本文整理汇总了Python中twilio.twiml.voice_response.VoiceResponse.play方法的典型用法代码示例。如果您正苦于以下问题:Python VoiceResponse.play方法的具体用法?Python VoiceResponse.play怎么用?Python VoiceResponse.play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twilio.twiml.voice_response.VoiceResponse
的用法示例。
在下文中一共展示了VoiceResponse.play方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_wait
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
def generate_wait():
twiml_response = VoiceResponse()
wait_message = 'Thank you for calling. Please wait in line for a few seconds. An agent will be with you shortly.'
wait_music = 'http://com.twilio.music.classical.s3.amazonaws.com/BusyStrings.mp3'
twiml_response.say(wait_message)
twiml_response.play(wait_music)
return str(twiml_response)
示例2: voice
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
def voice():
"""Respond to incoming calls with a simple text message."""
resp = VoiceResponse()
resp.say("Hello. It's me.")
resp.play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3")
return str(resp)
示例3: handle_recording
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
def handle_recording():
"""Play back the caller's recording."""
recording_url = request.values.get("RecordingUrl", None)
resp = VoiceResponse()
resp.say("Listen to your recorded message.")
resp.play(recording_url)
resp.say("Goodbye.")
return str(resp)
示例4: gatekeeper
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
def gatekeeper():
logger.info("Call started: %s", request.values)
response = VoiceResponse()
if 'notFirstCall' not in request.values:
# Accept Google voice call
response.play(digits='1')
add_gandalf_to_response(response)
return str(response)
示例5: post_valid
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
def post_valid(self, request):
"""Expects a POST request from Twilio, and return a response directing
Twilio to play the greeting mp3 and post the recorded response to
the handle voicemail URL
"""
response = VoiceResponse()
self.static_greeting_path = static(self.voicemail_static_path)
self.record_voicemail_url = request.build_absolute_uri(
reverse('phone-handle_new_message')).replace('http:', 'https:')
response.play(self.static_greeting_path)
response.record(action=self.record_voicemail_url, method='POST')
return HttpResponse(response)
示例6: voice
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
def voice():
"""Respond to incoming phone calls and mention the caller's city"""
# Get the caller's city from Twilio's request to our app
city = request.values['FromCity']
# Start our TwiML response
resp = VoiceResponse()
# Read a message aloud to the caller
resp.say('Never gonna give you up, {}!'.format(city), voice='alice')
# Play an audio file for the caller
resp.play('https://demo.twilio.com/docs/classic.mp3')
return str(resp)
示例7: voice
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
def voice():
resp = VoiceResponse()
# Greet the caller by name
resp.say("Hello. It's me. ")
# Play an mp3
resp.play("http://howtodocs.s3.amazonaws.com/ahoyhoy.mp3")
# Gather digits.
with resp.gather(numDigits=1, action="/handle-gather", method="POST") as g:
g.say(
"""To speak to a real person, press 1.
Press 2 to record a message for a Twilio educator.
Press any other key to start over."""
)
return str(resp)
示例8: play
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
def play(request, url, loop=None):
"""
See: http://www.twilio.com/docs/api/twiml/play.
Usage::
# urls.py
urlpatterns = patterns('',
# ...
url(r'^play/$', 'django_twilio.views.play', {
'url': 'http://blah.com/blah.wav',
}),
# ...
)
"""
r = VoiceResponse()
r.play(url, loop=loop)
return r
示例9: password_entered
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
def password_entered():
digits = request.values['Digits']
logger.info("Password entered: %s", digits)
response = VoiceResponse()
if digits == "12345":
correct_clip = pick_random_file("correct")
response.play(correct_clip)
response.play(digits="9")
elif digits == "54321":
response.play(digits="99")
else:
wrong_clip = pick_random_file("wrong")
response.play(wrong_clip)
add_gandalf_to_response(response)
return str(response)
示例10: VoiceResponse
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
from twilio.twiml.voice_response import Play, VoiceResponse
response = VoiceResponse()
response.play('', digits='wwww3')
print(response)
示例11: VoiceResponse
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
from twilio.twiml.voice_response import Play, VoiceResponse
response = VoiceResponse()
response.play('https://api.twilio.com/cowbell.mp3', loop=10)
print(response)
示例12: route_call
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
def route_call(request):
digits = int(request.POST.get('Digits', '0'))
call_origin = request.POST.get('From', None)
call_log = Call.objects.create(twilio_id=request.POST.get('CallSid', None),
type="incoming",
incoming_number=call_origin)
if digits == 1:
message = "https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-transferring-sales.mp3"
numbers = [(73, '+66819189145')]
clients = [(73, "sidarat")]
caller_id = call_origin or '+6625088681'
call_log.forwarding_number = '+66819189145'
call_log.save()
elif digits == 2:
message = "https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-transferring-customer-service.mp3"
numbers = [(16, '+66914928558'), (42, '+66952471426'), (42, '+66634646465')]
clients = [(16, "chup"), (42, 'apaporn')]
caller_id = '+6625088681'
elif digits == 3:
message = "https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-transferring-accounting.mp3"
numbers = [(63, '+66988325610')]
clients = [(63, "mays")]
caller_id = '+6625088681'
elif digits == 8:
message = "https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-transferring-accounting.mp3"
numbers = [(1, '+66990041468')]
clients = [(1, "charliephairoj")]
caller_id = "+6625088681"
call_log.forwarding_number = '+66990041468'
call_log.save()
else:
message = "https://s3-ap-southeast-1.amazonaws.com/media.dellarobbiathailand.com/ivr/audio-transferring-customer-service.mp3"
numbers = [(16, '+66914928558'), (42, '+66952471426')]
clients = [(16, "chup"), (42, 'apaporn')]
caller_id = '+6625088681' or '+6625088681'
resp = VoiceResponse()
resp.play(message)
dial = Dial(caller_id=caller_id,
record='record-from-ringing',
recording_status_callback="/api/v1/ivr/recording/")
for number in numbers:
dial.number(number[1],
status_callback_event='answered completed',
status_callback=_get_status_callback_url(number[0]),
status_callback_method="GET")
for client in clients:
dial.client(client[1],
status_callback_event='answered completed',
status_callback=_get_status_callback_url(client[0]),
status_callback_method="GET")
resp.append(dial)
return HttpResponse(resp)
示例13: VoiceResponse
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
from twilio.twiml.voice_response import Play, VoiceResponse
response = VoiceResponse()
response.play(
'http://com.twilio.sounds.music.s3.amazonaws.com/MARKOVICHAMP-Borghestral.mp3'
)
print(response)
示例14: VoiceResponse
# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import play [as 别名]
from twilio.twiml.voice_response import Play, VoiceResponse, Say
response = VoiceResponse()
response.say('Hello World')
response.play('https://api.twilio.com/Cowbell.mp3')
print(response)