alphacep / alphacep/vosk-api

Scrambled result on Chinese characters

Ouverte
#2,047 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Jupyter Notebook
Étoiles
15.1k
Forks
1.8k
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.