import speech_recognition as sr
##### Configuracoes #####
with open('My First Project-d463b9d77052.json') as credenciais_google:
credenciais_google = credenciais_google.read()
# obtain audio from the microphone
def monitora_audio():
microfone = sr.Recognizer()
with sr.Microphone() as source:
print("Aguardando o comando")
audio = microfone.listen(source)
try:
print(microfone.recognize_google_cloud(audio, credentials_json=credenciais_google, language='pt-BR'))
except sr.UnknownValueError:
print("Google Cloud Speech could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Cloud Speech service; {0}".format(e))
monitora_audio()