alphacep / alphacep/vosk-api

Passing cyrillic words as a grammar does not match vocabulary

Aperta
#1,276 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Jupyter Notebook
Stelle
15.1k
Fork
1.8k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hello there,

I am using C# with Vosk, and trying to set specific grammar in cyrillic characters.

First of all, this will not work:
```csharp
var recognizer = new VoskRecognizer(model, SampleRate, "[\"привет\"]");
```
Reason is that `string` does not play well with `const char*` for non-ascii symbols I believe - in Vosk logs you will get:
```
LOG (VoskAPI:Recognizer():recognizer.cc:63) ["яЁштхЄ"]
WARNING (VoskAPI:Recognizer():recognizer.cc:84) Ignoring word missing in vocabulary: 'яЁштхЄ'
```

Now, let's try to pass same text as unicode escaped:
```csharp
var grammar = JsonSerializer.Serialize(new[] { "привет" }); // grammar is ["\u043F\u0440\u0438\u0432\u0435\u0442"]
var recognizer = new VoskRecognizer(model, SampleRate, grammar);
```
Now encoded chars are passed properly, but text is not decoded and not found in text model I believe. Logs:
```
LOG (VoskAPI:Recognizer():recognizer.cc:63) ["\\u043F\\u0440\\u0438\\u0432\\u0435\\u0442"]
WARNING (VoskAPI:Recognizer():recognizer.cc:84) Ignoring word missing in vocabulary: '\\u043F\\u0440\\u0438\\u0432\\u0435\\u0442'
```

Although obvoiusly "привет" is there (in vocabulary).

Not sure if this is a bug/missing feature, or I am just missing something - could you give some thoughts @nshmyrev ?

P.S. I tried to make calls to native API directly with PInvoke, marshalling string in different ways or even passing bytes directly in different encodings, but could not find working way to go. But there should be some, because there are models with non-ascii chars in language.

Thanks in advance!

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.