Skip to content

Instantly share code, notes, and snippets.

@fasiha
Last active June 10, 2017 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fasiha/6f480420cc535a9ab608aaaff62cb63d to your computer and use it in GitHub Desktop.
Save fasiha/6f480420cc535a9ab608aaaff62cb63d to your computer and use it in GitHub Desktop.
Run an audio file through speech-to-text via CMU Sphinx on macOS

Install homebrew

Via https://brew.sh/

Install CMU Sphinx

Per https://github.com/watsonbox/homebrew-cmu-sphinx,

$ brew tap watsonbox/cmu-sphinx
$ brew install --HEAD watsonbox/cmu-sphinx/cmu-sphinxbase
$ brew install --HEAD watsonbox/cmu-sphinx/cmu-pocketsphinx

Install ffmpeg

$ brew install ffmpeg

Prepare the audio using ffmpeg:

$ ffmpeg -i INPUT_FILE -ac 1 -ar 16000 output.wav
  • -ac 1 means mono
  • -ar 16000 means 16 KHz sample rate

Run

$ pocketsphinx_continuous -infile output.wav > output.txt

A lot of output will be generated but the text will go to output.txt. You can monitor its progress in another shell:

$ tail -f output.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment