Need help with libsprec?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

130 Stars 37 Forks Other 18 Commits 4 Opened issues


C library for speech recognition using the Google Speech API

Services available


Need anything else?

Contributors list

# 151,680
Visual ...
17 commits


Speech recognizer library in C using the Google Speech v2.0 API.

Requires libcurl >= 7.25.0, libflac and libogg.

For iOS, you have to grab these libraries either from Cydia or my web page. Libflac, libogg and libcurl should be already in your favourite Unix distro's package management system (OS X and Homebrew are no exception!).

For iOS, you can download the Debian packages from here:

Tested on iOS 4.2.1, Ubuntu 11.10 and OS X 10.9.5.

If immediate recording of FLAC audio is possible on a platform, then it should be done using 16000 samples/second, 2 channels, 16 bit/sample (signed little endian); and only the functions in

have to be used, e. g.:
  • sprec_send_audio_data()
    takes a pointer to the contents of a FLAC file and sends it to the Google Speech API along with the appropriate headers and other parameters. Returns the server's response.

If immediate FLAC recording is not available, then the audio should be recorded in WAV (uncompressed interleaved PCM), 16 bits/sample, signed, little endian, 2 channels and 16000 Hz sample rate). Then the resulting WAV file should be converted to a FLAC one using

. Then one can proceed as described above. You can use the
function for recording in the appropriate format.

The simple API

To simplify this task, two convenience functions,

are also available (the latter needs POSIX threads).


for further API usage information.

The usage of the example program is:


A word about API keys

The Google Speech v2.0 API requires an API key, and rate-limits the application to 50 keys per day. In order to obtain an API key, follow the instructions at, except that you don't have to make an OAuth key (a browser/server/iOS app key under the tab "Public API Access" does the job just as well).

Response format

Some people complained that libsprec depends on my libjsonz library. I've thus removed the dependency. I tried to use yajl instead, but Google's JSON response is in a very, um, particular format (it's sometimes two JSON objects separated by a newline), and yajl doesn't seem to be able to digest it. So libsprec now just spits out verbatim the JSON it has got, and it's the developer's responsibility to make sense of it.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.