![]() |
STT: recognition connection failed: [Errno 32] Broken pipe - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: STT: recognition connection failed: [Errno 32] Broken pipe (/thread-28430.html) |
STT: recognition connection failed: [Errno 32] Broken pipe - GrahamBerends - Jul-18-2020 Hi All. I keep getting these broken pipe messages. Some STT conversions work, others don't. So the code basically works. I imagine that there's a stretch of speech which the speech_recognition doesn't like, so it dumps the whole process with a Broken Pipe. Can you please help me find some ideas for a work-around: - How can I identify these parts which the speech_recognition doesn't like? And, say, print "xxxx" wherever there is a section which cannot be converted to text? Or, - Can you explain how I can maybe "clean" the speech-input-file? If you need my input audio_file, I will gladly post it. Look forward to your replies. Graham This command works, generating good output: Quote:rm transcript.txt; python ${stt}/WAV_convert_2_text.py ${stt}/Joanne_davilla_35seconds.wav >> transcript.txt This command fails: Quote:rm transcript.txt; python ${stt}/WAV_convert_2_text.py transcript.wav >> transcript.txt This is the error output: Quote:transcript.wav This is the code: import speech_recognition as sr import sys from pydub import AudioSegment # read WAV filename from arguments audio_file = sys.argv[1] def readAudioFile(audio_file): r = sr.Recognizer() file = sr.AudioFile(audio_file) with file as source: audio = r.record(source) type(audio) try: message = r.recognize_google(audio) print(message) print("Data extracted from phone conversation:\n" + message) 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)) except IOError as e: print("IOError; {0}".format(e)) # parser = argparse.ArgumentParser() # parser.add_argument("--file", "-f", type=str, required=True) # args = parser.parse_args() # audio_file = args.file print(audio_file) readAudioFile(audio_file) |