Python Forum
STT: recognition connection failed: [Errno 32] Broken pipe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
STT: recognition connection failed: [Errno 32] Broken pipe
#1
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
Could not request results from google Speech Recognition service; recognition connection failed: [Errno 32] Broken pipe

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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert Excel file into csv with Pipe symbol.. mg24 4 1,288 Oct-18-2022, 02:59 PM
Last Post: Larz60+
  Why is copying and pasting a block now broken? WagmoreBarkless 2 1,332 May-05-2022, 05:01 AM
Last Post: WagmoreBarkless
  Why is copying and pasting a block now broken? WagmoreBarkless 1 1,197 May-04-2022, 11:40 PM
Last Post: Larz60+
  Serial connection connection issue Joni_Engr 15 7,831 Aug-30-2021, 04:46 PM
Last Post: deanhystad
  BrokenPipeError: [Errno 32] Broken pipe throwaway34 6 8,939 May-06-2021, 05:39 AM
Last Post: throwaway34
  Duplex Named Pipe with Python Server and C# Clients raybowman 1 2,336 Dec-03-2020, 09:58 PM
Last Post: Gribouillis
  Python broken if moved to a different folder ecastrotns 3 2,371 Oct-26-2020, 10:53 PM
Last Post: ecastrotns
  [Errno 54] Connection reset by peer BlueBlue 0 3,558 Oct-14-2020, 09:34 PM
Last Post: BlueBlue
  2 or more processes on the write end of the same pipe Skaperen 4 3,790 Sep-27-2020, 06:41 PM
Last Post: Skaperen
  multiprocessing Pipe.poll very slow seandepagnier 0 2,315 Mar-09-2020, 03:10 AM
Last Post: seandepagnier

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020