alphacep / alphacep/vosk-api

Support for domain-specific grammars

オープン
#55 コメント 36 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
Jupyter Notebook
スター
15.1k
フォーク
1.8k
PR マージ指標
30日以内にマージされた PR はありません

説明

It would be very convenient to be able to describe the space of possible outputs. This would be very useful for example in the domain of home automation, where the speaker is likely to say sentences such as, `turn {on,off} the {hallway,kitchen} lights`. Right now, using the full language model from [here](https://github.com/alphacep/kaldi-android-demo/releases), accuracy isn't very good. Intuitively, by limiting the grammar, accuracy could be improved.

It would be awesome if this could be done inside the library rather than offline using Kaldi command-line utilities, as described on the [Updating the Language Model](https://github.com/alphacep/vosk-api/blob/master/doc/adaptation.md) page.

I was wondering if that's something that you have planned for, given the addition of this bit of code in [kaldi_recognizer.cc](https://github.com/alphacep/vosk-api/blob/master/src/kaldi_recognizer.cc#L49-L86) which serves to limit the set of words from the full set included in the language model to just those in the string `grammar`:

```cpp
g_fst_.AddState();
g_fst_.SetStart(0);
g_fst_.AddState();
g_fst_.SetFinal(1, fst::TropicalWeight::One());
g_fst_.AddArc(1, StdArc(0, 0, fst::TropicalWeight::One(), 0));

// Create simple word loop FST
std::stringstream ss(grammar);
std::string token;

while (std::getline(ss, token, ' ')) {
int32 id = model_.word_syms_->Find(token);
g_fst_.AddArc(0, StdArc(id, id, fst::TropicalWeight::One(), 1));
}
ArcSort(&g_fst_, ILabelCompare());

decode_fst_ = LookaheadComposeFst(*model_.hcl_fst_, g_fst_, model_.disambig_);
```

Would it be possible to read the grammar from a [JSGF](https://en.wikipedia.org/wiki/JSGF) file or something like Rhasspy's `sentences.ini` (documented [here](https://rhasspy.readthedocs.io/en/latest/training/#sentencesini)) and construct the appropriate graph?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。