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


Python Tropo.say方法代码示例

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


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

示例1: do_confirm_ok

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
 def do_confirm_ok(self, candidate_id):
     caller_id = models.caller_id_if_valid(self.call_id())
     models.record_vote(caller_id, candidate_id)
     t = Tropo()
     t.say("Great, your vote has been counted. Goodbye.")
     t.message("Thanks for voting! Tropo <3 you!", channel="TEXT", to=caller_id)
     return t.RenderJson()
开发者ID:ananelson,项目名称:tropo-vote,代码行数:9,代码来源:vote.py

示例2: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
def index(request):
    s = Session(request.body)
    t = Tropo()
    t.say('12345', _as='DIGITS', voice='dave')
    json = t.RenderJson()
    print(json)
    return json
开发者ID:buildingspeak,项目名称:tropo-webapi-python,代码行数:9,代码来源:gh-14.test_say.py

示例3: speak_webpage

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
def speak_webpage():
    print "speak_webpage"
    t = Tropo()
    userid = request.args.get('userid', None)
    if userid is None:
        t.say("No user specified. Error.")
        t.on(event='continue', next='/home')
        return t.RenderJson()
    userid = int(userid)
    user = User.query.filter_by(userid=userid).first()

    url = im_feeling_lucky(user.voice_query)

    webpage = extract.ParsedWebpage(url)
    page_n = int(request.args['page'])
    if page_n >= len(webpage.chunks):
        t.say("End of document.")
        t.on(event='continue', next='/home')
        return t.RenderJson()

    # Deal with the variety of commands you can use to navigate.
    t.ask(
        choices='link([1-4 DIGITS]), command(next, home)',
        say=webpage.chunks[page_n],
        bargein=False,
    )
    t.on(event='continue', next='/deal_with_links?userid={0}&page={1}'
        .format(userid, page_n))
    return t.RenderJson()
开发者ID:fephsun,项目名称:dialup,代码行数:31,代码来源:run.py

示例4: tropo

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
def tropo():
    """
        Receive a JSON POST from the Tropo WebAPI

        @see: https://www.tropo.com/docs/webapi/newhowitworks.htm
    """

    # Stored in modules/tropo.py
    from tropo import Tropo, Session

    try:
        s = Session(request.body.read())
        t = Tropo()
        # This is their service contacting us, so parse their request
        try:
            row_id = s.parameters["row_id"]
            # This is an Outbound message which we've requested Tropo to send for us
            table = s3db.msg_tropo_scratch
            query = (table.row_id == row_id)
            row = db(query).select().first()
            # Send the message
            #t.message(say_obj={"say":{"value":row.message}},to=row.recipient,network=row.network)
            t.call(to=row.recipient, network=row.network)
            t.say(row.message)
            # Update status to sent in Outbox
            outbox = s3db.msg_outbox
            db(outbox.id == row.row_id).update(status=2)
            # Set message log to actioned
            log = s3db.msg_log
            db(log.id == row.message_id).update(actioned=True)
            # Clear the Scratchpad
            db(query).delete()
            return t.RenderJson()
        except:
            # This is an Inbound message
            try:
                message = s.initialText
                # This is an SMS/IM
                # Place it in the InBox
                uuid = s.id
                recipient = s.to["id"]
                try:
                    fromaddress = s.fromaddress["id"]
                except:
                    # SyntaxError: s.from => invalid syntax (why!?)
                    fromaddress = ""
                s3db.msg_log.insert(uuid=uuid, fromaddress=fromaddress,
                                    recipient=recipient, message=message,
                                    inbound=True)
                # Send the message to the parser
                reply = msg.parse_message(message)
                t.say([reply])
                return t.RenderJson()
            except:
                # This is a Voice call
                # - we can't handle these yet
                raise HTTP(501)
    except:
        # GET request or some random POST
        pass
开发者ID:mrbtano,项目名称:eden,代码行数:62,代码来源:msg.py

示例5: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
 def index(self):
     t = Tropo()
     t.say("Welcome to Pitchlift")
     choices = Choices(self.choices())
     t.ask(choices, say=self.prompt())
     t.on(event="continue", next="/menu/cont")
     return t.RenderJson()
开发者ID:evelynmitchell,项目名称:dexy-site,代码行数:9,代码来源:pitchlift2.py

