POCKETSPHINX(1)

πŸ“¦
version 5.1.1 Β· 2 versions
, in nixpkgs unstable, ubuntu stonking

πŸ’– NAME πŸ’–

pocketsphinx β€” run speech recognition on audio data. That's the whole gig, bestie. 🎀✨

This is the POCKETSPHINX(1) page, straight outta the General Commands Manual. Pocketsphinx said "name so nice u write it twice" so the og header had it on both ends, but we're folding it up here at the top where it belongs. 🫢


πŸŽ€ SYNOPSIS πŸŽ€

pocketsphinx [ options... ] [ live | single | help | soxflags ]
INPUTS...

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: the pocketsphinx command-line program reads single-channel 16-bit PCM audio from one or more input files β€” or from - if u want it slurping straight off standard input πŸ₯€ β€” and then it goes and tries to recognize speech in that audio using the default acoustic and language model. It's giving main character energy fr fr.

Those input files can be raw audio, WAV, or NIST Sphere files β€” tho ngl some of these may not get recognized properly, so don't come for me if ur crusty old file gets ignored. πŸ’€

It also takes a large number of options which you probably don't care about, plus a command, which defaults to live if u don't say anything. Iconic lazy-girl behavior, we respect it.

Here's the rundown of the commands, bestie:

  • help β€” print a long list of those options you don't care about. Yes, that's literally the description. Slay.
  • config β€” dump the configuration as JSON to standard output. Bonus: u can load it right back in with the -config option. ♻️
  • live β€” detect speech segments in the input files, run recognition on them (using all those options u don't care about), and write the results to standard output as line-delimited JSON. I know, it's not the prettiest format ever, but honestly it sure beats XML. πŸ™ˆ

Every line is a JSON object with these fields, which got short names purely so the lines stay readable:

  • "b" β€” start time in seconds, counted from the beginning of the stream ⏱️
  • "d" β€” duration in seconds
  • "p" β€” estimated probability of the recognition result, i.e. a number between 0 and 1 which u may use as a confidence score
  • "t" β€” full text of the recognition result
  • "w" β€” list of segments (usually words), each of which in turn contains the b, d, p, and t fields, for start, end, probability, and the text of the word. In the future we may also support hierarchical results, in which case w could be present.
  • single β€” recognize the input as a single utterance, and write a JSON object in the same format described above. One shot, one vibe. 🎯
  • align β€” align a single input file (or - for standard input) to a word sequence, and write a JSON object in the same format described above.

The first positional argument is the input, and all the subsequent ones get concatenated to make the text β€” that way there are no surprises if u forget to quote it. And bestie, you are responsible for normalizing the text to remove punctuation, uppercase, centipedes, etc. (yes. centipedes. that's what it says. we don't make the rules πŸ›)

For example:

pocketsphinx align goforward.wav "go forward ten meters"

By default, only word-level alignment happens. If u want phone alignments, pass -phone_align yes in the flags, like:

pocketsphinx -phone_align yes align audio.wav $text

And to get state-level alignments, pass -state_align yes β€” heads up, that automatically enables phone alignment as well:

pocketsphinx -state_align yes align audio.wav $text

This will make not particularly readable output, but u can use jq (https://stedolan.github.io/jq/) to clean it up. For example, u can get just the word names and start times like this:

pocketsphinx align audio.wav $text | jq '.w[]|[.t,.b]'

Or u could get the phone names and durations like this:

pocketsphinx -phone_align yes align audio.wav $text | jq '.w[]|.w[]|[.t,.d]'

There are many, many other possibilities, of course. Go wild. πŸ’…

  • help β€” print a usage and help text with a list of possible arguments. Yes, help shows up twice in this list, mind ur business. 😌 U can also get command-specific help by specifying a command after help β€” for example, pocketsphinx help align will show u the alignment-specific options. Chef's kiss. πŸ‘‘
  • help-config β€” print a long list of all configuration parameters with their descriptions. This is the deep lore for the config girlies.
  • soxflags β€” return arguments to sox which will create the appropriate input format. But ⚠️ note that because the sox command-line is slightly quirky, these must always come after the filename or -d (and -d is what tells sox to read from the microphone, iykyk). πŸŽ™οΈ

U can run live recognition like this:

sox -d $(pocketsphinx soxflags) | pocketsphinx -

Or decode from a file named "audio.mp3" like this:

sox audio.mp3 $(pocketsphinx soxflags) | pocketsphinx -

By default, only errors get printed to standard error. If u want more info, pass -loglevel INFO and it will spill the tea. β˜•

Also: partial results are not printed. Maybe they will be in the future, but bestie, don't hold ur breath. πŸ™ˆ Force-alignment, however, is likely to be supported soon. ✨

⚑ OPTIONS ⚑

okay bestie, this is the part where we go through EVERY. SINGLE. FLAG. no skipping, no gatekeeping, we're doing the whole list πŸ’… each one comes before the audio files on the command line, iykyk.

  • -agc β€” automatic gain control for c0, and your choices are 'max', 'emax', 'noise', or 'none' ✨
  • -agcthresh β€” the initial threshold for that automatic gain control
  • -allphone β€” phoneme decoding with a phonetic lm (and yeah, you hand it the file right here)
  • -allphone_ci β€” do the phoneme decoding with a phonetic lm but context-independent units only, no context drama πŸŽ€
  • -alpha β€” preemphasis parameter
  • -ascale β€” inverse of the acoustic model scale, used for confidence score calculation
  • -aw β€” inverse weight applied to acoustic scores
  • -backtrace β€” print results AND backtraces to the log πŸ“
  • -beam β€” beam width applied to every frame in the Viterbi search (heads up: smaller values mean a wider beam, yes it's giving backwards, that's just how it is)
  • -bestpath β€” run the bestpath (Dijkstra) search over the word lattice β€” that's the 3rd pass πŸ‘‘
  • -bestpathlw β€” language model probability weight for the bestpath search
  • -ceplen β€” number of components in the input feature vector
  • -cmn β€” cepstral mean normalization scheme, pick 'live', 'batch', or 'none'
  • -cmninit β€” initial values (comma-separated, bestie) for the cepstral mean when 'live' is the scheme in use
  • -compallsen β€” compute all senone scores in every frame (this can genuinely be faster when there are a lot of senones, slay)
  • -dict β€” pronunciation dictionary (lexicon) input file
  • -dictcase β€” dictionary is case sensitive (⚠️ NOTE: the case insensitivity applies to ASCII characters only)
  • -dither β€” add 1/2-bit noise
  • -doublebw β€” use double bandwidth filters (same center freq, just chonkier)
  • -ds β€” frame GMM computation downsampling ratio
  • -fdict β€” word pronunciation dictionary input file
  • -feat β€” feature stream type, depends on the acoustic model
  • -featparams β€” containing feature extraction parameters.
  • -fillprob β€” filler word transition probability
  • -frate β€” frame rate
  • -fsg β€” format finite state grammar file
  • -fsgusealtpron β€” add alternate pronunciations to the FSG
  • -fsgusefiller β€” insert filler words at each state.
  • -fwdflat β€” run the forward flat-lexicon search over the word lattice β€” that's the 2nd pass ✨
  • -fwdflatbeam β€” beam width applied to every frame in the second-pass flat search
  • -fwdflatefwid β€” minimum number of end frames for a word to be searched in the fwdflat search
  • -fwdflatlw β€” language model probability weight for flat lexicon (2nd pass) decoding
  • -fwdflatsfwin β€” window of frames in the lattice to search for successor words in the fwdflat search
  • -fwdflatwbeam β€” beam width applied to word exits in the second-pass flat search
  • -fwdtree β€” run the forward lexicon-tree search β€” that's the 1st pass, the og πŸ’–
  • -hmm β€” containing acoustic model files.
  • -input_endian β€” endianness of the input data, big or little, ignored if it's NIST or MS Wav
  • -jsgf β€” grammar file
  • -keyphrase β€” to spot
  • -kws β€” file with keyphrases to spot, one per line
  • -kws_delay β€” delay to wait for the best detection score
  • -kws_plp β€” phone loop probability for keyphrase spotting
  • -kws_threshold β€” threshold for the p(hyp)/p(alternatives) ratio
  • -latsize β€” initial backpointer table size
  • -lda β€” containing transformation matrix to be applied to features (single-stream features only, don't try it with anything else)
  • -ldadim β€” dimensionality of the output of the feature transformation (0 means use the entire matrix)
  • -lifter β€” length of the sin-curve for liftering, or 0 for no liftering.
  • -lm β€” trigram language model input file
  • -lmctl β€” a set of language model
  • -lmname β€” language model in -lmctl to use by default
  • -logbase β€” base in which all log-likelihoods are calculated
  • -logfn β€” to write log messages in
  • -loglevel β€” minimum level of log messages (DEBUG, INFO, WARN, ERROR)
  • -logspec β€” write out logspectral files instead of cepstra
  • -lowerf β€” lower edge of filters
  • -lpbeam β€” beam width applied to the last phone in words
  • -lponlybeam β€” beam width applied to the last phone in single-phone words
  • -lw β€” language model probability weight
  • -maxhmmpf β€” maximum number of active HMMs to maintain at each frame (or -1 for no pruning)
  • -maxwpf β€” maximum number of distinct word exits at each frame (or -1 for no pruning)
  • -mdef β€” definition input file
  • -mean β€” gaussian means input file
  • -mfclogdir β€” to log feature files to
  • -min_endfr β€” nodes ignored in lattice construction if they persist for fewer than N frames
  • -mixw β€” mixture weights input file (uncompressed)
  • -mixwfloor β€” senone mixture weights floor (applied to data from the -mixw file)
  • -mllr β€” transformation to apply to means and variances
  • -mmap β€” use memory-mapped I/O (if possible) for model files
  • -ncep β€” number of cep coefficients
  • -nfft β€” size of the FFT, or 0 to set it automatically (recommended, fr fr trust)
  • -nfilt β€” number of filter banks
  • -nwpen β€” new word transition penalty
  • -pbeam β€” beam width applied to phone transitions
  • -pip β€” phone insertion penalty
  • -pl_beam β€” beam width applied to phone loop search for lookahead
  • -pl_pbeam β€” beam width applied to phone loop transitions for lookahead
  • -pl_pip β€” phone insertion penalty for phone loop
  • -pl_weight β€” weight for phoneme lookahead penalties
  • -pl_window β€” phoneme lookahead window size, in frames
  • -rawlogdir β€” to log raw audio files to
  • -remove_dc β€” remove DC offset from each frame
  • -remove_noise β€” remove noise using spectral subtraction
  • -round_filters β€” round mel filter frequencies to DFT points
  • -samprate β€” sampling rate
  • -seed β€” seed for the random number generator; if it's less than zero, we pick our own 🎲
  • -sendump β€” dump (compressed mixture weights) input file
  • -senlogdir β€” to log senone score files to
  • -senmgau β€” to codebook mapping input file (usually not needed)
  • -silprob β€” silence word transition probability
  • -smoothspec β€” write out cepstral-smoothed logspectral files
  • -svspec β€” specification (e.g., 24,0-11/25,12-23/26-38 or 0-12/13-25/26-38)
  • -tmat β€” state transition matrix input file
  • -tmatfloor β€” HMM state transition probability floor (applied to the -tmat file)
  • -topn β€” maximum number of top Gaussians to use in scoring.
  • -topn_beam β€” beam width used to determine top-N Gaussians (or a list, per-feature 🫢)
  • -toprule β€” rule for JSGF (first public rule is the default)
  • -transform β€” which type of transform to use to calculate cepstra (legacy, dct, or htk)
  • -unit_area β€” normalize mel filters to unit area
  • -upperf β€” upper edge of filters
  • -uw β€” unigram weight
  • -var β€” gaussian variances input file
  • -varfloor β€” mixture gaussian variance floor (applied to data from the -var file)
  • -varnorm β€” variance normalize each utterance (only if CMN == current, no exceptions bestie)
  • -verbose β€” show input filenames
  • -warp_params β€” defining the warping function
  • -warp_type β€” warping function type (or shape)
  • -wbeam β€” beam width applied to word exits
  • -wip β€” word insertion penalty
  • -wlen β€” Hamming window length

πŸ‘‘ AUTHOR πŸ‘‘

Written by numerous people at CMU from 1994 onwards. This manual page by David Huggins-Daines <dhdaines@gmail.com> πŸ’Œ


Copyright Β© 1994-2016 Carnegie Mellon University. See the file LICENSE included with this package for more information.


πŸ¦‹ SEE ALSO πŸ¦‹


okay that's the whole page, you made it, I'm so proud of you πŸ₯ΉπŸ’– this was the POCKETSPHINX(1) page, stamped with the date 2022-09-27 β€” go forth and decode some speech, you absolute icon πŸ’…βœ¨

πŸ“¦ where this page comes from