alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
7.38k stars 1.04k forks source link

Garbled characters when using JNA:5.10.0+ #1449

Closed unknowIfGuestInDream closed 6 months ago

unknowIfGuestInDream commented 8 months ago

When I use java api and the jna version is 5.10.0+, the result is garbled, and it is normal when switching to 5.7.0 I want to know if this is a bug or if it requires me to make additional changes to the code?

Language: Eclipse Temurin JDK 17.0.8.1 Version:

Modal: vosk-model-small-cn-0.22 Code: Base from https://github.com/alphacep/vosk-api/blob/master/java/demo/src/main/java/org/vosk/demo/DecoderDemo.java

JNA 5.13.0 image

JNA 5.7.0 image

nshmyrev commented 8 months ago

What about 5.14 the latest version please?

unknowIfGuestInDream commented 8 months ago

What about 5.14 the latest version please?

Now the latest version of JNA is 5.13.0, and there is this problem.

unknowIfGuestInDream commented 6 months ago

What about 5.14 the latest version please?

5.14 still has this problem

unknowIfGuestInDream commented 6 months ago

I may have found the cause of the problem. https://github.com/java-native-access/jna/pull/1393/files#diff-2b1161da4142a2565bc95b82de87e04020a982e6dc03eb43e98247857f66fbe5R142 I have to set jna.encoding=UTF-8 before calling LibVosk (such as : LibVosk.setLogLevel(LogLevel.INFO);)

System.setProperty("jna.encoding", "UTF-8");

image

If you have no other comments, I will close this issue soon.