0

I am making this speech recognition thing in python and here I want it to recognize some words like

Dbot which it understands as deepak,deepa,boss,teddy bear

hi which it understands as hai

hey which it sometimes understands as hay

Now I recently got familiar with the term keyword entries but I don't know how to use it but if you know then that might be the solution.

So I just want it to understand words like Dbot,hi and so on.

If I need to change the module then I'm ready to.

And I hope the problem is now self explanatory and I would be thankful if someone could help :)

Note:I tried this (How do i make speech recognition understand spesific words i choose ? Python) but didn't it help so please don't mark this as duplicate

Here is the code BTW:

import speech_recognition as sr

def voicecommand(error):
    r = sr.Recognizer()
    with sr.Microphone() as source:
        r.adjust_for_ambient_noise(source, duration=1)
        print("listening...")
        audio = r.listen(source)
        print("recognizing...")
    try:
        global output
        output = r.recognize_google(audio)
        output = output.lower()
    except Exception as e:
        if error == True:
            print("Sorry, can you repeat that?")
        voicecommand(True)
    return str(output)
voicecommand(True)

while True:
    a = voicecommand(True)
    print(a)
    if "dbot" in a:
        print("it works!")

0 Answers0