-1

The following program generates the following error:

import os
#import time
import speech_recognition
from subprocess import call
from platform import python_version
home = os.path.expanduser("~")
from gtts import gTTS
from bs4 import BeautifulSoup
import pyaudio
import PyPDF2
print('Speech Recognition version ' + speech_recognition.__version__)

print('Attempting to read Preamble')
wav = "C:\\Users\\Owner\\PycharmProjects\\Government\\Governing_documents\\Preamble.wav"

recognizer = speech_recognition.Recognizer()
preamble = speech_recognition.AudioFile(wav)
with preamble as source:
    audio = recognizer.record(source)
type(audio)
recognizer.recognize_google(audio)

ERROR MESSAGES FROM PYCHARM:

C:\Users\Owner\PycharmProjects\Speech\venv\Scripts\python.exe C:\Users\Owner\PycharmProjects\Speech\Wav_to_Text.py 
Traceback (most recent call last):
  File "C:\Users\Owner\PycharmProjects\Speech\Wav_to_Text.py", line 3, in <module>
    import speech_recognition
ModuleNotFoundError: No module named 'speech_recognition'

CMD PROMPT:

C:\Users\Owner\PycharmProjects\Speech>python Wav_to_Text.py
Traceback (most recent call last):
  File "C:\Users\Owner\PycharmProjects\Speech\Wav_to_Text.py", line 3, in <module>
    import speech_recognition
ModuleNotFoundError: No module named 'speech_recognition'

I tried modifying the environment variables to ensure that the libraries were visible. I checked where the packages were installed and that matched the PATH variable. They still give me an error in PyCharm and cmd

Compo
  • 36,585
  • 5
  • 27
  • 39
Jim
  • 1
  • 1
  • Did you check out : https://pypi.org/project/SpeechRecognition/ it has a list of requirments and install instructions – JonSG Jan 20 '23 at 17:05
  • Welcome to Stack Overflow. Exactly what steps did you take in order to install the `speech_recognition` package? It looks like you are using a virtual environment to run the program - is that correct? Did you make sure that the virtual environment was activated when installing the package? "I checked where the packages were installed and that matched the PATH variable." The system `PATH` environment variable has **nothing to do with** where a running Python process will look for packages. – Karl Knechtel Jan 20 '23 at 17:37
  • Did you set up the project interpreter in python, and install the modules to that specific virtual environment? – Random Davis Jan 20 '23 at 17:39
  • Please read the Python documentation pages [Command line and environment](https://docs.python.org/3/using/cmdline.html) with information about the environment variable __PYTHONPATH__ and [Using Python on Windows](https://docs.python.org/3/using/windows.html) and [Modules](https://docs.python.org/3/tutorial/modules.html) to get knowledge how Python finds modules (libraries). Please take a look on [What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?](https://stackoverflow.com/a/41461002/3074564) for getting knowledge about `PATH`. – Mofi Jan 20 '23 at 18:30

2 Answers2

0
 pip install pocketsphinx PyAudio google-api-python-client vosk whisper

Run this command in the terminal and inform us what happened

this will install all the requierments

Ali Redha
  • 316
  • 2
  • 14
0

Just needed to adjust the project files in pycharm. I also had a bad reference to 3.9 when it should have been 3.11. Everything is now working.

Jim
  • 1
  • 1