Merge pull request 'main' (#25) from React-Group/interstellar_ai:main into main

Reviewed-on: https://interstellardevelopment.org/code/code/YasinOnm08/interstellar_ai/pulls/25
This commit is contained in:
YasinOnm08 2024-09-26 09:53:19 +02:00
commit 12aae026b2

View file

@ -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