Git Product home page Git Product logo

libsprec's Introduction

Libsprec

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 web_client.h 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 sprec_flac_encode() from flac_encoder.h. Then one can proceed as described above. You can use the sprec_record_wav() function for recording in the appropriate format.

The simple API

To simplify this task, two convenience functions, sprec_recognize_sync() and sprec_recognize_async() are also available (the latter needs POSIX threads).

See examples/simple.c for further API usage information.

The usage of the example program is:

./simple <API key> <language code> <duration>

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 http://www.chromium.org/developers/how-tos/api-keys, 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.

libsprec's People

Contributors

h2co3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libsprec's Issues

iOS app expample

Hi, i'm new on ios dev, can you provide me an example to integrate this with a project.
Thanks

Crashes on 10.13 High Sierra

Flac_encoder.c, line 124 crashes: EXC_ARITHMETIC (code=EXC_I386_DIV, subcode=0x0)

Looks like there are issues reading the header file.

undefined reference to 'alloca'

Hi, I am having the same problem as #3.
(I am using the rapsberry pi)

When I try to compile 'simple.c' with the following command
"gcc -o simple simple.c -lsprec -lpthread"
the following came up:
/usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../libsprec.so: undefined reference to 'alloca'
collect2: error: ld returned 1 exit status

I tried to delete the library and build it again, but it doesn't work for me and I am quite stuck here.
Is there a way I can fix this problem?

Thank you

Can this be build in XCode?

Hi. I've downloaded the mentioned .deb libs (dependencies) and the libsprec .zip. Now that I have an src folder with classes and all the .deb files needed, should I be looking into how to compile this in XCode, or should it be done via some command line compiler?

Also, I see that ios.makefile mentions it's system root as iOS5 SDK. Is this a separate download?

Thanks.

Integrating with iOS

Hello!
I am making my first Xcode project, but I don't know how to use your libsprec. Can you send me some example, please?

Cannot build exampls/simple.c

Running "make simple" I got the following error:

gcc -o sprec_simple examples/simple.o -lsprec
/usr/bin/ld: examples/simple.o: undefined reference to symbol 'pthread_join@@GLIBC_2.0'
/usr/bin/ld: note: 'pthread_join@@GLIBC_2.0' is defined in DSO /lib/i386-linux-gnu/libpthread.so.0 so try adding it to the linker command line
/lib/i386-linux-gnu/libpthread.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [sprec_simple] Error 1

Error messege after finish compile tool.c

Hi, I am interested to use libsprec as speech recognizer C library for my final year project. Currently I am still new in c programming, try to understand the coding and compile & run the examples/tool.c in Ubuntu platform and it show segmentation fault error message.

This is how I compile tool.c:
g++ -o tool tool.c -lsprec -ljsonz -lcurl -lFLAC -lasound

and then i run it after compiling it:
./tool

however, it show messege as show below after few seconds:
Segmentation fault

Please help and correct me if I did any mistake during compiling tool.c. Thanks and have a nice day :)

Sample demo crash!

Hello,

I build given library and demo example application on raspberry pi 3 and when I run this application on command line, getting segmentation fault. Find out below run time error:

ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM pulse
Segmentation fault

Please clarification on above issue!

Thanks,
Pratik

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.