Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from chriamue/tensorflow
Tensorflow
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python3 | ||
import time | ||
import speech_recognition as sr | ||
from tensorflow.contrib.framework.python.ops import audio_ops as contrib_audio # noqa | ||
|
||
# obtain audio from the microphone | ||
r = sr.Recognizer() | ||
m = sr.Microphone() | ||
|
||
with m as source: | ||
r.adjust_for_ambient_noise(source) | ||
|
||
|
||
def callback(recognizer, audio): | ||
try: | ||
# You can download the data here: http://download.tensorflow.org/models/speech_commands_v0.01.zip | ||
spoken = recognizer.recognize_tensorflow(audio, tensor_graph='speech_recognition/tensorflow-data/conv_actions_frozen.pb', tensor_label='speech_recognition/tensorflow-data/conv_actions_labels.txt') | ||
print(spoken) | ||
except sr.UnknownValueError: | ||
print("Tensorflow could not understand audio") | ||
except sr.RequestError as e: | ||
print("Could not request results from Tensorflow service; {0}".format(e)) | ||
|
||
|
||
stop_listening = r.listen_in_background(m, callback, phrase_time_limit=0.6) | ||
time.sleep(100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters