Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
b0e86e65
提交
b0e86e65
authored
7月 03, 2014
作者:
areski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
misc of python pep8 fixes
上级
39200cd1
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
98 行增加
和
100 行删除
+98
-100
fshelper.py
scripts/python/freepy/fshelper.py
+51
-53
models.py
scripts/python/freepy/models.py
+5
-4
request.py
scripts/python/freepy/request.py
+17
-17
mytest.py
scripts/python/mytest.py
+12
-13
recipewizard.py
scripts/python/recipewizard.py
+13
-13
没有找到文件。
scripts/python/freepy/fshelper.py
浏览文件 @
b0e86e65
...
...
@@ -31,6 +31,7 @@ from twisted.internet import reactor, defer
from
twisted.internet.protocol
import
ClientFactory
import
freepy
class
FsHelper
(
ClientFactory
):
def
__init__
(
self
,
host
=
None
,
passwd
=
None
,
port
=
None
):
...
...
@@ -72,7 +73,6 @@ class FsHelper(ClientFactory):
self
.
connection_deferred
=
None
deferred2callback
.
callback
(
"Connected"
)
def
generalError
(
self
,
failure
):
print
"General error:
%
s"
%
failure
return
failure
...
...
@@ -128,9 +128,6 @@ class FsHelper(ClientFactory):
d
.
addCallback
(
originate_inner
)
return
d
def
dialconf
(
self
,
people2dial
,
conf_name
,
bgapi
=
True
):
"""
conf_name - name of conf TODO: change to match db
...
...
@@ -215,7 +212,6 @@ class FsHelper(ClientFactory):
d
.
addCallback
(
confdtmf_inner
)
return
d
def
confsay
(
self
,
conf_name
,
text2speak
,
bgapi
=
True
):
"""
conf_name - name of conf
...
...
@@ -268,7 +264,6 @@ class FsHelper(ClientFactory):
d
.
addCallback
(
confstop_inner
)
return
d
def
showchannels
(
self
,
bgapi
=
True
):
def
showchannels_inner
(
ignored
):
...
...
@@ -289,7 +284,6 @@ class FsHelper(ClientFactory):
d
.
addCallback
(
killchan_inner
)
return
d
def
broadcast
(
self
,
uuid
,
path
,
legs
=
"both"
,
bgapi
=
True
):
"""
@legs - one of the following strings: aleg|bleg|both
...
...
@@ -325,12 +319,10 @@ class FsHelper(ClientFactory):
d
.
addCallback
(
sofia_profile_restart_inner
)
return
d
def
sofia_status_profile
(
self
,
profile_name
,
bgapi
=
True
):
def
sofia_status_profile_inner
(
ignored
):
df
=
self
.
freepyd
.
sofia_status_profile
(
profile_name
,
bgapi
)
df
=
self
.
freepyd
.
sofia_status_profile
(
profile_name
,
bgapi
)
return
df
d
=
self
.
connect
()
...
...
@@ -340,7 +332,7 @@ class FsHelper(ClientFactory):
class
FsHelperTest
:
def
__init__
(
self
,
fshelper
):
self
.
fshelper
=
fshelper
self
.
fshelper
=
fshelper
pass
def
test_dialconf
(
self
):
...
...
@@ -349,10 +341,16 @@ class FsHelperTest:
# called "freeswitch" on the local freeswitch instance.
# one party is actually another conference, just to make
# the example more confusing.
people2dial
=
[{
'name'
:
'freeswitch'
,
'number'
:
'888@conference.freeswitch.org'
},
{
'name'
:
'mouselike'
,
'number'
:
'904@mouselike.org'
}]
people2dial
=
[
{
'name'
:
'freeswitch'
,
'number'
:
'888@conference.freeswitch.org'
},
{
'name'
:
'mouselike'
,
'number'
:
' 904@mouselike.org'
}
]
d
=
self
.
fshelper
.
dialconf
(
people2dial
,
"freeswitch"
,
bgapi
=
False
)
def
failed
(
error
):
print
"Failed to dial users!"
...
...
@@ -494,8 +492,7 @@ def test5():
#reactor.stop()
for
i
in
xrange
(
20
):
party2dial
=
"sofia/foo/600@192.168.1.202:5080"
party2dial
=
"sofia/foo/600@192.168.1.202:5080"
d
=
fshelper
.
originate
(
party2dial
=
party2dial
,
dest_ext_app
=
"700"
,
bgapi
=
True
)
...
...
@@ -504,6 +501,7 @@ def test5():
reactor
.
run
()
def
test6
():
"""
show channels for a given sofia profile
...
...
@@ -524,7 +522,7 @@ def test6():
reactor
.
run
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
#test1()
#test2()
#test3()
...
...
scripts/python/freepy/models.py
浏览文件 @
b0e86e65
...
...
@@ -30,6 +30,7 @@ Data models for objects inside freeswitch
import
re
class
ConfMember
:
def
__init__
(
self
,
rawstring
):
...
...
scripts/python/freepy/request.py
浏览文件 @
b0e86e65
scripts/python/mytest.py
浏览文件 @
b0e86e65
...
...
@@ -2,11 +2,11 @@
# http://wiki.freeswitch.org/wiki/Mod_python
# before reporting errors
import
sys
,
time
from
freeswitch
import
*
def
onDTMF
(
input
,
itype
,
funcargs
):
console_log
(
"1"
,
"
\n\n
onDTMF input:
%
s
\n
"
%
input
)
console_log
(
"1"
,
"
\n\n
onDTMF input:
%
s
\n
"
%
input
)
if
input
==
"5"
:
return
"pause"
if
input
==
"3"
:
...
...
@@ -17,9 +17,9 @@ def onDTMF(input, itype, funcargs):
return
"stop"
return
None
# will make the streamfile audio stop
def
handler
(
uuid
):
console_log
(
"1"
,
"... test from my python program
\n
"
)
def
handler
(
uuid
):
console_log
(
"1"
,
"... test from my python program
\n
"
)
session
=
PySession
(
uuid
)
session
.
answer
()
session
.
setDTMFCallback
(
onDTMF
,
""
)
...
...
@@ -27,13 +27,12 @@ def handler(uuid):
session
.
playFile
(
"/path/to/your.mp3"
,
""
)
session
.
speak
(
"Please enter telephone number with area code and press pound sign. "
)
input
=
session
.
getDigits
(
""
,
11
,
"*#"
,
"#"
,
10000
)
console_log
(
"1"
,
"result from get digits is
%
s
\n
"
%
input
)
console_log
(
"1"
,
"result from get digits is
%
s
\n
"
%
input
)
phone_number
=
session
.
playAndGetDigits
(
5
,
11
,
3
,
10000
,
"*#"
,
"/sounds/test.gsm"
,
"/sounds/invalid.gsm"
,
""
,
"^17771112222$"
)
;
console_log
(
"1"
,
"result from play_and_get_digits is
%
s
\n
"
%
phone_number
)
"^17771112222$"
)
console_log
(
"1"
,
"result from play_and_get_digits is
%
s
\n
"
%
phone_number
)
session
.
transfer
(
"1000"
,
"XML"
,
"default"
)
session
.
hangup
(
"1"
)
scripts/python/recipewizard.py
浏览文件 @
b0e86e65
...
...
@@ -2,7 +2,7 @@ from freeswitch import *
from
py_modules.speechtools
import
Grammar
,
SpeechDetect
from
py_modules.speechtools
import
SpeechObtainer
import
time
,
os
import
os
VOICE_ENGINE
=
"cepstral"
VOICE
=
"William"
...
...
@@ -20,24 +20,24 @@ How to make this work:
"""
class
RecipeWizard
:
def
__init__
(
self
,
session
):
self
.
session
=
session
self
.
session
=
session
self
.
session
.
set_tts_parms
(
VOICE_ENGINE
,
VOICE
)
self
.
main
()
def
main
(
self
):
console_log
(
"debug"
,
"recipe wizard main()
\n
"
)
self
.
speechdetect
=
SpeechDetect
(
self
.
session
,
"openmrcp"
,
"127.0.0.1"
)
;
self
.
speechdetect
=
SpeechDetect
(
self
.
session
,
"openmrcp"
,
"127.0.0.1"
)
self
.
speechobtainer
=
SpeechObtainer
(
speech_detect
=
self
.
speechdetect
,
required_phrases
=
1
,
wait_time
=
5000
,
max_tries
=
3
)
gfile
=
os
.
path
.
join
(
GRAMMAR_ROOT
,
"mainmenu.xml"
)
self
.
grammar
=
Grammar
(
"mainmenu"
,
gfile
,
"input"
,
80
,
90
)
self
.
speechobtainer
.
setGrammar
(
self
.
grammar
)
;
self
.
grammar
=
Grammar
(
"mainmenu"
,
gfile
,
"input"
,
80
,
90
)
self
.
speechobtainer
.
setGrammar
(
self
.
grammar
)
console_log
(
"debug"
,
"calling speechobtainer.run()
\n
"
)
self
.
speechobtainer
.
detectSpeech
()
self
.
session
.
speak
(
"Hello. Welcome to the recipe wizard. Drinks or food?"
)
...
...
@@ -50,6 +50,7 @@ class RecipeWizard:
console_log
(
"debug"
,
"speechobtainer.run() finished
\n
"
)
def
mainmenu
():
"""
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
...
...
@@ -78,10 +79,9 @@ def mainmenu():
"""
pass
def
handler
(
uuid
):
session
=
PySession
(
uuid
)
session
.
answer
()
rw
=
RecipeWizard
(
session
)
session
.
hangup
(
"1"
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论