alphacep / alphacep/vosk-api

Support for domain-specific grammars

Abierto
#55 36 comentarios 1 reacción 0 asignados Ver en GitHub
Lenguaje dominante
Jupyter Notebook
Estrellas
15.1k
Forks
1.8k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.