Adding new words to an existing model

323 views
Skip to first unread message

Olli Sagittarius

unread,
Aug 3, 2021, 7:34:26 AM8/3/21
to kaldi-help
Hello all,

I've posted this in another thread, but I don't seem to be getting any reactions and I was adviced to start a new thread.

I want to add new words to an existing and working open-source kaldi speech to text model. Here is the link to the package I am using: https://github.com/opensource-spraakherkenning-nl/Kaldi_NL

I got this package working using the "oralhistory" option that downloads pretrained models. Using those I decoded various audio files. It's pretty accurate, however I want to improve one of these models by adding new words. The phones of the model are solid and I should be able to add new words using the existing phones.

I found this thread explaining how to do it: https://github.com/kaldi-asr/kaldi/issues/720

According to the thread I had to do the following:
"for adding new word into the lexicon, you don't have to retrain the AM you'd just run mkgraph.sh with different lexicon directory (the one with the updated lexicon)"

And that's where I got stuck and have the following questions:
  • How do I add new words to an existing model? (please describe step by step)
If the thread is correct then I have the follow up questions:
  • Which lexicon file do I need to edit? I found different ones:
    • lexicon.txt
    • lexiconp.txt
    • lexicon.lex
  • Is editting the lexicon file sufficiënt or do I need to edit different files?
  • After editting the files do I just run mkgraph.sh? Or is there a different way?
The folder structure can be found on the github page of Kaldi_NL. Here's roughly the locations:
  • Acousting model: Kaldi_NL\models\AM
  • Language model: Kaldi_NL\models\Lang (contains G.fst, L.fst)
  • Lexicon.txt: Kaldi_NL\models\Lang\langtemp\lexicon.txt
  • Graph: Kaldi_NL\models\AM\graph
  • the phones folder exists in two folders, why?: 
    • Kaldi_NL\models\AM\graph\phones
    • Kaldi_NL\models\Lang\phones
  • words.txt and phones.txt exist in various locations. But again in both AM and Lang folders:
    • Kaldi_NL\models\AM\graph\words.txt
    • Kaldi_NL\models\AM\graph\phones.txt
    • Kaldi_NL\models\Lang\graph\words.txt
    • Kaldi_NL\models\Lang\graph\phones.txt
Now where stuff gets confusing is that there is also a LM folder in the models folder. Supposedly that's the Language Model? Which one is the language model, the Lang or LM folder?
  • Kaldi_NL\models\LM\Const <- (Contains G.carpa, L.fst , phones folder, phones.txt, words.txt and more)
Moving on:

So when I ran mkgraph.sh it gave the following error:
line 75: tree-info command not found
Error when getting context-width

That's a PATH error most likely. My guess is that it's happening because Kaldi_NL is expecting me to run mkgraph.sh through a different file, most likely: configure.sh in the base folder. The configure.sh runs three different files:
  • configure_basic.sh
  • configure_decode.sh
  • configure_download.sh
The configure_basic supposedly sets up kaldi _root. Check the code out here
I already ran the configure.sh when setting up, it was succesfull.

However, when I run echo $KALDI_ROOT I get nothing. But I can decode audio. My best guess is that the decode process uses a different way of getting the root pathway.

Lastly, I think I need the configure_decode.sh to add new words, but I could be wrong. Here is the link to the code. It seems to only select models instead of creating stuff.

So anyway, that's how far I've come. I feel I'm very close to cracking this problem. I really want to solve this, could you please help me?


Reply all
Reply to author
Forward
0 new messages