{"id":20581589,"url":"https://github.com/rhasspy/rhasspy-asr-kaldi","last_synced_at":"2025-10-06T19:49:03.371Z","repository":{"id":57461842,"uuid":"231017993","full_name":"rhasspy/rhasspy-asr-kaldi","owner":"rhasspy","description":"Speech to text library for Rhasspy using Kaldi","archived":false,"fork":false,"pushed_at":"2023-12-09T00:41:43.000Z","size":180,"stargazers_count":14,"open_issues_count":4,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T08:11:53.256Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/rhasspy.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}},"created_at":"2019-12-31T03:19:56.000Z","updated_at":"2023-11-06T21:47:27.000Z","dependencies_parsed_at":"2023-02-14T04:15:21.315Z","dependency_job_id":null,"html_url":"https://github.com/rhasspy/rhasspy-asr-kaldi","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhasspy%2Frhasspy-asr-kaldi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhasspy%2Frhasspy-asr-kaldi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhasspy%2Frhasspy-asr-kaldi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhasspy%2Frhasspy-asr-kaldi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhasspy","download_url":"https://codeload.github.com/rhasspy/rhasspy-asr-kaldi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248951869,"owners_count":21188419,"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-11-16T06:29:30.103Z","updated_at":"2025-10-06T19:48:58.302Z","avatar_url":"https://github.com/rhasspy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rhasspy ASR Kaldi\n\n[![Continous Integration](https://github.com/rhasspy/rhasspy-asr-kaldi/workflows/Tests/badge.svg)](https://github.com/rhasspy/rhasspy-asr-kaldi/actions)\n[![GitHub license](https://img.shields.io/github/license/rhasspy/rhasspy-asr-kaldi.svg)](https://github.com/rhasspy/rhasspy-asr-kaldi/blob/master/LICENSE)\n\nAutomated speech recognition in [Rhasspy](https://github.com/synesthesiam/rhasspy) voice assistant with [Kaldi](http://kaldi-asr.org).\n\n## Requirements\n\n* Python 3.7\n* [Kaldi](https://kaldi-asr.org)\n    * Expects `$KALDI_DIR` in environment\n* [Opengrm](http://www.opengrm.org/twiki/bin/view/GRM/NGramLibrary)\n    * Expects `ngram*` in `$PATH`\n* [Phonetisaurus](https://github.com/AdolfVonKleist/Phonetisaurus)\n    * Expects `phonetisaurus-apply` in `$PATH`\n\nSee [pre-built apps](https://github.com/synesthesiam/prebuilt-apps) for pre-compiled binaries.\n\n## Installation\n\n```bash\n$ git clone https://github.com/rhasspy/rhasspy-asr-kaldi\n$ cd rhasspy-asr-kaldi\n$ ./configure\n$ make\n$ make install\n```\n\n## Transcribing\n\nUse `python3 -m rhasspyasr_kaldi transcribe \u003cARGS\u003e`\n\n```\nusage: rhasspy-asr-kaldi transcribe [-h] --model-dir MODEL_DIR\n                                    [--graph-dir GRAPH_DIR]\n                                    [--model-type MODEL_TYPE]\n                                    [--frames-in-chunk FRAMES_IN_CHUNK]\n                                    [wav_file [wav_file ...]]\n\npositional arguments:\n  wav_file              WAV file(s) to transcribe\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --model-dir MODEL_DIR\n                        Path to Kaldi model directory (with conf, data)\n  --graph-dir GRAPH_DIR\n                        Path to Kaldi graph directory (with HCLG.fst)\n  --model-type MODEL_TYPE\n                        Either nnet3 or gmm (default: nnet3)\n  --frames-in-chunk FRAMES_IN_CHUNK\n                        Number of frames to process at a time\n```\n\nFor nnet3 models, the `online2-tcp-nnet3-decode-faster` program is used to handle streaming audio. For gmm models, audio is buffered and packaged as a WAV file before being transcribed.\n\n## Training\n\nUse `python3 -m rhasspyasr_kaldi train \u003cARGS\u003e`\n\n```\nusage: rhasspy-asr-kaldi train [-h] --model-dir MODEL_DIR\n                               [--graph-dir GRAPH_DIR]\n                               [--intent-graph INTENT_GRAPH]\n                               [--dictionary DICTIONARY]\n                               [--dictionary-casing {upper,lower,ignore}]\n                               [--language-model LANGUAGE_MODEL]\n                               --base-dictionary BASE_DICTIONARY\n                               [--g2p-model G2P_MODEL]\n                               [--g2p-casing {upper,lower,ignore}]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --model-dir MODEL_DIR\n                        Path to Kaldi model directory (with conf, data)\n  --graph-dir GRAPH_DIR\n                        Path to Kaldi graph directory (with HCLG.fst)\n  --intent-graph INTENT_GRAPH\n                        Path to intent graph JSON file (default: stdin)\n  --dictionary DICTIONARY\n                        Path to write custom pronunciation dictionary\n  --dictionary-casing {upper,lower,ignore}\n                        Case transformation for dictionary words (training,\n                        default: ignore)\n  --language-model LANGUAGE_MODEL\n                        Path to write custom language model\n  --base-dictionary BASE_DICTIONARY\n                        Paths to pronunciation dictionaries\n  --g2p-model G2P_MODEL\n                        Path to Phonetisaurus grapheme-to-phoneme FST model\n  --g2p-casing {upper,lower,ignore}\n                        Case transformation for g2p words (training, default:\n                        ignore)\n```\n\nThis will generate a custom `HCLG.fst` from an intent graph created using [rhasspy-nlu](https://github.com/rhasspy/rhasspy-nlu). Your Kaldi model directory should be laid out like this:\n\n* my_model/  (`--model-dir`)\n    * conf/\n        * mfcc_hires.conf\n    * data/\n        * local/\n            * dict/\n                * lexicon.txt (copied from `--dictionary`)\n            * lang/\n                * lm.arpa.gz (copied from `--language-model`)\n    * graph/ (`--graph-dir`)\n        * HCLG.fst (generated)\n    * model/\n        * final.mdl\n    * phones/\n        * extra_questions.txt\n        * nonsilence_phones.txt\n        * optional_silence.txt\n        * silence_phones.txt\n    * online/ (nnet3 only)\n    * extractor/ (nnet3 only)\n\nWhen using the `train` command, you will need to specify the following arguments:\n\n* `--intent-graph` - path to graph json file generated using [rhasspy-nlu](https://github.com/rhasspy/rhasspy-nlu)\n* `--model-type` - either nnet3 or gmm\n* `--model-dir` - path to top-level model directory (my_model in example above)\n* `--graph-dir` - path to directory where HCLG.fst should be written (my_model/graph in example above)\n* `--base-dictionary` - pronunciation dictionary with all words from intent graph (can be used multiple times)\n* `--dictionary` - path to write custom pronunciation dictionary (optional)\n* `--language-model` - path to write custom ARPA language model (optional)\n\n## Building From Source\n\n`rhasspy-asr-kaldi` depends on the following programs that must be compiled:\n\n* [Kaldi](http://kaldi-asr.org)\n    * Speech to text engine\n* [Opengrm](http://www.opengrm.org/twiki/bin/view/GRM/NGramLibrary)\n    * Create ARPA language models\n* [Phonetisaurus](https://github.com/AdolfVonKleist/Phonetisaurus)\n    * Guesses pronunciations for unknown words\n\n### Kaldi\n\nMake sure you have the necessary dependencies installed:\n\n```bash\nsudo apt-get install \\\n    build-essential \\\n    libatlas-base-dev libatlas3-base gfortran \\\n    automake autoconf unzip sox libtool subversion \\\n    python3 python \\\n    git zlib1g-dev\n```\n\nDownload Kaldi and extract it:\n\n```bash\nwget -O kaldi-master.tar.gz \\\n    'https://github.com/kaldi-asr/kaldi/archive/master.tar.gz'\ntar -xvf kaldi-master.tar.gz\n```\n\nFirst, build Kaldi's tools:\n\n```bash\ncd kaldi-master/tools\nmake\n```\n\nUse `make -j 4` if you have multiple CPU cores. This will take a **long** time.\n\nNext, build Kaldi itself:\n\n```bash\ncd kaldi-master\n./configure --shared --mathlib=ATLAS\nmake depend\nmake\n```\n\nUse `make depend -j 4` and `make -j 4` if you have multiple CPU cores. This will take a **long** time.\n\nThere is no installation step. The `kaldi-master` directory contains all the libraries and programs that Rhasspy will need to access.\n\nSee [docker-kaldi](https://github.com/synesthesiam/docker-kaldi) for a Docker build script.\n\n### Phonetisaurus\n\nMake sure you have the necessary dependencies installed:\n\n```bash\nsudo apt-get install build-essential\n```\n\nFirst, download and build [OpenFST 1.6.2](http://www.openfst.org/)\n\n```bash\nwget http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.6.2.tar.gz\ntar -xvf openfst-1.6.2.tar.gz\ncd openfst-1.6.2\n./configure \\\n    \"--prefix=$(pwd)/build\" \\\n    --enable-static --enable-shared \\\n    --enable-far --enable-ngram-fsts\nmake\nmake install\n```\n\nUse `make -j 4` if you have multiple CPU cores. This will take a **long** time.\n\nNext, download and extract Phonetisaurus:\n\n```bash\nwget -O phonetisaurus-master.tar.gz \\\n    'https://github.com/AdolfVonKleist/Phonetisaurus/archive/master.tar.gz'\ntar -xvf phonetisaurus-master.tar.gz\n```\n\nFinally, build Phonetisaurus (where `/path/to/openfst` is the `openfst-1.6.2` directory from above):\n\n```\ncd Phonetisaurus-master\n./configure \\\n    --with-openfst-includes=/path/to/openfst/build/include \\\n    --with-openfst-libs=/path/to/openfst/build/lib\nmake\nmake install\n```\n\nUse `make -j 4` if you have multiple CPU cores. This will take a **long** time.\n\nYou should now be able to run the `phonetisaurus-align` program.\n\nSee [docker-phonetisaurus](https://github.com/synesthesiam/docker-phonetisaurus) for a Docker build script.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhasspy%2Frhasspy-asr-kaldi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhasspy%2Frhasspy-asr-kaldi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhasspy%2Frhasspy-asr-kaldi/lists"}