示例6: post

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
    def post(self, request):
        t = Tropo()
        r = Result(request.body)
        log.debug('PlayCode got: %s', request.body.__repr__())

        session = m.Session.objects.get(identifier=r._sessionId)
        player = session.player

        if r._state == 'DISCONNECTED':
            log.info('player %s disconnected', session.player)
            return HttpResponse(t.RenderJson())
            
        # see if there's a user-entered code
        try:
            code = r.getValue()
        except KeyError:
            t.say("Please try again.")
            code = None

        # if there's a code, try changing the station
        if code:
            try:
                song = m.SongStation.objects.get(select_code=code)
                player.completed_stations.add(song)
                player.current_station = song
                player.save()
            except ObjectDoesNotExist:
                t.say("Sorry, %s is invalid" % code)

        prompt_player(t, player)

        tropo_response = t.RenderJson()
        log.debug('PlayCode returning %s', tropo_response)
        return HttpResponse(tropo_response)
开发者ID:sporksmith,项目名称:dance_ave,代码行数:36,代码来源:views.py

示例7: TropoCallback

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
    def TropoCallback (rh):
        tropo = Tropo()

        # Get the session object sent by Tropo
        s = Session(rh.request.body)
        logging.info("session: %s " % rh.request.body)

        callerID = s.fromaddress['id']
        logging.info ("Caller ID: %s " % callerID)

        # Try to find a custom header we use in client app to pass a pal name
        if 'x-username' in s.headers:
            pal = s.headers['x-username']
            logging.info ("Pal : %s " % pal)

            # Find sid for this pal
            sipendpoint = ''
            user = TropoPals.get_record("1",pal)
            if user:
                sipendpoint = ':'.join(("sip", user.phonosid))

            logging.info ("sip endpoint: %s " % sipendpoint)
            if len(sipendpoint) != 0:
                tropo.transfer(sipendpoint)
                #tropo.say("User is found")
            else:
                tropo.say("User is not found")
        else:
            tropo.say("This is a purple application!")

        return tropo.RenderJson()
开发者ID:fimkap,项目名称:tropo-purple,代码行数:33,代码来源:tcb_logic.py

示例8: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
def index(request):

	r = Result(request.body)        
        print "request.body : %s" % request.body

	t = Tropo()

	answer = r.getInterpretation()
	value = r.getValue()
        
	t.say("You said " + answer + ", which is a " + value)
        
        actions_options_array = ['name', 'attempts', 'disposition', 'confidence', 'interpretation', 'utterance', 'value', 'concept', 'xml', 'uploadStatus']
        actions = r.getActions()
	if (type (actions) is list):
	     for item in actions:
		for opt in actions_options_array:
                    print 'action object filed %(actionfieldname)s\'s value is %(vaalue)s' % {'actionfieldname':opt, "vaalue":item.get(opt,'NoValue')}
                print '------------------------------'
             
       	else:
            dict = actions
	    for opt in actions_options_array:
                print 'action object filed %(actionfieldname)s\'s value is %(vaalue)s' % {'actionfieldname':opt, "vaalue":dict.get(opt,'NoValue')}
        
        json = t.RenderJson()
        print json
	return json
开发者ID:tropo,项目名称:tropo-webapi-python,代码行数:30,代码来源:gh-20-test_ask.py

示例9: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
def index(request):
    s = Session(request.body)
    t = Tropo()
    t.setVoice('dave')
    # we use what has been set in Tropo object
    t.say(['hello world!'])
    # we use what is set in the method call
    t.say(['hello world!'], voice="allison")

    # we use the voice that has been set in Tropo object
    choices = Choices("[5 digits]").obj
    t.ask(choices,
              say="Please enter your 5 digit zip code.",
              attempts=3, bargein=True, name="zip", timeout=5)

    # we use the voice passed in the method call.
    choices = Choices("[5 digits]").obj
    t.ask(choices,
              say="Please enter your 5 digit zip code.",
              attempts=3, bargein=True, name="zip", timeout=5, voice="allison")


    json = t.RenderJson()
    print json
    return json
开发者ID:BSierakowski,项目名称:tropo-webapi-python,代码行数:27,代码来源:gh-12-test_voice.py

示例10: index

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
def index(request):
    t = Tropo()
    t.answer(headers={"P-Header":"value goes here","Remote-Party-ID":"\"John Doe\"<sip:[email protected]>;party=calling;id-type=subscriber;privacy=full;screen=yes"})
    t.say('This is your mother. Did you brush your teeth today?')
    json = t.RenderJson() 
    print json
    return json
开发者ID:tropo,项目名称:tropo-webapi-python,代码行数:9,代码来源:test_answer.py

