• Stars
    star
    296
  • Rank 140,464 (Top 3 %)
  • Language
    C
  • License
    MIT License
  • Created about 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CMU PocketSphinx for Golang, a lightweight speech recognition engine.

CMUSphinx for Golang Lines of Code

cmusphinx logo

Intro

CMUSphinx collects over 20 years of the CMU research. All advantages are hard to list, but just to name a few:

  • State of art speech recognition algorithms for efficient speech recognition. CMUSphinx tools are designed specifically for low-resource platforms;
  • Flexible design;
  • Focus on practical application development and not on research;
  • Support for several languages like US English, UK English, French, Mandarin, German, Dutch, Russian and ability to build a models for others;
  • BSD-like license which allows commercial distribution;
  • Active development and release schedule;
  • Active community (more than 400 users on Linkedin CMUSphinx group);
  • Wide range of tools for many speech-recognition related purposes (keyword spotting, alignment, pronuncation evaluation).

Refer to http://cmusphinx.sourceforge.net/wiki/ for the further info.

This project

The main aim of the pocketsphinx-go project is to bring all those features to the Go programming language. Firstly, by leveraging awesome cgogen framework I was able to create full-featured bindings to the pocketsphinx core library and sphinxbase just in a few hours of config tweaking. Secondly, I added a high-level wrapper package on top of that so users won't be bothered too much by rough API and lack of documentation in godoc. The code is from the edge of both upstreams, so any new features added like yesterday will be automatically there in no time.

package pocketsphinx GoDoc

Package pocketsphinx provides Go bindings for pocketsphinx, one of Carnegie Mellon University's open source large vocabulary, speaker-independent continuous speech recognition engine. Pocketsphinx is a library that depends on another library called SphinxBase which provides common functionality across all CMUSphinx projects. All the binding code has automatically been generated with rules defined in pocketsphinx.yml. This tries to cover as much as possible of the API, if you missing some method or type you'd like to see here — just create an issue and it'll be there.

Examples of use: sphinx/lattice.go, and others from the sphinx package.

package sphinx GoDoc

Package sphinx is a top-level wrapper for PocketSphinx API exposed by the autogenerated pocketsphinx package. It is hand written and covers almost everything you'd like to have from PhocketSphinx: the decoder, lattices, n-grams, mllr and log-math. There is a possibility to add fsg, fe and feat modules in a few hours, but I was too lazy to get them done in the first place, let me know if you need them too by creating an issue. Actually they are from SphinxBase rather than from the public set of methods of PocketSphinx. This one is the main package you should use to work ith CMUSphinx. It tries to simplify its methods for use from Go and provides a complete documentation as the original code does.

Examples of use: gortana/main.go.

Installation

In order to start experimenting with sphinx you need to install the latest version from sources, do not use any pre-packaged versions as the latest stable release was in 2008 and since then they continiuously working on the software in "pre-alpha" mode, that means the master branch in the upstream. So installation is simple, just follow their instaructions.

  1. Install https://github.com/cmusphinx/sphinxbase - this should go fast. Better to install to /usr/local.
  2. Install https://github.com/cmusphinx/pocketsphinx - this one depends on sphinxbase and contains models for language and dictionaries, so expect to download 200M of data. Better to install to /usr/local.

In both cases it can be done like this:

./autogen.sh
make
make install

And finally get the sphinx package:

$ go get github.com/xlab/pocketsphinx-go/sphinx

It will locate the pocketsphinx installation using pkg-config.

Example

There is an example program called gortana that simply listens to your speech in continious mode and triest to recognize something. I haven't managed to recognize "gopher" but any common-ish sentences it gets right, the stock HMM, LM and Dict are good. For input it uses portaudio-go. So you will need to get portaudio installed first.

$ brew install portaudio
$ go get github.com/xlab/pocketsphinx-go/example/gortana
$ gortana --help
 __
