15 lines
407 B
Python
15 lines
407 B
Python
import speech_recognition as sr
|
|
|
|
|
|
class VoiceRecognition:
|
|
@staticmethod
|
|
def basic_recognition(audio, option):
|
|
r = sr.Recognizer()
|
|
if option == "online":
|
|
with audio as source:
|
|
return r.recognize_google_cloud(source)
|
|
elif option == "offline":
|
|
with audio as source:
|
|
return r.recognize_sphinx(source)
|
|
|
|
return False
|