I want to make a Python program where microphone audio input is received.
I already tried pyaudio but I can't understand how it works.
There is this module called gTTS
that you can use instead.
The
get_audio
function will be able to detect a users voice, translate the audio to text and return it to us. It will even wait until the user is speaking to start translating/recording the audio
Here's a complete example on Getting user input
using the get_audio
function.
def get_audio():
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)
said = ""
try:
said = r.recognize_google(audio)
print(said)
except Exception as e:
print("Exception: " + str(e))
return said
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.