alphacep / alphacep/vosk-api

Passing cyrillic words as a grammar does not match vocabulary

Offen
#1,276 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Jupyter Notebook
Sterne
15.1k
Forks
1.8k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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!

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.