Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

erro ao executar função monitora_audio()

FUNÇÃO ABAIXO

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()

MENSAGEM DE ERRO

C:\Users\raine\PycharmProjects\FRIDAY\venv\Scripts\python.exe C:\Users\raine\PycharmProjects\FRIDAY\friday.py Aguardando o comando! Traceback (most recent call last): File "C:\Users\raine\PycharmProjects\FRIDAY\friday.py", line 22, in monitora_audio() File "C:\Users\raine\PycharmProjects\FRIDAY\friday.py", line 15, in monitora_audio print(microfone.recognize_google_cloud(audio, credentials_json=credenciais_google, language='pt-BR')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raine\PycharmProjects\FRIDAY\venv\Lib\site-packages\speech_recognition_init__.py", line 963, in recognizegoogle_cloud client = speech.SpeechClient.from_service_account_json(credentials_json) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raine\PycharmProjects\FRIDAY\venv\Lib\site-packages\google\cloud\speech_v1\services\speech\client.py", line 160, in from_service_account_file credentials = service_account.Credentials.from_service_account_file(filename) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raine\PycharmProjects\FRIDAY\venv\Lib\site-packages\google\oauth2\service_account.py", line 241, in from_service_account_file info, signer = serviceaccount_info.from_filename( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\raine\PycharmProjects\FRIDAY\venv\Lib\site-packages\google\auth_service_account_info.py", line 79, in from_filename with io.open(filename, "r", encoding="utf-8") as json_file: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [Errno 22] Invalid argument: '{\n "type": "service_account",\n "project_id": "friday-python-assistente",\n "private_key_id": "9cccedf4ed8046903a6a3cb888cfd3dd76481744",\n "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmAeg+YI02BUs7\n+fWLaPGVWn/vqwezOA6EpX4xvy9blCBDdd9r3QF5gzaNkYw8zkzihQExn/fhHJk+\nKxSy+7TBVP8GX/J2uKAa8n3uPzuuU/zqINYyhKrKKyraWghEBnJ1gpaGQ4GZts7g\n1y4FsuJqr173ZTB8/F4TZlS6d391wmCcgVXYqNhCLoIz0BA7K99PzracOZUIJfsa\npzHkgu4o7I17ed4KB+addUqv2oHs122/VHhPETegTekL+1hNvpYuwiT/CBZa8qg2\n8cXjTQvi0rckL+mZUc1TSyJGv49JTYKJVHyu+L+XZ7dAs0tLABTMfdALbggGvMkV\nSBwTUu9VAgMBAAECggEAOVliUp5HWli013jwR2OPRfH4TaNPqy3b8h47/NKX+TKw\nfK2tbBVzC3f1ci3MfTsl24FoWqzxVN7s38nBQl3rYXjMC3c9C5+XjAem0pYct4pD\nTtzeMqCbYfFMwhclUN7LTuY4uxR6ItDBInKj7wsP5hxEmgHmoN8MXvZUogBjU5ou\nbIqsom/hsyLv1Olm8psPDpV2Akxl2nHqtKXtLOHzKB13bIYWmBXeew+gNK3hPe39\nrZNnnSgE02YPMtwoIoGozMALkx3N6l137pU8/eJ2cjbQB7xfYOqaSo2dyvFih/iL\n2mU++n65US4qUzw2T505OrviZ28dqM3JY7pAtWCbxwKBgQDjGXJQtvUqRtbhtNJK\n0zfc/v1Fq0bEEGMkjJILnnm7g0SqXFPbLLTNOlxWB5ObQpMXOrtcKIw2KieF5nTm\nyxIUlaBF1JYAfb3HN+jq5g5JL+uefuXBxX6lCD02SGxblMvL/+vto2bL+ySlbwKs\nGR6ESWt2pjOKTrPNg1vaEa/hIwKBgQC7Ii1/HLWmsyT7g8zDA7cLapZDmLVZSfG3\nR1UIB3Ah2XyKbDTrGb6xGhMXBDElnUFitNJ94K3naSXjgDdJoNIzbVSAZ3ut3sBV\nID3oZ1/xf0nIUahDjKKVyM7hZeE1gp5bKJQPEtUrUPZLOgsbYisBn67lOkRD3Gqh\nFY8x5GeBJwKBgD7XcMmjBw5u0dFdLv/jmMa/jKg1r/xbKIQZneQ3MypPNbYKnG2+\n3j0YFCr+J7tD3d4Es4nZ8oqeeZdU4S5oLRWjHdmU7Pkv0k8JSpuNk5BvAT03ki5f\njx7tu7qEqe9hqk9F/ywgFjcFxOs+X7ftr4Mdqe4IKaTxCFIrMkSStl+PAoGBAJW9\nRnyVI4GtjaU4lKtjmJ+o/W4/jrVQ5vsKOC9BjGd5mR9GcJ3DLwSV4bqkHxODHuP1\n3wzcsSsfxzKg0Ry4dBq0nE5W/+9j87DqKL+DoJEkkoyZUrQin6KNWYWguTHRQBef\ng8IABtUvZrVRT7vstI8LEK7aDe/jOuuEzd1Vb8E3AoGAfQU66WnJmXl536aZtNKs\nyDTN31tAUg0HwIymSOa1CwlKVFBZVZQuVhXeyDG6QVxDBwfbnCmiJ2Jv5JEP4kzL\n8GWRgORX8NctC0QQ4LfLTi+XgdbPyQj01VRfjBf7nXFOpMp5KXHxRfwvBjNSgHG5\nhL4r8muqWhznJz9l1+hk4K8=\n-----END PRIVATE KEY-----\n",\n "client_email": "friday@friday-python-assistente.iam.gserviceaccount.com",\n "client_id": "110766193085766740365",\n "auth_uri": "https://accounts.google.com/o/oauth2/auth",\n "token_uri": "https://oauth2.googleapis.com/token",\n "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",\n "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/friday%40friday-python-assistente.iam.gserviceaccount.com"\n}\n'

1 resposta
solução!

Use o botão </> da caixa de mensagem para colocar o código.