Help speech recognition

2

I'm using the speechrecognition library and would like to know how do I do if it finds a certain text in my speech it does a certain action.

For example, if it detects that the word I said was 'test' it writes in the output 'Congratulations you got'.

import speech_recognition as sr

r = sr.Recognizer()

with sr.Microphone()as s:
    r.adjust_for_ambient_noise(s)

    while True:
        audio=r.listen(s)

        print('Você:',r.recognize_google(audio,language='pt'))
    
asked by anonymous 20.05.2018 / 20:46

0 answers