#๐Ÿ”’ did they remove recognize_google from speech_recognition?

50 messages ยท Page 1 of 1 (latest)

twin sirenBOT
#

@smoky solar

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

whole sequoia
#

it's still there as far as i can see.

smoky solar
#

i cant use it

#

it just wont work

#

and it doesnt show up as a useable function

whole sequoia
#

you need to give more details

#

how does it "just won't work"

smoky solar
#

Ok it just doesnt recognise it

#

Let me take a screenshot

#

Ignore the audio bit

#

i just typed it up quickly so audio doesnt exist

#

but see how its not recognised

#

whereas vosk is

#

@whole sequoia

whole sequoia
#

the editor might not recognize it, but it works.

#
import speech_recognition as sr

# obtain path to "english.wav" in the same folder as this script
from os import path

AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "english.wav")

r = sr.Recognizer()
with sr.AudioFile(AUDIO_FILE) as source:
    audio = r.record(source)  # read the entire audio file

# recognize speech using Google Speech Recognition
try:
    print("Google Speech Recognition thinks you said " + r.recognize_google(audio))
except sr.UnknownValueError:
    print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
    print("Could not request results from Google Speech Recognition service; {0}".format(e))
smoky solar
#

@whole sequoia how would i put that into a text file tho

#

instead of the audio

#

so using PyAudio

whole sequoia
#

you would not use a text file.

#

it doesn't work that way

#

you just need an audio file

#

and the example for that is above.

smoky solar
#

Doesnt work

whole sequoia
#

did you read the message?

smoky solar
#

?

#

That i need an audio file

#

yes

whole sequoia
#

right so?

smoky solar
#

so it still didnt work

whole sequoia
#

because you're not passing it an audio file.

smoky solar
#

i am

#

Thats an audio file

whole sequoia
#

does it play?

smoky solar
#

Theres no audio in it

whole sequoia
#

so it's not an audio file.

#

and the error is correct.

smoky solar
#

I fixed it

#

The script doesnt record what im saying though

#

Surley something like this would work

#

import speech_recognition as sr
import pyttsx3

recogniser = sr.Recognizer()

while True:

try:

    with sr.Microphone() as mic:
        recogniser.adjust_for_ambient_noise(mic, duration=0.2)
        audio = recogniser.listen(mic)
        text = recogniser.recognize_google(audio)
        text = text.lower()

        print(f"recognised {text}")
except sr.UnknownValueError():
    recogniser = sr.Recognizer()
    continue
twin sirenBOT
#

Hey @smoky solar!

It looks like you're trying to paste code into this channel.

Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
smoky solar
#
import speech_recognition as sr
import pyttsx3

recogniser = sr.Recognizer()

while True:

    try:

        with sr.Microphone() as mic:
            recogniser.adjust_for_ambient_noise(mic, duration=0.2)
            audio = recogniser.listen(mic)
            text = recogniser.recognize_google(audio)
            text = text.lower()

            print(f"recognised {text}")
    except sr.UnknownValueError():
        recogniser = sr.Recognizer()
        continue

#

i got it working

twin sirenBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.