{"id":17041686,"url":"https://github.com/xlab/pocketsphinx-go","last_synced_at":"2025-04-06T05:18:33.656Z","repository":{"id":54165659,"uuid":"67300743","full_name":"xlab/pocketsphinx-go","owner":"xlab","description":"CMU PocketSphinx for Golang, a lightweight speech recognition engine.","archived":false,"fork":false,"pushed_at":"2023-04-23T16:12:43.000Z","size":280,"stargazers_count":302,"open_issues_count":7,"forks_count":47,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-30T04:09:22.315Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-03T16:41:51.000Z","updated_at":"2025-02-23T20:36:35.000Z","dependencies_parsed_at":"2024-06-18T17:22:06.070Z","dependency_job_id":null,"html_url":"https://github.com/xlab/pocketsphinx-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fpocketsphinx-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fpocketsphinx-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fpocketsphinx-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlab%2Fpocketsphinx-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xlab","download_url":"https://codeload.github.com/xlab/pocketsphinx-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247436624,"owners_count":20938600,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T09:13:13.927Z","updated_at":"2025-04-06T05:18:33.577Z","avatar_url":"https://github.com/xlab.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CMUSphinx for Golang ![Lines of Code](https://img.shields.io/badge/lines-3.7K-blue.svg)\n\n\u003cimg alt=\"cmusphinx logo\" src=\"internal/cmusphinx.png\" width=\"200\" /\u003e\n\n## Intro\n\n[CMUSphinx](http://cmusphinx.sourceforge.net) collects over 20 years of the CMU research. All advantages are hard to list, but just to name a few:\n\n* State of art speech recognition algorithms for efficient speech recognition. CMUSphinx tools are designed specifically for low-resource platforms;\n* Flexible design;\n* Focus on practical application development and not on research;\n* Support for several languages like US English, UK English, French, Mandarin, German, Dutch, Russian and ability to build a models for others;\n* BSD-like license which allows commercial distribution;\n* Active development and release schedule;\n* Active community (more than 400 users on Linkedin CMUSphinx group);\n* Wide range of tools for many speech-recognition related purposes (keyword spotting, alignment, pronuncation evaluation).\n\nRefer to http://cmusphinx.sourceforge.net/wiki/ for the further info.\n\n## This project\n\nThe main aim of the **pocketsphinx-go** project is to bring all those features to the Go programming language. Firstly,\nby leveraging awesome [cgogen](https://cgogen.com/) framework I was able to create full-featured\nbindings 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.\n\n### package [pocketsphinx](/pocketsphinx) [![GoDoc](https://godoc.org/github.com/xlab/pocketsphinx-go/pocketsphinx?status.svg)](https://godoc.org/github.com/xlab/pocketsphinx-go/pocketsphinx)\n\nPackage **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](/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.\n\nExamples of use: [sphinx/lattice.go](sphinx/lattice.go), and others from the sphinx package.\n\n### package [sphinx](/sphinx) [![GoDoc](https://godoc.org/github.com/xlab/pocketsphinx-go/sphinx?status.svg)](https://godoc.org/github.com/xlab/pocketsphinx-go/sphinx)\n\nPackage **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.\n\nExamples of use: [gortana/main.go](/example/gortana/main.go).\n\n## Installation\n\nIn 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.\n\n1. Install https://github.com/cmusphinx/sphinxbase - this should go fast. Better to install to `/usr/local`.\n2. 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`.\n\nIn both cases it can be done like this:\n\n```\n./autogen.sh\nmake\nmake install\n```\n\nAnd finally get the **sphinx** package:\n\n```\n$ go get github.com/xlab/pocketsphinx-go/sphinx\n```\n\nIt will locate the pocketsphinx installation using `pkg-config`.\n\n## Example\n\nThere is an example program called [gortana](/example/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](https://github.com/xlab/portaudio-go). So you will need to get portaudio installed first.\n\n```\n$ brew install portaudio\n$ go get github.com/xlab/pocketsphinx-go/example/gortana\n$ gortana --help\n __\n/ _  _  _|_ _  _  _\n\\__)(_)| |_(_|| )(_|\n\nUsage: gortana [OPTIONS]\n\nGoratana is a dumb personal assistant to test how CMUSphinx works from Golang.\n\nOptions:\n  --hmm=\"/usr/local/share/pocketsphinx/model/en-us/en-us\"                 Sets directory containing acoustic model files.\n  --dict=\"/usr/local/share/pocketsphinx/model/en-us/cmudict-en-us.dict\"   Sets main pronunciation dictionary (lexicon) input file..\n  --lm=\"/usr/local/share/pocketsphinx/model/en-us/en-us.lm.bin\"           Sets word trigram language model input file.\n  --log=\"gortana.log\"                                                     Log file to write log to.\n  --stdout=false                                                          Disables log file and writes everything to stdout.\n  --outraw=\"\"                                                             Specify output dir for RAW recorded sound files (s16le). Directory must exist.\n```\n\nBy 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:\n\n```\n$ ffplay -f s16le -ar 16000 -ac 1 -i out/000000000.raw\n\n$ play -r 16k -e signed-integer -b 16 -c 1 out/000000000.raw\n```\n\n## Rebuilding the package\n\nYou will need to get the [c-for-go](https://git.io/c-for-go) tool installed first.\n\n```\n$ git clone https://github.com/xlab/pocketsphinx-go \u0026\u0026 cd pocketsphinx-go\n$ make clean\n$ make\n```\n\n## Contributing\n\nFeel free to share bugs, especially when method signature doesn't look like expected (`[]` instad of `*`, etc).\nPlease also share this project in social networks so more people would know how to use offline voice recognition in their Go apps.\n\n## License\n\nAll the code except when stated otherwise is licensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlab%2Fpocketsphinx-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxlab%2Fpocketsphinx-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlab%2Fpocketsphinx-go/lists"}