Passing cyrillic words as a grammar does not match vocabulary
- 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ả
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!
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á.