当前位置: 首页>>代码示例>>Python>>正文


Python VoiceResponse.say方法代码示例

本文整理汇总了Python中twilio.twiml.voice_response.VoiceResponse.say方法的典型用法代码示例。如果您正苦于以下问题:Python VoiceResponse.say方法的具体用法?Python VoiceResponse.say怎么用?Python VoiceResponse.say使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twilio.twiml.voice_response.VoiceResponse的用法示例。


在下文中一共展示了VoiceResponse.say方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: example

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [as 别名]
def example():
    """
    Some example usage of different twilio resources.
    """
    client = Client(ACCOUNT_SID, AUTH_TOKEN)

    # Get all messages
    all_messages = client.messages.list()
    print('There are {} messages in your account.'.format(len(all_messages)))

    # Get only last 10 messages...
    some_messages = client.messages.list(limit=10)
    print('Here are the last 10 messages in your account:')
    for m in some_messages:
        print(m)

    # Get messages in smaller pages...
    all_messages = client.messages.list(page_size=10)
    print('There are {} messages in your account.'.format(len(all_messages)))

    print('Sending a message...')
    new_message = client.messages.create(to='XXXX', from_='YYYY', body='Twilio rocks!')

    print('Making a call...')
    new_call = client.calls.create(to='XXXX', from_='YYYY', method='GET')

    print('Serving TwiML')
    twiml_response = VoiceResponse()
    twiml_response.say('Hello!')
    twiml_response.hangup()
    twiml_xml = twiml_response.to_xml()
    print('Generated twiml: {}'.format(twiml_xml))
开发者ID:kanyapnp,项目名称:twilio-python,代码行数:34,代码来源:basic_usage.py

示例2: incoming_call

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [as 别名]
def incoming_call(request):
    """ Returns TwiML instructions to Twilio's POST requests """
    resp = VoiceResponse()
    resp.say("For Programmable SMS, press one. For Voice, press any other key.")
    resp.gather(numDigits=1, action="/call/enqueue", method="POST")

    return HttpResponse(resp)
开发者ID:TwilioDevEd,项目名称:task-router-django,代码行数:9,代码来源:views.py

示例3: generate_wait

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [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)
开发者ID:TwilioDevEd,项目名称:warm-transfer-flask,代码行数:9,代码来源:twiml_generator.py

示例4: get_voice_twiml

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [as 别名]
def get_voice_twiml():
    """Respond to incoming calls with a simple text message."""

    resp = VoiceResponse()
    resp.say("Thanks for calling!")

    return Response(str(resp), mimetype='text/xml')
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:9,代码来源:response-twiml.6.x.py

示例5: voice

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:9,代码来源:example-1.6.x.py

示例6: voice

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [as 别名]
def voice():
    """Respond to incoming phone calls with a 'Hello world' message"""
    # Start our TwiML response
    resp = VoiceResponse()

    # Read a message aloud to the caller
    resp.say("hello world!", voice='alice')

    return str(resp)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:11,代码来源:example.6.x.py

示例7: handle_recording

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:12,代码来源:twiml-record.6.x.py

示例8: get_voice_twiml

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [as 别名]
def get_voice_twiml():
    """Respond to incoming calls with a simple text message."""

    resp = VoiceResponse()
    if "To" in request.form:
        resp.dial(request.form["To"], callerId="+15017250604")
    else:
        resp.say("Thanks for calling!")

    return Response(str(resp), mimetype='text/xml')
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:12,代码来源:response-twiml-dial.6.x.py

示例9: voice

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [as 别名]
def voice():
    """Respond to incoming phone calls with a text message."""
    # Start our TwiML response
    resp = VoiceResponse()

    # Read a message aloud to the caller
    resp.say("Hello! You will get an SMS message soon.")

    # Also tell Twilio to send a text message to the caller
    resp.sms("This is the ship that made the Kessel Run in fourteen parsecs?")

    return str(resp)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:14,代码来源:example-1.6.x.py

示例10: outbound

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [as 别名]
def outbound():
    response = VoiceResponse()

    response.say("Thank you for contacting our sales department. If this "
                 "click to call application was in production, we would "
                 "dial out to your sales team with the Dial verb.",
                 voice='alice')
    '''
    # Uncomment this code and replace the number with the number you want
    # your customers to call.
    response.number("+16518675309")
    '''
    return str(response)
开发者ID:TwilioDevEd,项目名称:clicktocall-flask,代码行数:15,代码来源:app.py

示例11: voice_twiml

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [as 别名]
def voice_twiml(question):
    response = VoiceResponse()
    response.say(question.content)
    response.say(VOICE_INSTRUCTIONS[question.kind])

    action_url = url_for('answer', question_id=question.id)
    transcription_url = url_for('answer_transcription',
                                question_id=question.id)
    if question.kind == Question.TEXT:
        response.record(action=action_url,
                        transcribe_callback=transcription_url)
    else:
        response.gather(action=action_url)
    return str(response)
开发者ID:TwilioDevEd,项目名称:automated-survey-flask,代码行数:16,代码来源:question_view.py

示例12: record

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [as 别名]
def record():
    """Returns TwiML which prompts the caller to record a message"""
    # Start our TwiML response
    response = VoiceResponse()

    # Use <Say> to give the caller some instructions
    response.say('Hello. Please leave a message and I will transcribe it.')

    # Use <Record> to record and transcribe the caller's message
    response.record(transcribe=True, max_length=30)

    # End the call with <Hangup>
    response.hangup()

    return str(response)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:17,代码来源:example.6.x.py

示例13: say

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [as 别名]
def say(request, text, voice=None, language=None, loop=None):
    """
See: http://www.twilio.com/docs/api/twiml/say.

Usage::

    # urls.py
    urlpatterns = patterns('',
        # ...
        url(r'^say/$', 'django_twilio.views.say', {'text': 'hello, world!'})
        # ...
    )
    """
    r = VoiceResponse()
    r.say(text, voice=voice, language=language, loop=loop)
    return r
开发者ID:boardman,项目名称:django-twilio,代码行数:18,代码来源:views.py

示例14: get_voice_twiml

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [as 别名]
def get_voice_twiml():
    """Respond to incoming calls with a simple text message."""

    resp = VoiceResponse()
    if "To" in request.form:
        dial = Dial(callerId="+15017250604")
        # wrap the phone number or client name in the appropriate TwiML verb
        # by checking if the number given has only digits and format symbols
        if phone_pattern.match(request.form["To"]):
            dial.number(request.form["To"])
        else:
            dial.client(request.form["To"])
        resp.append(dial)
    else:
        resp.say("Thanks for calling!")

    return Response(str(resp), mimetype='text/xml')
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:19,代码来源:response-twiml-client.6.x.py

示例15: voice

# 需要导入模块: from twilio.twiml.voice_response import VoiceResponse [as 别名]
# 或者: from twilio.twiml.voice_response.VoiceResponse import say [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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:19,代码来源:twiml-record.6.x.py


注:本文中的twilio.twiml.voice_response.VoiceResponse.say方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。