Skip to content

Commit

Permalink
Merge pull request #321 from jhoelzl/patch-7
Browse files Browse the repository at this point in the history
Removed duplicate code
  • Loading branch information
Uberi authored Apr 3, 2019
2 parents f9fa758 + 768e9bd commit 350397d
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions speech_recognition/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,9 +816,6 @@ def recognize_sphinx(self, audio_data, language="en-US", keyword_entries=None, g
# perform the speech recognition with the keywords file (this is inside the context manager so the file isn;t deleted until we're done)
decoder.set_kws("keywords", f.name)
decoder.set_search("keywords")
decoder.start_utt() # begin utterance processing
decoder.process_raw(raw_data, False, True) # process audio data with recognition enabled (no_search = False), as a full utterance (full_utt = True)
decoder.end_utt() # stop utterance processing
elif grammar is not None: # a path to a FSG or JSGF grammar
if not os.path.exists(grammar):
raise ValueError("Grammar '{0}' does not exist.".format(grammar))
Expand All @@ -834,13 +831,10 @@ def recognize_sphinx(self, audio_data, language="en-US", keyword_entries=None, g
fsg = FsgModel(fsg_path, decoder.get_logmath(), 7.5)
decoder.set_fsg(grammar_name, fsg)
decoder.set_search(grammar_name)
decoder.start_utt()
decoder.process_raw(raw_data, False, True) # process audio data with recognition enabled (no_search = False), as a full utterance (full_utt = True)
decoder.end_utt() # stop utterance processing
else: # no keywords, perform freeform recognition
decoder.start_utt() # begin utterance processing
decoder.process_raw(raw_data, False, True) # process audio data with recognition enabled (no_search = False), as a full utterance (full_utt = True)
decoder.end_utt() # stop utterance processing

decoder.start_utt() # begin utterance processing
decoder.process_raw(raw_data, False, True) # process audio data with recognition enabled (no_search = False), as a full utterance (full_utt = True)
decoder.end_utt() # stop utterance processing

if show_all: return decoder

Expand Down

0 comments on commit 350397d

Please sign in to comment.