PyAudio in pycharm

2019-07-26 23:30发布

问题:

I have written a program for speech to text in which I use speech recognition by pycharm ask for PyAudio so I tried to do so . But PyAudio in pycharm is not getting installed

回答1:

I guess you need to configure a Python interpreter

https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html



回答2:

Sounddevice is easier for speech recognition because of it's simplicity. However if you really need pyaudio use

pip<python version> install pyaudio #in the terminal 

if that does not work then check what python you are using in pycharm by looking at the python console tab. In this case I am using python 3.6.

import sounddevice as sd
import soundfile as sf
import speechrecognition as sr
s = sr.Recognizer()
audio = sd.rec(int(time*44100),44100)
sd.wait()
sf.write("audio.wav",audio,time*44100)
audio = sr.AudioFile("audio.wav")
with audio as file:
    audio = s.record(file)
#wit.ai is a free speech recognition api from facebook and works almost as good as google.
text = s.recognize_wit(audio, key="*********")