Speech recognition error in python AI

Asked

Viewed 72 times

0

Hello I have an error that it displays the message but not what I said

main.py
Ouvindo....
Você disse {'alternative': [{'transcript': 'você disse', 'confidence': 0.88387161}, {'transcript': 'você diz'}, {'transcript': 'e você disse'}, {'transcript': 'se você diz'}, {'transcript': 'você diz isso'}], 'final': True}
main.py
Ouvindo....
Você disse []

python code:

import speech_recognition as sr


def reconhecer():
    rec = sr.Recognizer()
    with sr.Microphone() as s:
        rec.adjust_for_ambient_noise(s)

        while True:
            try:
                audio = rec.listen(s)
                entrada = rec.recognize_google(audio, language="pt-PT", show_all=True)
                return "Você disse {}".format(entrada)

            except sr.UnknownValueError:
                return "Nao estou te entendendo"
print("Ouvindo.....")
fala = reconhecer()
print(fala)
  • what I said on the microphone he puts only []

  • 1

    Yes, because what he returns is a dictionary of all the options he has identified and the level of trust. If you want to display only the text you will need to access this value in the dictionary.

  • then I change the show_all ? and I’m starting now in python

  • 1

    If you are starting in python the ideal is to start with the same simple. Learning the language and programming principles first and then applying them in a specific context. You’re trying to drive a formula one without ever having taken a car.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.