Cómo usar el reconocimiento de voz en python

Ejemplos de código

8
0

python text to speech

The best library because you dont have to save the
text file or open the file to start the speech

pip install pyttsx3

import pyttsx3
engine = pyttsx3.init()
engine.say("Hello world")
engine.runAndWait()
5
0

reconocimiento de voz python

import speech_recognition as sr

def take_command():
    r = sr.Recognizer()
    with sr.Microphone() as source:
        print('Listening...')
        r.pause_threshold = 1
        r.energy_threshold = 50
        audio = r.listen(source)

    try:
        print('Recognizing...')
        qry = r.recognize_google(audio, language='en-in')
        print(f"user said: {qry}\n")
        
#     if any error occurs this line will run
    except Exeption as e:
    # if you don't want to print the error comment the bottom line
        print(e)
        print('Say that again please\n')
        return 'None'

    return qry
  
if __name__ == '__main__':
	while True:
  		qry = takecommand().lower()
  
# now you can use the takecommand function where you want to recognize speech
# And please experiment with the above code 
# like what pause_threshold and energy_threshold do 
/\/\/\/\/\/\/\/\/\/\/\---  *HAPPYCODING*  ---/\/\/\/\/\/\/\/\/\/\/\
0
0

cómo arreglar el reconocimiento de voz en python

import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:                # use the default microphone as the audio source
    audio = r.listen(source)                   # listen for the first phrase and extract it into audio data

try:
    print("You said " + r.recognize(audio))    # recognize speech using Google Speech Recognition
except LookupError:                           # speech is unintelligible
    print("Could not understand audio")
   

En otros idiomas

Esta página está en otros idiomas

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................