speech recognition api
Python hosting: Host, run, and code Python in the cloud!
Google has a great Speech Recognition API. This API converts spoken text (microphone) into written text (Python strings), briefly Speech to Text. You can simply speak in a microphone and Google API will translate this into written text. The API has excellent results for English language.
A speech recognition API offloads the logic, such that you can simply send a web request to the API, which then returns the text that was recognized. You can do this from Python code directly, but your script will need internet access behind the scenes.
Related course:
Installation
Google Speech API v2 is limited to 50 queries per day. Make sure you have a good microphone.
Are you are looking for text to speech instead?
This is the installation guide for Ubuntu Linux. But this will probably work on other platforms is well. You will need to install a few packages: PyAudio, PortAudio and SpeechRecognition. PyAudio 0.2.9 is required and you may need to compile that manually.
git clone http://people.csail.mit.edu/hubert/git/pyaudio.git |
Program
This program will record audio from your microphone, send it to the speech API and return a Python string.
The audio is recorded using the speech recognition module, the module will include on top of the program. Secondly we send the record speech to the Google speech recognition API which will then return the output.
r.recognize_google(audio) returns a string.
|
You may like: Personal Assistant Jarvis (Speech Recognition and Text to Speech) or Speech Engines
Leave a Reply:
Does this work on Mac?
Changing sudo apt-get to brew?
The module works on Mac too, but I'm not sure if the Google Speech Recognition API is still publicly available. The module provides access to several other speech engines such as CMU Sphinx, Wit.ai, api.ai and IBM Speech to Text.
To install on mac I think you can use pip:
but I don't have a mac so I'm not sure.
The official module site is SpeechRecognition.
How you set the Italian language ??
The language you can set depends on the recognition engine. This only works if the language is supported. The Sphinx engine supports English, French and Chinese.
To set a language use the parameter.
Recognition engines may change over time (free to commercial/API key) or not include every language. However, the principle of using the speech_recognition module remains the same.
The recognition engines are:
Then specify the language as a parameter, depending on the speech engine.
For Sphinx,
For Google one,
For ibm,
Running this code snippet gives me the below error:
Any suggestions on how I can proceed from here?
Try the same code on another computer or another recognition engine
Ok. Thank you very much
after cloning the project from GIT, cd into pyaudio then when I try sudo python setup.py install it throws an error
" src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
compilation terminated. "
A dependency called Portaudio is missing. This is an audio API, http://www.portaudio.com/
On Mac
On Linux: http://askubuntu.com/questions/736238/how-do-i-install-and-setup-the-environment-for-using-portaudio/
Can i use this in Windows? If yes plz show me the steps to do it?
Yes, with one of the other speech engines it should work. Install the required modules and run it using Python.
How to end listening @ line audio = r.listen(source) ??
Execution seems to be stuck at this line...
It should end automatically, try changing the speech engine.
Can you change the type of voice?
The speech API supports that, but I don't think it's in the speech_recognition module.
Hey when i run through the installation steps, i can't get past this line
sudo apt-get installl libportaudio-dev
I get the error:
Package libportaudio-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'libportaudio-dev' has no installation candidate
Any idea how i can resolve this?
Try download it from here: http://www.portaudio.com/download.html
Hello Sir, I am using google speech API with default API key since 15 days but currently it does't recognize my voice with it where my microphone works well which I test at google voice where it works without any error. I can't understand what problem behind it. Please help me.
Hope for positive response.
I'm not sure, does the site https://www.google.com/intl/en/chrome/demos/speech.html work for you?
sir , i have the same problem but this site https://www.google.com/intl... works for me by changing the default to usb mic in chrome setting.
so sir can you plz tell is there any way to change default to usb mic. i am using Raspberry PI3
The usb mic is needed on the raspberry PI. I don't have a raspberry pi, but it looks like
you can change it with:
that's in the line
To list the microphones use this program:
I have to do convert speech to text in offline on SAMSUNG ARTIK board. Please tell which package do i need to install and the steps to follow.
Many speech APIs only work online. The module SpeechRecognition only works offline with the engine CMU Sphinx. All the other speech engines supported dby the module SpeechRecognition need internet connectivity.
Hello, is there any solution for reducing the delay time? I have test the code and this does not work online, it takes a few seconds to give back the string. Thanks
There is no real time solution that I know of. Even on Android it takes a moment to listen
Not able to install any of the above packages on Windows 10
Got Python Version 2.7.13 and pip version 9.0.1
Everytime a get an error says : Could not find a version that satisfies the requirement libportaudio-dev(from version:)
No matching distribution found for libportaudio-dev
Help me out
On windows you need to compile PortAudio.
Also try: pip install pyaudio
Any documentation to publish this as webservice? Or can be consumed by hangout, skype or something?
Any leads?
This records the microphone locally (attached to the computer). If the client would run a Python program recording the microphone, you could forward the text to a server.