Skip to content

Commit

Permalink
abort upon receiving an empty result in freeswitch event
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5665 d0543943-73ff-0310-b7d9-9358b9ac24b2
  • Loading branch information
keynuker committed Aug 25, 2007
1 parent 1a091c1 commit 1d347c8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/py_modules/speechtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def __init__(self, speech_detect, required_phrases, wait_time, max_tries):
self.max_tries=max_tries

self.detected_phrases = []
self.failed = False

def setGrammar(self, grammar):
"""
Expand Down Expand Up @@ -124,7 +125,8 @@ def dtmf_handler(input, itype, funcargs):
console_log("debug", "starting run() while loop\n")
while (session.ready() 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")
session.collectDigits(self.wait_time)
num_tries += 1
Expand Down Expand Up @@ -172,6 +174,12 @@ def handle_event(self, event, funcargs):
# unicode strings.
# TODO: check the score
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)
phrase = dom.getElementsByTagName(self.grammar.obj_path)[0]
phrase_text = self.getText(phrase)
Expand Down

0 comments on commit 1d347c8

Please sign in to comment.