/ _  _  _|_ _  _  _
\__)(_)| |_(_|| )(_|

Usage: gortana [OPTIONS]

Goratana is a dumb personal assistant to test how CMUSphinx works from Golang.

Options:
  --hmm="/usr/local/share/pocketsphinx/model/en-us/en-us"                 Sets directory containing acoustic model files.
  --dict="/usr/local/share/pocketsphinx/model/en-us/cmudict-en-us.dict"   Sets main pronunciation dictionary (lexicon) input file..
  --lm="/usr/local/share/pocketsphinx/model/en-us/en-us.lm.bin"           Sets word trigram language model input file.
  --log="gortana.log"                                                     Log file to write log to.
  --stdout=false                                                          Disables log file and writes everything to stdout.
  --outraw=""                                                             Specify output dir for RAW recorded sound files (s16le). Directory must exist.

By default it writes to the log, but if something seems strange, you may enable stdout logging instead and see everything what's going on. Paths for HMM, LM and Dict are based upon standard installation to /usr/local. And one more thing: there is an option to write every utterance sphinx had processesed to some dir and this directory should exist, otherwise gortana won't start. Then you can simply play them with ffplay from ffmpeg:

$ ffplay -f s16le -ar 16000 -ac 1 -i out/000000000.raw

$ play -r 16k -e signed-integer -b 16 -c 1 out/000000000.raw

Rebuilding the package

You will need to get the c-for-go tool installed first.

$ git clone https://github.com/xlab/pocketsphinx-go && cd pocketsphinx-go
$ make clean
$ make

Contributing

Feel free to share bugs, especially when method signature doesn't look like expected ([] instad of *, etc). Please also share this project in social networks so more people would know how to use offline voice recognition in their Go apps.

License

All the code except when stated otherwise is licensed under the MIT license.

More Repositories

1

c-for-go

Automatic C-Go Bindings Generator for Go Programming Language
Go
1,384
star
2

android-go

The android-go project provides a platform for writing native Android apps in Go programming language.
Go
1,058
star
3

treeprint

Package treeprint provides a simple ASCII tree composing tool.
Go
387
star
4

libvpx-go

Package vpx provides Go bindings for libvpx-1.6.0, the WebM Project VP8/VP9 codec implementation.
C
190
star
5

go-lambda

A multi-purpose tool for creating and managing AWS Lambda instances backed by arbitrary Go code
Go
146
star
6

closer

Package closer ensures a clean exit for your Go app.
Go
132
star
7

at

AT is a framework written in Go for communication with AT-compatible devices like Huawei modems via serial port.
Go
113
star
8

matchbox-keyboard

A mirror of matchbox-keyboard tree + my patches
C
63
star
9

netsed

Mirror of http://silicone.homelinux.org/git/netsed.git/
C
59
star
10

structwalk

Battle-tested Go struct and map traversal utilities.
Go
31
star
11

portmidi

The package provides Go bindings for PortMIDI from the PortMedia set of libraries.
Go
26
star
12

teg-workshop

Go
25
star
13

tablewriter

The platform-independent fork of Go ASCII Table Generator, ported from the Ruby terminal-tables library.
Go
24
star
14

handysort

Alphanumeric string sorting algorithm implementation in Go
Go
24
star
15

vorbis-go

Package vorbis provides Go bindings for OggVorbis implementation by the Xiph.Org Foundation.
C
23
star
16

libpd-go

Package libpd provides an idiomatic Go-lang wrapper for Pure Data embeddable audio synthesis library.
Go
19
star
17

portaudio-go

Package portaudio provides Go bindings for PortAudio.
Go
18
star
18

ios-go

The iOS-go project provides a platform for writing native iOS apps in Go programming language.
Go
17
star
19

opus-go

Package opus provides Go bindings for Opus encoder/decoder reference implementation by Xiph.org
C
16
star
20

gitio

A git.io client for Go, also a CLI utility.
Go
13
star
21

pace

Package pace provides a threadsafe counter for measuring ticks in the specified timeframe.
Go
9
star
22

pkgconfig

A lightweight pkg-config(1) clone written in Go.
Go
7
star
23

alac-go

Package alac provides Go bindings for ALAC decoder (C version by David Hammerton) with community patches.
C
5
star
24

suplog

Supercharged Go logging based on Logrus
Go
5
star
25

etherman

Etherman is a CLI tool for managing and testing Solidity contract deployments, written in pure Go.
Go
5
star
26

midievent

Package midievent provides MIDI event type mappings for Go-lang.
Go
4
star
27

termtables

A fork of long-gone apcera/termtables, because I liked it.
Go
4
star
28

smsru

Go-lang API bindings for sms.ru
Go
3
star
29

qml-kit

qml-kit is a bootstrapping template for Go/QML projects.
Go
3
star
30

ziptools

Package ziptools provides functionality to search through USA zip codes and cities in extremely fast way.
Go
3
star
31

clipboard

Clipboard for Go (go-qml applications, uses Qt)
C++
2
star
32

tpmmgd

My coursework 2013 - Modeling DEDS with timed Petri nets
JavaScript
2
star
33

libafrodite

Code completion engine for Vala language
Vala
1
star
34

wp8sdk-installer

A try to install Windows Phone 8 SDK under Windows 7
Ruby
1
star
35

nl80211

Generating Go constants from a C header example project.
C
1
star
36

chunked

A PoC service for chunked and encrypted file uploads.
JavaScript
1
star
37

beam-o

Fire a beam to teleport your files onto servers in distant galaxies.
Go
1
star
38

tun

Tun is a tool that serves files from the specified directory or a web resource.
Go
1
star
39

linmath

Go port of linmath.h — a small library for linear math as required for computer graphics.
Go
1
star
40

statsd_metrics

Common logic to report Go runtime and custom metrics to Telegraf/StatsD
Go
1
star
41

api

Package api is a helper that simplifies the process of REST APIs bindings creation in Go.
Go
1
star
42

invoker

Supercharged "exec.Cmd" helpers for asynchronous and thread-safe reading of StdOut and StdErr.
Go
1
star