forked from React-Group/interstellar_ai
Compare commits
No commits in common. "12aae026b24b316ce81d4b4ca893ae916edad7c0" and "ea3fd09ea2107c2636c3f1f87d685c8586ab5a84" have entirely different histories.
12aae026b2
...
ea3fd09ea2
1 changed files with 4 additions and 5 deletions
|
@ -4,18 +4,17 @@ import speech_recognition as sr
|
||||||
class VoiceRecognition:
|
class VoiceRecognition:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def basic_recognition(audio, option):
|
def basic_recognition(audio, option):
|
||||||
print(type(audio))
|
|
||||||
print("preparing")
|
print("preparing")
|
||||||
r = sr.Recognizer()
|
r = sr.Recognizer()
|
||||||
if option == "online":
|
if option == "online":
|
||||||
with sr.AudioFile(audio) as source:
|
print("online")
|
||||||
print("online")
|
with audio as source:
|
||||||
text = r.recognize_google_cloud(source)
|
text = r.recognize_google_cloud(source)
|
||||||
print("recognized as: " + text)
|
print("recognized as: " + text)
|
||||||
return text
|
return text
|
||||||
elif option == "offline":
|
elif option == "offline":
|
||||||
with sr.AudioFile(audio) as source:
|
print("offline")
|
||||||
print("offline")
|
with audio as source:
|
||||||
text = r.recognize_sphinx(source)
|
text = r.recognize_sphinx(source)
|
||||||
print("recognized as: " + text)
|
print("recognized as: " + text)
|
||||||
return text
|
return text
|
||||||
|
|
Loading…
Reference in a new issue