Scrambled result on Chinese characters
- Dominant language
- Jupyter Notebook
- Stars
- 15.1k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.