Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectionResetError when translating with Google Speech #69

Closed
italomaia opened this issue Nov 30, 2015 · 6 comments
Closed

ConnectionResetError when translating with Google Speech #69

italomaia opened this issue Nov 30, 2015 · 6 comments

Comments

@italomaia
Copy link

I have my little good looking script right here:

import speech_recognition as sr
r = sr.Recognizer()
def translate(file_path):
    with sr.WavFile(file_path) as source:
        audio = r.record(source)

    return r.recognize_google(audio, key=key, language=language)

Which reads from a wav file and translates the audio with speech recognition. I'm getting a ConnectionResetError: [Errno 104] Connection reset by peer all the time. I made sure the audio
is wav 16k mono.

@italomaia
Copy link
Author

I have read somewhere google speech has a 60s limit, so, I changed my encoder to match that:

call(['ffmpeg',
          '-i', mp3_path,
          '-acodec', 'pcm_s16le',
          '-ac', '1',
          '-ar', '16000',
          '-t', '50',  # 50s
          wav_path])

File format seems correct. Still get error:

 if "alternative" not in actual_result: raise UnknownValueError()
speech_recognition.UnknownValueError

@Uberi
Copy link
Owner

Uberi commented Nov 30, 2015

Hi @italomaia,

Please upload the WAV file and the script that is causing the error.

Does the WAV file example work for you (see examples/wav_transcribe.py)? If not, then the issue may be your connection.

@italomaia
Copy link
Author

@italomaia
Copy link
Author

Here is the thing, sample-10s, which is 48khz mono wav, pt-BR language, with 10s duration, works: https://drive.google.com/file/d/0B9UaciTdg4eHOXRGZkY5Wk1DTGc/view?usp=sharing

Same song, same settings, 20s duration, does not: https://drive.google.com/file/d/0B9UaciTdg4eHbFlzdG15SHI2dnM/view?usp=sharing

What do you guys think?

@italomaia
Copy link
Author

wav_transcribe.py works with the 10s sample only.

@Uberi
Copy link
Owner

Uberi commented Dec 5, 2015

Hi @italomaia,

Your samples seem to contain music, which is confusing the speech recognizer. You may get better results by trimming those out.

It might be worth trying out the Wit.ai recognizer to see if it works a bit better - see the documentation for recognize_wit.

@Uberi Uberi closed this as completed Mar 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants