daanzu / kaldi-active-grammar

Python Kaldi speech recognition with grammars that can be set active/inactive dynamically at decode-time
GNU Affero General Public License v3.0
333 stars 49 forks source link

simple demo #7

Open dpny518 opened 4 years ago

dpny518 commented 4 years ago

Do you have a simple demo, like the one in dragonfly that doesn't require dragonfly? I just want to transcribe an audio file with grammar weights added to the language model

Thanks

daanzu commented 4 years ago

I have been meaning to add a simple example of direct usage, but haven't gotten around to it yet. You basically just need to build a graph describing your grammar and then call the decoding. Designing a good API for describing grammars more simply isn't easy.

Do you have an example of the grammar you want to decode with?

dpny518 commented 4 years ago

nothing specific just pick words from a word list

#JSGF V1.0;
grammar word;
public <wholeutt> = <words>+;
<words> = [sil] [word1] [ sil ] [word2] [ sil ] [word3] [ sil ] [word4] [ sil ] [word5] [ sil ] [word...] [ sil ];
daanzu commented 4 years ago

That would be easy to encode in an FST. But in general, it would probably be easier to go through the dragonfly backend, once I get wave file reading implemented.

daanzu commented 4 years ago

This is implemented in https://github.com/dictation-toolbox/dragonfly/pull/175 with KaldiEngine.recognize_wave_file().

I am leaving this open to remind me to implement something directly in this repo.