示例11: tropo_view

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
def tropo_view(request):
    if request.method == "POST":
        data = json.loads(request.raw_post_data)
        session = data["session"]
        if "parameters" in session:
            params = session["parameters"]
            if ("_send_sms" in params) and ("numberToDial" in params) and ("msg" in params):
                numberToDial = params["numberToDial"]
                msg = params["msg"]
                t = Tropo()
                t.call(to = numberToDial, network = "SMS")
                t.say(msg)
                log("OUT", "TEXT", numberToDial, "TROPO", request.raw_post_data, msg)
                return HttpResponse(t.RenderJson())
        if "from" in session:
            caller_id = session["from"]["id"]
            channel = session["from"]["channel"]
            msg = None
            if "initialText" in session:
                msg = session["initialText"]
            log("IN", channel, caller_id, "TROPO", request.raw_post_data, msg)
            if channel == "VOICE":
                send_sms_tropo(caller_id, "Callback received.")
        t = Tropo()
        t.hangup()
        return HttpResponse(t.RenderJson())
    else:
        return HttpResponseBadRequest()
开发者ID:gcapalbo,项目名称:flashback_test,代码行数:30,代码来源:views.py

示例12: do_confirm_ok

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
 def do_confirm_ok(self, song_id):
     caller_id = models.votes.caller_id_if_valid(self.call_id())
     models.votes.vote_for_song(song_id, caller_id)
     t = Tropo()
     t.say("Great, your vote has been counted. Goodbye.")
     t.message("Thanks for voting!", channel="TEXT", to=caller_id)
     return t.RenderJson()
开发者ID:imclab,项目名称:tropo-voting-app,代码行数:9,代码来源:voting_webapi.py

示例13: sms_in

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
def sms_in(request):
    """
    Handles tropo messaging requests
    """
    if request.method == "POST":
        data = json.loads(request.body)
        session = data["session"]
        # Handle when Tropo posts to us to send an SMS
        if "parameters" in session:
            params = session["parameters"]
            if ("_send_sms" in params) and ("numberToDial" in params) and ("msg" in params):
                numberToDial = params["numberToDial"]
                msg = params["msg"]
                t = Tropo()
                t.call(to = numberToDial, network = "SMS")
                t.say(msg)
                return HttpResponse(t.RenderJson())
        # Handle incoming SMS
        phone_number = None
        text = None
        if "from" in session:
            phone_number = session["from"]["id"]
        if "initialText" in session:
            text = session["initialText"]
        if phone_number is not None and len(phone_number) > 1:
            if phone_number[0] == "+":
                phone_number = phone_number[1:]
        incoming_sms(phone_number, text, SQLTropoBackend.get_api_id())
        t = Tropo()
        t.hangup()
        return HttpResponse(t.RenderJson())
    else:
        return HttpResponseBadRequest("Bad Request")
开发者ID:philipkaare,项目名称:commcare-hq,代码行数:35,代码来源:views.py

示例14: license

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
def license(request):
    r = Result(request.body)
    t = Tropo()

    answer = r.getInterpretation()

    u = current[r._sessionId]
    current[r._sessionId]["last_name"] = answer

    db = MySQLdb.connect(host="localhost", user="globalhackv", passwd="globalhack", db="globalhackv")
    cur = db.cursor()

    cur.execute(
        "SELECT first_name, last_name FROM good_data_fixed WHERE date_of_birth = %s AND last_name LIKE %s AND status <> 'CLOSED' AND status <> 'DISMISS WITHOUT COSTS'",
        (u["birthday"], answer),
    )
    result = cur.fetchall()

    cur.close()
    db.close()

    t.say("Hello %s %s," % (result[0][0], result[0][1]))

    choices = Choices("[4 DIGITS]", mode="dtmf", attempts=3)
    t.ask(
        choices,
        timeout=15,
        name="last_drivers",
        say="As a final validation, please enter the last four digits of your driver's license I D",
    )

    t.on(event="continue", next="/results")

    return t.RenderJson()
开发者ID:ixchi,项目名称:GlobalHackV,代码行数:36,代码来源:phone.py

示例15: verify_no

# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import say [as 别名]
def verify_no(request):
	t = Tropo()
	t.say("Sorry, that wasn't on of the options.")
	json = t.RenderJson()
	print json
	return HttpResponse(json)
	
开发者ID:kwantopia,项目名称:shoppley-migrate,代码行数:8,代码来源:views.py


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