1

I am using pyttsx3 and speech_recognition modules and sometimes I receive this error: OSError [Errno -9988] Stream closed. Here is a little bit same question, but without answer and on Raspberry Pi.
My OS - Windows 10, Python version - 3.8.5

Minimal reproducible example -

import speech_recognition as sr
import pyttsx3

engine = pyttsx3.init()

while True:
    r = sr.Recognizer()
    print("Say something")
    try:
        with sr.Microphone() as source:
        audio = r.listen(source, phrase_time_limit = 10)
        said = ''
        try:
            said = r.recognize_google(audio, language="en-EN")
        except sr.UnknownValueError:
            print("Unrecognised speech")
        if said == 'hi':
            engine.say("Hello there!")
            engine.runAndWait()
    except OSError as ose:
        print(ose)

The full output it produces - I excepted this error and my output is OSError [Errno -9988] Stream closed

So my question is - How to resolve it???, and why this error appears?

  • ...and your question is? Please take the [tour] and read [ask]. Also, provide a [mcve] so people know what is required to trigger the fault and the full output it produces. BTW: Ask yourself if you don't want to report a bug instead, for which you're using the wrong forum though. – Ulrich Eckhardt Dec 22 '20 at 06:58
  • Yeah, sure) I miswrote) –  Dec 22 '20 at 07:47

0 Answers0