Uberi / speech_recognition

Speech recognition module for Python, supporting several engines and APIs, online and offline.
https://pypi.python.org/pypi/SpeechRecognition/
BSD 3-Clause "New" or "Revised" License
8.16k stars 2.39k forks source link

Speech Recognizer in py2exe is giving [winError2] error. #612

Open ayushbhardwaj10 opened 2 years ago

ayushbhardwaj10 commented 2 years ago

Steps to reproduce

  1. How do you make the issue happen? Does it happen every time you try it?

    • The issue is coming only when I convert my python code to an exe format using py2exe, otherwise it's working good as a python program. But my requirement is to make it work as an exe.
  2. If there are any files, like audio recordings, don't forget to include them.

    • I'm taking the audio input from microphone

Expected behaviour

It should convert my speech to text

Actual behaviour

Speech to text not happening, getting this following exception : [WinError 2] The system cannot find the file specified.

System information

My system is Lenovo E495, Windows 10 x64.

My Python version is 3.6.13.

My Pip version is 21.2.2 .

My SpeechRecognition library version is 3.8.1.

My PyAudio library version is 0.2.11

My microphones are: ['Microsoft Sound Mapper - Input', 'Microphone Array (Synaptics Aud', 'Microsoft Sound Mapper - Output', 'Speakers (Synaptics Audio)']

Here my Code for speech to text :

  def speech_to_text(self):
        print("speech to text started..")
        r = sr.Recognizer()
        log.debug("Before microphone() :")
        with sr.Microphone() as source:
            log.debug("Inside microphone() :")
            audio = r.listen(source)
            log.debug("Before Try() :")
            try:
                log.debug("Before google audio :")
                text = r.recognize_google(audio)
                log.debug("after google audio :")
                response = {"speech": text}
                log.debug("Response is :")
                log.debug(response)
                return response
            except Exception as e:
                log.debug("Sorry, Couldn't recognize the speech")
                log.debug(e)
                response = {"speech": ''}
                log.debug("Response is :")
                log.debug(response)
                return response

Here's my setup code to convert python program to exe using py2exe library

from distutils.core import setup
import py2exe
setup(
    console=[{"script":'app.py',
              "icon_resources": [(0, "images/xxx.ico")],
              "dest_base" : 'xxxApp'
              }
            ],
    options = {"py2exe":{
                      "packages": ['azure.cognitiveservices.speech','eventlet','dns','engineio.async_drivers'],
                       "includes" : ["encodings","encodings.latin_1"],
                       "skip_archive": True
                 }
              },
    data_files = [
                  ('images',['images/xxx.ico','images/logo.png','images/tray-logo.png'])
                 ]
)

command to convert python code to exe : python app_setup.py py2exe

`

MohamedSamer1 commented 5 months ago

[WinError 10054] An existing connection was forcibly closed by the remote host

i get this error