提交 1d347c8a authored 作者: Traun Leyden's avatar Traun Leyden

abort upon receiving an empty result in freeswitch event

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5665 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 1a091c1a
...@@ -83,6 +83,7 @@ class SpeechObtainer: ...@@ -83,6 +83,7 @@ class SpeechObtainer:
self.max_tries=max_tries self.max_tries=max_tries
self.detected_phrases = [] self.detected_phrases = []
self.failed = False
def setGrammar(self, grammar): def setGrammar(self, grammar):
""" """
...@@ -124,7 +125,8 @@ class SpeechObtainer: ...@@ -124,7 +125,8 @@ class SpeechObtainer:
console_log("debug", "starting run() while loop\n") console_log("debug", "starting run() while loop\n")
while (session.ready() and while (session.ready() and
num_tries < self.max_tries and num_tries < self.max_tries and
len(self.detected_phrases) < self.required_phrases): len(self.detected_phrases) < self.required_phrases and
not self.failed):
console_log("debug", "top of run() while loop\n") console_log("debug", "top of run() while loop\n")
session.collectDigits(self.wait_time) session.collectDigits(self.wait_time)
num_tries += 1 num_tries += 1
...@@ -172,6 +174,12 @@ class SpeechObtainer: ...@@ -172,6 +174,12 @@ class SpeechObtainer:
# unicode strings. # unicode strings.
# TODO: check the score # TODO: check the score
body = event['body'] body = event['body']
if not body or len(body) == 0 or body == "(null)":
# freeswitch returned a completely empty result
self.failed = True
# do we want to return stop? what should we return?
return "stop"
dom = minidom.parseString(body) dom = minidom.parseString(body)
phrase = dom.getElementsByTagName(self.grammar.obj_path)[0] phrase = dom.getElementsByTagName(self.grammar.obj_path)[0]
phrase_text = self.getText(phrase) phrase_text = self.getText(phrase)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论