alphacep / alphacep/vosk-api

Scrambled result on Chinese characters

Aperta
#2,047 1 commento 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

I was testing Vosk on my Java program, but when I invoke `recognizer.getResult()` or `recognizer.getPartialResult()`, it returned some scrambled words like these:

what I said: 而且这次乱的更奇怪了
returned result: 鑰屼笖 杩欎釜 涔� 寰� 鏇� 濂囨�� 浜�

Then I tried to resolve this problem, and created a function:
```java
private static String fixVoskResult(String result) {
try {
byte[] bytes = result.getBytes(Charset.forName("GBK"));

return new String(bytes, StandardCharsets.UTF_8);
} catch (Exception e) {
LOGGER.error("Error occurred while fixing Vosk result.", e);
return result;
}
}
```
Surely it can fix some words, but there are still a lot of '�?':

�? 视觉 识别 准确�? �? 第二�?
�? �? �?�? 偷看 �?�? 偷看 �? 叔叔 �?
这个 识别 准确�? �? �? �? �? �? �?

It seems that '�' is causing problem. When Java parsing result from JNI return value (GBK parsing UTF-8 represented bytes), this character is used to represent those unparsable bytes(this is an unicode feature). So there are already broken bytes in returned result. That is why there are still some '�?' in fixed result.

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.