Package: rhasspy-asr-kaldi
Rhasspy ASR KaldiAutomated speech recognition inRhasspyvoice assistant withKaldi.RequirementsPython 3.7KaldiExpects$KALDI_DIRin environmentOpengrmExpectsngram*in$PATHPhonetisaurusExpectsphonetisaurus-applyin$PATHSeepre-built appsfor pre-compiled binaries.Installation$gitclonehttps://github.com/rhasspy/rhasspy-asr-kaldi
$cdrhasspy-asr-kaldi
$./configure
$make
$makeinstallTranscribingUsepython3 -m rhasspyasr_kaldi transcribe <ARGS>usage: rhasspy-asr-kaldi transcribe [-h] --model-dir MODEL_DIR
                                    [--graph-dir GRAPH_DIR]
                                    [--model-type MODEL_TYPE]
                                    [--frames-in-chunk FRAMES_IN_CHUNK]
                                    [wav_file [wav_file ...]]

positional arguments:
  wav_file              WAV file(s) to transcribe

optional arguments:
  -h, --help            show this help message and exit
  --model-dir MODEL_DIR
                        Path to Kaldi model directory (with conf, data)
  --graph-dir GRAPH_DIR
                        Path to Kaldi graph directory (with HCLG.fst)
  --model-type MODEL_TYPE
                        Either nnet3 or gmm (default: nnet3)
  --frames-in-chunk FRAMES_IN_CHUNK
                        Number of frames to process at a timeFor nnet3 models, theonline2-tcp-nnet3-decode-fasterprogram is used to handle streaming audio. For gmm models, audio is buffered and packaged as a WAV file before being transcribed.TrainingUsepython3 -m rhasspyasr_kaldi train <ARGS>usage: rhasspy-asr-kaldi train [-h] --model-dir MODEL_DIR
                               [--graph-dir GRAPH_DIR]
                               [--intent-graph INTENT_GRAPH]
                               [--dictionary DICTIONARY]
                               [--dictionary-casing {upper,lower,ignore}]
                               [--language-model LANGUAGE_MODEL]
                               --base-dictionary BASE_DICTIONARY
                               [--g2p-model G2P_MODEL]
                               [--g2p-casing {upper,lower,ignore}]

optional arguments:
  -h, --help            show this help message and exit
  --model-dir MODEL_DIR
                        Path to Kaldi model directory (with conf, data)
  --graph-dir GRAPH_DIR
                        Path to Kaldi graph directory (with HCLG.fst)
  --intent-graph INTENT_GRAPH
                        Path to intent graph JSON file (default: stdin)
  --dictionary DICTIONARY
                        Path to write custom pronunciation dictionary
  --dictionary-casing {upper,lower,ignore}
                        Case transformation for dictionary words (training,
                        default: ignore)
  --language-model LANGUAGE_MODEL
                        Path to write custom language model
  --base-dictionary BASE_DICTIONARY
                        Paths to pronunciation dictionaries
  --g2p-model G2P_MODEL
                        Path to Phonetisaurus grapheme-to-phoneme FST model
  --g2p-casing {upper,lower,ignore}
                        Case transformation for g2p words (training, default:
                        ignore)This will generate a customHCLG.fstfrom an intent graph created usingrhasspy-nlu. Your Kaldi model directory should be laid out like this:my_model/  (--model-dir)conf/mfcc_hires.confdata/local/dict/lexicon.txt (copied from--dictionary)lang/lm.arpa.gz (copied from--language-model)graph/ (--graph-dir)HCLG.fst (generated)model/final.mdlphones/extra_questions.txtnonsilence_phones.txtoptional_silence.txtsilence_phones.txtonline/ (nnet3 only)extractor/ (nnet3 only)When using thetraincommand, you will need to specify the following arguments:--intent-graph- path to graph json file generated usingrhasspy-nlu--model-type- either nnet3 or gmm--model-dir- path to top-level model directory (my_model in example above)--graph-dir- path to directory where HCLG.fst should be written (my_model/graph in example above)--base-dictionary- pronunciation dictionary with all words from intent graph (can be used multiple times)--dictionary- path to write custom pronunciation dictionary (optional)--language-model- path to write custom ARPA language model (optional)Building From Sourcerhasspy-asr-kaldidepends on the following programs that must be compiled:KaldiSpeech to text engineOpengrmCreate ARPA language modelsPhonetisaurusGuesses pronunciations for unknown wordsKaldiMake sure you have the necessary dependencies installed:sudoapt-getinstall\build-essential\libatlas-base-devlibatlas3-basegfortran\automakeautoconfunzipsoxlibtoolsubversion\python3python\gitzlib1g-devDownload Kaldi and extract it:wget-Okaldi-master.tar.gz\'https://github.com/kaldi-asr/kaldi/archive/master.tar.gz'tar-xvfkaldi-master.tar.gzFirst, build Kaldi's tools:cdkaldi-master/tools
makeUsemake -j 4if you have multiple CPU cores. This will take alongtime.Next, build Kaldi itself:cdkaldi-master
./configure--shared--mathlib=ATLAS
makedepend
makeUsemake depend -j 4andmake -j 4if you have multiple CPU cores. This will take alongtime.There is no installation step. Thekaldi-masterdirectory contains all the libraries and programs that Rhasspy will need to access.Seedocker-kaldifor a Docker build script.PhonetisaurusMake sure you have the necessary dependencies installed:sudoapt-getinstallbuild-essentialFirst, download and buildOpenFST 1.6.2wgethttp://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.6.2.tar.gz
tar-xvfopenfst-1.6.2.tar.gzcdopenfst-1.6.2
./configure\"--prefix=$(pwd)/build"\--enable-static--enable-shared\--enable-far--enable-ngram-fsts
make
makeinstallUsemake -j 4if you have multiple CPU cores. This will take alongtime.Next, download and extract Phonetisaurus:wget-Ophonetisaurus-master.tar.gz\'https://github.com/AdolfVonKleist/Phonetisaurus/archive/master.tar.gz'tar-xvfphonetisaurus-master.tar.gzFinally, build Phonetisaurus (where/path/to/openfstis theopenfst-1.6.2directory from above):cd Phonetisaurus-master
./configure \
    --with-openfst-includes=/path/to/openfst/build/include \
    --with-openfst-libs=/path/to/openfst/build/lib
make
make installUsemake -j 4if you have multiple CPU cores. This will take alongtime.You should now be able to run thephonetisaurus-alignprogram.Seedocker-phonetisaurusfor a Docker build script.