Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #99 from englercj/master

Fix Multiple Grammars
  • Loading branch information...
commit ef2aefb668c1f0739069d19f039dbe18b54b7c23 2 parents f5a6421 + e05d420
@tamiel tamiel authored
Showing with 20 additions and 19 deletions.
  1. +20 −19 src/plivo/rest/freeswitch/elements.py
View
39 src/plivo/rest/freeswitch/elements.py
@@ -1814,21 +1814,9 @@ def execute(self, outbound_socket):
# set grammar tag name
grammar_tag = os.path.basename(grammar_file)
- if i != len(grammars) - 1:
- # define grammar
- speech_args = "grammar %s %s" % (grammar_full_path, grammar_tag)
- res = outbound_socket.execute("detect_speech", speech_args)
- if not res.is_success():
- outbound_socket.log.error("GetSpeech Failed - %s" \
- % str(res.get_response()))
- if gpath:
- try:
- os.remove(gpath)
- except:
- pass
- return
- # enable grammar
- speech_args = "grammaron %s" % (grammar_full_path)
+ if i == 0:
+ # init detection
+ speech_args = "%s %s %s" % (self.engine, grammar_full_path, grammar_tag)
res = outbound_socket.execute("detect_speech", speech_args)
if not res.is_success():
outbound_socket.log.error("GetSpeech Failed - %s" \
@@ -1839,9 +1827,11 @@ def execute(self, outbound_socket):
except:
pass
return
+ else:
+ grammar_loaded = True
else:
- # start detection
- speech_args = "%s %s %s" % (self.engine, grammar_full_path, grammar_tag)
+ # define grammar
+ speech_args = "grammar %s %s" % (grammar_full_path, grammar_tag)
res = outbound_socket.execute("detect_speech", speech_args)
if not res.is_success():
outbound_socket.log.error("GetSpeech Failed - %s" \
@@ -1852,10 +1842,21 @@ def execute(self, outbound_socket):
except:
pass
return
- else:
- grammar_loaded = True
+ # enable grammar
+ speech_args = "grammaron %s" % (grammar_tag)
+ res = outbound_socket.execute("detect_speech", speech_args)
+ if not res.is_success():
+ outbound_socket.log.error("GetSpeech Failed - %s" \
+ % str(res.get_response()))
+ if gpath:
+ try:
+ os.remove(gpath)
+ except:
+ pass
+ return
if grammar_loaded == True:
+ outbound_socket.execute("detect_speech", "resume")
for child_instance in self.children:
if isinstance(child_instance, Play):
sound_file = child_instance.sound_file_path
Please sign in to comment.
Something went wrong with that request. Please try again.