本文整理汇总了Python中tropo.Tropo.ask方法的典型用法代码示例。如果您正苦于以下问题:Python Tropo.ask方法的具体用法?Python Tropo.ask怎么用?Python Tropo.ask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tropo.Tropo
的用法示例。
在下文中一共展示了Tropo.ask方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [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()
示例2: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [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
示例3: license
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [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()
示例4: speak_webpage
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [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()
示例5: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [as 别名]
def index(request):
t = Tropo()
t.ask(choices = "yes(yes,y,1), no(no,n,2)", timeout=60, name="reminder", say = "Hey, did you remember to take your pills?")
t.on(event = "continue", next ="/continue")
t.on(event = "incomplete", next ="/incomplete")
json = t.RenderJson()
print(json)
return json
示例6: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [as 别名]
def index(request):
t = Tropo()
t.call(to = "[email protected]", _from = "[email protected]", channel = "TEXT", network = "JABBER")
t.ask(choices = "yes(yes,y,1), no(no,n,2)", timeout=60, name="reminder", say = "Hey, did you remember to take your pills?")
t.on(event = "continue", next ="verify_yes")
t.on(event = "incomplete", next ="verify_no")
json = t.RenderJson()
print json
return HttpResponse(json)
示例7: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [as 别名]
def index(request):
t = Tropo()
t.on("continue", next="/continue.json", post = 'http://192.168.26.88:8080/FileUpload/receiveJson', say = "this is say in on function")
t.on("error", next = "/error.json")
t.on("hangup", next = "/hangup.json")
t.on("incomplete", next = "/incomplete.json")
t.ask(say = "Welcome to Tropo. What's your birth year?", name = "year", require = "true", choices = "[4 DIGITS]")
json = t.RenderJsonSDK()
print json
return json
示例8: do_listen
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [as 别名]
def do_listen(self):
prompt = """
If you know the five digit pitch eye dee
you want to listen to, please enter it now.
If you want to hear a random pitch,
press zero or say random"""
t = Tropo()
choices = Choices("0, random, [5 DIGITS]")
t.ask(choices, say=prompt)
t.on(event="continue", next="/listen")
return t.RenderJson()
示例9: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [as 别名]
def index(request):
t = Tropo()
t.ask(choices = "yes(yes,y,1), no(no,n,2)", timeout = 15, name = "directory", minConfidence = 1, attempts = 3, say = "Are you trying to reach the sales department??")
t.on(event = "continue", next ="/continue")
json = t.RenderJson()
print(json)
return json
示例10: do_menu
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [as 别名]
def do_menu(self):
t = Tropo()
prompt = """
You will shortly be prompted to enter the two digit code for the
company you want to vote for. If you already know the code, you can
enter it at any time using your phone's keypad.
"""
for candidate in models.get_candidates():
prompt += "For %s, enter %s. " % (candidate['name'], candidate['vote_code'])
t.ask(Choices("[2 DIGITS]", mode="dtmf"), say=prompt)
t.on(event="continue", next=self.response_url())
return t.RenderJson()
示例11: do_response
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [as 别名]
def do_response(self):
song_id = self.get_answer()
song_title = models.songs.song_title(song_id)
if not song_id:
return self.do_bad_choice()
else:
t = Tropo()
prompt = "You chose %s, is that correct? " % song_title
choices = self.confirm_choices()
t.ask(choices, say=prompt + self.confirm_prompt())
t.on(event="continue", next=self.confirm_url(song_id))
return t.RenderJson()
示例12: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [as 别名]
def index(request):
t = Tropo()
choices = Choices("[4-5 DIGITS]", mode="dtmf", terminator = "#")
t.ask(choices, timeout=15, name="digit", say = "What's your four or five digit pin? Press pound when finished.")
t.on(event = "continue", next ="/continue")
json = t.RenderJson()
print json
return json
示例13: do_response
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [as 别名]
def do_response(self):
answer = self.get_answer()
candidate = models.find_candidate_by_code(answer)
if not candidate:
return self.do_bad_choice()
else:
t = Tropo()
prompt = "You chose %s, is that correct? " % candidate['name']
choices = self.confirm_choices()
t.ask(choices, say=prompt + self.confirm_prompt())
t.on(event="continue", next=self.confirm_url(candidate['id']))
return t.RenderJson()
示例14: birthday_day
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [as 别名]
def birthday_day(request):
r = Result(request.body)
t = Tropo()
answer = r.getInterpretation()
current[r._sessionId]["birthday"]["month"] = answer
choices = Choices("[1-2 DIGITS]", mode="dtmf")
t.ask(choices, timeout=15, name="birthday_day", say="Please enter your date of birth", attempts=3)
t.on(event="continue", next="/name")
return t.RenderJson()
示例15: do_menu
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import ask [as 别名]
def do_menu(self):
t = Tropo()
t.say("hello, thank you for helping us choose the music")
prompts = []
choices = []
for title, keyword, number, votes_cache in models.songs.songs_array():
choices.append("%s(%s,%s)" % (number, keyword, number))
prompts.append("For %(title)s, say %(keyword)s or press %(number)s." % locals())
prompt = " ".join(prompts)
t.ask(Choices(",".join(choices)), say=prompt)
t.on(event="continue", next=self.response_url())
return t.RenderJson()