alphacep / vosk-android-demo

Offline speech recognition for Android with Vosk library.
Apache License 2.0
740 stars 198 forks source link

When using Chinese model to identify audio files, all returned are empty #168

Open rancekk opened 2 years ago

rancekk commented 2 years ago

When using Chinese model to identify audio files, all returned are empty

nimyyshu commented 1 year ago
  1. replace the 10001-xxxxx-xxxxx.wav audio file with a Chinese Language version(the sound content should be Mandarin);
  2. modify java source code:

import java.nio.charset.StandardCharsets; ... String chineseString = "[\"一 零 零 零 一\", " + "\"幺 零 一 二 三 四 五 六 七 八 九\", \"[unk]\"]"; byte[] chineseBytesArray = chineseString.getBytes(); String encodedChineseString = new String(chineseBytesArray, StandardCharsets.UTF_8); Recognizer rec = new Recognizer(model, 16000.f, encodedChineseString); // Recognizer rec = new Recognizer(model, 16000.f, "[\"one zero zero zero one\", " + // "\"oh zero one two three four five six seven eight nine\", \"[unk]\"]");

reference: UTF-8 java string