forked from React-Group/interstellar_ai
backend audio fix woo
This commit is contained in:
parent
492443e139
commit
f12014833c
1 changed files with 5 additions and 4 deletions
|
@ -4,17 +4,18 @@ 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":
|
||||||
print("online")
|
with sr.AudioFile(audio) as source:
|
||||||
with audio as source:
|
print("online")
|
||||||
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":
|
||||||
print("offline")
|
with sr.AudioFile(audio) as source:
|
||||||
with audio as source:
|
print("offline")
|
||||||
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