forked from signalwire/freeswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmytest.py
More file actions
38 lines (33 loc) · 1.37 KB
/
Copy pathmytest.py
File metadata and controls
38 lines (33 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Please see latest version of this script at
# http://wiki.freeswitch.org/wiki/Mod_python
# before reporting errors
from freeswitch import *
def onDTMF(input, itype, funcargs):
console_log("1", "\n\nonDTMF input: %s\n" % input)
if input == "5":
return "pause"
if input == "3":
return "seek:+60000"
if input == "1":
return "seek:-60000"
if input == "0":
return "stop"
return None # will make the streamfile audio stop
def handler(uuid):
console_log("1", "... test from my python program\n")
session = PySession(uuid)
session.answer()
session.setDTMFCallback(onDTMF, "")
session.set_tts_parms("cepstral", "david")
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)
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)
session.transfer("1000", "XML", "default")
session.hangup("1")