Uberi / Uberi/speech_recognition

Python voice recognize error

Open
#552 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9k
Forks
2.4k
Avg merge
12h 24m
Merged PRs (30d)
3

Description

Guys, I try to many ways to solve this problem
my code:

import speech_recognition as sr
import pyttsx3
import pywhatkit

listener = sr.Recognizer()
microphone = sr.Microphone()
r = sr.Recognizer()
my_mic = sr.Microphone(device_index=1)

engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id) # use whatever voice_id you'd like

def talk():
engine.say('Hello Iam vino how can I help you')
engine.runAndWait()

def take_command():

try:
    with microphone as source:
        print('listening....')
        voice = r.listen(source)
        command = listener.recognize_google(voice, language='en-US')
        command = command.lower()
        if 'alexa' in command:
            command = voice.replace('alexa', ' ')
            print(command)
        else:
            print('error')
except LookupError:
    #print('Could not understand the audio')
    pass
return command

def run_alexa():
command = take_command()
print(command)
if 'play' in command:
song = command.replace('play', '')
talk('playing ' + song)
pywhatkit.playonyt(song)

run_alexa()

============
error message

ommand = listener.recognize_google(voice, language='en-US')
AttributeError: 'Recognizer' object has no attribute 'recognize_google'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at take_command() in the reported code and reproduce the AttributeError at listener.recognize_google(voice, language='en-US'). Check the speech_recognition Recognizer API and the installed package used by this code; done means identifying why the method is unavailable and confirming a corrected example runs without that error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
audio-video-rtc
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.