alphacep / alphacep/vosk-api

Support for domain-specific grammars

Đang mở
#55 36 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Jupyter Notebook
Star
15.1k
Fork
1.8k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.