alphacep / alphacep/vosk-api

Support for domain-specific grammars

Ouverte
#55 36 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
Langage dominant
Jupyter Notebook
Étoiles
15.1k
Forks
1.8k
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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?

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.