本文整理汇总了Python中tropo.Tropo.record方法的典型用法代码示例。如果您正苦于以下问题:Python Tropo.record方法的具体用法?Python Tropo.record怎么用?Python Tropo.record使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tropo.Tropo
的用法示例。
在下文中一共展示了Tropo.record方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_pitch
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import record [as 别名]
def do_pitch(self):
pitch_id = self.generate_pitch_id()
pitch_pin = self.generate_pitch_pin()
pitch_key = self.generate_pitch_key()
pitch.new_pitch(pitch_id, pitch_pin, pitch_key, "pending")
### @export "recording-instructions"
t = Tropo()
t.say("You will soon be prompted to record your elevator pitch")
t.say("Please have pen and paper ready")
t.say("Please start making your pitch when you hear the beep")
### @export "make-recording"
t_url = "http://50.17.37.57:8081/transcription/%s" % pitch_key
t.record(
beep = True,
choices = '#',
maxTime = 120,
say = """Press pound when finished
to listen to your recording.""",
silenceTimeout = 7,
timeout = 10,
transcription = {
"url" : t_url
},
url = "http://50.17.37.57:8081/record/%s" % pitch_key
)
### @export "finish"
t.on(event="continue", next="/record/after/%s" % pitch_id)
return t.RenderJson()
示例2: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import record [as 别名]
def index(request):
t = Tropo()
t.call("+xxx")
t.record(name = "recording", timeout = 10, maxSilence = 7, maxTime = 60, choices = {"terminator": "#"}, transcription = {"id":"1234", "url":"mailto:[email protected]", "language":"de_DE"}, say = {"value":"Willkommen zur Abfage! Sag uns bitte, wie es dir geht!"}, url = "http://www.example.com/recordings.py", voice =" Katrin")
return t.RenderJson()
示例3: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import record [as 别名]
def index(request):
t = Tropo()
VOICE = 'Grace'
t.record(name='voicemail.mp3', say='Your call is important. Please leave a short message after the tone: ', url = 'http://www.example.com', beep = True, format = 'audio/mp3', voice = VOICE)
return t.RenderJson()
示例4: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import record [as 别名]
def index(request):
t = Tropo()
VOICE = 'Grace'
transcriptionobj = Transcription(id = "tropo-12123", url = "http://192.168.26.88:8080/FileUpload/uploadFile", language = "English").json
t.record(transcription = transcriptionobj, name='voicemail.wav', say='Your call is important. Please leave a short message after the tone: ', url = 'http://192.168.26.88:8080/FileUpload/uploadFile', beep = True, formamt = 'audio/wav', sensitivity = 5.3)
return t.RenderJson()
示例5: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import record [as 别名]
def index(request):
t = Tropo()
VOICE = 'Grace'
transcriptionobj = Transcription(id = "tropo-12123", url = "http://192.168.26.88:8080/FileUpload/uploadFile", language = "English").json
recordURLobj1 = RecordUrlTuple(url = "http://192.168.26.88:8080/FileUpload/uploadFile1", username = "fakename1", password="fakepassword", method="POST").json
recordURLobj2 = RecordUrlTuple(url = "http://192.168.26.88:8080/FileUpload/uploadFile", username = "fakename2", password="fakepassword", method="POST").json
recordURLobj3 = RecordUrlTuple(url = "http://192.168.26.88:8080/FileUpload/uploadFile3", username = "fakename3", password="fakepassword", method="POST").json
recordURLobj4 = RecordUrlTuple(url = "http://192.168.26.88:8080/FileUpload/uploadFile4", username = "fakename4", password="fakepassword", method="POST").json
t.record(url = [recordURLobj1, recordURLobj2, recordURLobj3, recordURLobj4],transcription = transcriptionobj, name='voicemail.wav', say='Your call is important. Please leave a short message after the tone: ', beep = True, formamt = 'audio/wav', sensitivity = 5.3)
return t.RenderJson()
示例6: test_record
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import record [as 别名]
def test_record(self):
"""
Test the "record" Tropo class method.
"""
tropo = Tropo()
url = "/receive_recording.py"
choices_obj = Choices("", terminator="#").json
tropo.record(say="Tell us about yourself", url=url,
choices=choices_obj)
rendered = tropo.RenderJson()
pretty_rendered = tropo.RenderJson(pretty=True)
print "===============test_record================="
print "render json: %s" % pretty_rendered
# print "test_record: %s" % tropo.RenderJson()
rendered_obj = jsonlib.loads(rendered)
wanted_json = ' {"tropo": [{"record": {"url": "/receive_recording.py", "say": {"value": "Tell us about yourself"}, "choices": {"terminator": "#", "value": ""}}}]}'
wanted_obj = jsonlib.loads(wanted_json)
self.assertEqual(rendered_obj, wanted_obj)
示例7: home
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import record [as 别名]
def home():
# Generate a user cookie value. This is kept in the url args throughout
# the session.
user = User()
db.session.add(user)
db.session.commit()
userid = user.userid
t = Tropo()
t.record(
name='myrecording',
say="What website to visit? Speak your query for an I'm Feeling Lucky Google search.",
choices={'terminator': '#'},
url='http://infinite-cove-6526.herokuapp.com/record?userid={0}' \
.format(userid),
asyncUpload=True,
maxTime=10,
maxSilence=3,
)
t.on(event='continue', next='/wait_for_recog?userid={0}'.format(userid))
t.on(event='incomplete', next='/home')
t.on(event='error', next='/home')
return t.RenderJson()
示例8: CallResponse
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import record [as 别名]
class CallResponse(object):
'''
A response to a request from a voip provider such as twilio or tropo.
Abstracts common verbs such as .say() and .ask() and .conference() and provides the appropriate command for the provider.
'''
def __init__(self, provider, *args, **kwargs):
'''
Takes a PhoneProvider object, sets the provider for this response to that provider.
'''
self.provider = provider
if provider.name == "Twilio":
self.response_object = twiml.Response()
if provider.name == "Tropo":
self.response_object = Tropo()
super(CallResponse, self).__init__()
def render(self):
if self.provider.name == "Twilio":
return HttpResponse(self.response_object, mimetype='text/xml')
if self.provider.name == "Tropo":
return HttpResponse(self.response_object.RenderJson(), mimetype='text/json')
def say(self, *args, **kwargs):
if self.provider.name == "Twilio":
if kwargs['voice'] == 'Allison' or kwargs['voice'] == 'Susan' or kwargs['voice'] == 'Vanessa':
kwargs['voice'] = 'woman'
else:
kwargs['voice'] = 'man'
return self.response_object.addSay(*args, **kwargs)
if self.provider.name == "Tropo":
return self.response_object.say(*args, **kwargs)
def transfer(self, *args, **kwargs):
if self.provider.name == "Twilio":
return self.response_object.addDial(*args, **kwargs)
if self.provider.name == "Tropo":
return self.response_object.transfer(*args, **kwargs)
def conference(self, start_recording=False, *args, **kwargs):
if self.provider.name == "Twilio":
if start_recording:
dial = self.response_object.addDial(record=True, action='%s/comm/recording_handler/call/%s/' % (resources.COMM_DOMAIN, kwargs['conference_id']))
else:
dial = self.response_object.addDial()
startConferenceOnEnter = True if 'start_now' in kwargs and kwargs['start_now'] else False #Sometimes we want this joiner to start the conference. Sometimes not.
command = dial.addConference(kwargs['conference_id'], startConferenceOnEnter=startConferenceOnEnter)
comm_logger.info('Telling Twilio: %s' % dial)
return command
if self.provider.name == "Tropo":
self.response_object.on("hangup", next="/comm/handle_hangup/%s/%s/" % (kwargs['conference_id'], kwargs['number'].id))
if 'record' in kwargs and kwargs['record']:
self.response_object.startRecording('%s/comm/recording_handler/call/%s/' % (resources.COMM_DOMAIN, kwargs['conference_id']), format="audio/mp3")
return self.response_object.conference(kwargs['conference_id'], allowSignals=['leaveConference',], *args, **kwargs)
def conference_holding_pattern(self, conference_id, number_object, hold_music):
'''
Put someone on hold, perparing them for a conference. During their hold, play the hold music.
'''
if self.provider.name == "Twilio":
dial = self.response_object.addDial()
reactor.callFromThread(twilio_deferred_voicemail_determination, conference_id, 30)
return dial.addConference(conference_id)#TODO: waitUrl=hold_music)
if self.provider.name == "Tropo":
#First we add the hold music, allowing for the "exithold" signal to end it.
self.response_object.say(hold_music, allowSignals=["joinConference", "goToVoiceMail", "incomplete"])
self.response_object.on("hangup", next="/comm/handle_hangup/%s/%s/" % (conference_id, number_object.id))
self.response_object.on('joinConference', next="/comm/simply_join_conference/%s/%s/" % (conference_id, number_object.id))
self.response_object.on('goToVoiceMail', next="/comm/voicemail/")
reactor.callFromThread(send_deferred_tropo_signal, conference_id, 'goToVoiceMail', 40) #How to test this?
def join_and_begin_conference(self, conference_id, number, *args, **kwargs):
'''
Join the user to a conference that started with a holding pattern and begin the conference.
'''
comm_logger.info('%s is beginning conference %s', number, conference_id)
conference_kwargs = {'conference_id':conference_id, 'number':number}
if self.provider.name == "Twilio":
conference_kwargs['start_now'] = True
if self.provider.name == "Tropo":
reactor.callFromThread(send_deferred_tropo_signal, conference_id, 'joinConference', 0)
self.conference(start_recording=True, **conference_kwargs)
return True #We can't know anything meaningful because we aren't going to wait around for the signal.
def on(self, *args, **kwargs):
if self.provider.name == "Twilio":
raise NotImplementedError("Twilio does not offer an equivalent to Tropo's .on() method.")
if self.provider.name == "Tropo":
return self.response_object.on(*args, **kwargs)
def call(self, *args, **kwargs):
if self.provider.name == "Twilio":
raise NotImplementedError("Twilio does not offer an equivalent to Tropo's .call() method.")
if self.provider.name == "Tropo":
if 'caller_id' in kwargs:
kwargs['from'] = kwargs['caller_id'] #Why Tropo, do you think it's acceptable to use a python command (from) in your lib?
return self.response_object.call(*args, **kwargs)
#.........这里部分代码省略.........
示例9: Tropo
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import record [as 别名]
tropo = Tropo()
tropo.ask("[5 digits]",
say = Say("Please enter a 5 digit zip code").json)
tropo.call (TO)
tropo.conference(ID)
tropo.hangup()
tropo.message ("Hello, World", TO)
tropo.on(event="continue",
next="http://example.com/weather.py",
say="Please hold.")
tropo.record(say="Please say something for posterity",
url=URL,
choices = Choices("", terminator="#").json)
tropo.redirect(ID)
tropo.reject(ID)
tropo.startRecording(URL)
tropo.stopRecording()
tropo.transfer(TO)
tropo.message("Hello, World",
TO,
channel='TEXT',
network='SMS')
else:
unittest.main()