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