0
How can I get speech input and use it as strings in python?
2 Antworten
+ 1
You can't do this in Sololearn's code playground but you could locally.
I got the following code to work in Python 2.7.15.
I needed to install https://pypi.org/project/SpeechRecognition/
I also installed pyaudio. https://realpython.com/python-speech-recognition/#installing-pyaudio
The following program records and recognizes text spoken through your microphone. It is converted to string and printed.
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)
# try recognizing the speech in the recording
try:
transcription = r.recognize_google(audio)
print('response transcription = ' + transcription)
except sr.RequestError:
print("API unavailable")
except sr.UnknownValueError:
# speech was unintelligible
print("Unable to recognize speech")
0
Thanks bro