Add CTC HLG decoding for JNI (#810)
This commit is contained in:
@@ -1,12 +1,25 @@
|
||||
package com.k2fsa.sherpa.onnx
|
||||
|
||||
fun main() {
|
||||
val recognizer = createOfflineRecognizer()
|
||||
val types = arrayOf(0, 2, 5, 6)
|
||||
for (type in types) {
|
||||
test(type)
|
||||
}
|
||||
}
|
||||
|
||||
val waveFilename = "./sherpa-onnx-streaming-zipformer-en-20M-2023-02-17/test_wavs/0.wav"
|
||||
fun test(type: Int) {
|
||||
val recognizer = createOfflineRecognizer(type)
|
||||
|
||||
val waveFilename = when (type) {
|
||||
0 -> "./sherpa-onnx-paraformer-zh-2023-03-28/test_wavs/0.wav"
|
||||
2 -> "./sherpa-onnx-whisper-tiny.en/test_wavs/0.wav"
|
||||
5 -> "./sherpa-onnx-zipformer-multi-zh-hans-2023-9-2/test_wavs/1.wav"
|
||||
6 -> "./sherpa-onnx-nemo-ctc-en-citrinet-512/test_wavs/8k.wav"
|
||||
else -> null
|
||||
}
|
||||
|
||||
val objArray = WaveReader.readWaveFromFile(
|
||||
filename = waveFilename,
|
||||
filename = waveFilename!!,
|
||||
)
|
||||
val samples: FloatArray = objArray[0] as FloatArray
|
||||
val sampleRate: Int = objArray[1] as Int
|
||||
@@ -22,10 +35,10 @@ fun main() {
|
||||
recognizer.release()
|
||||
}
|
||||
|
||||
fun createOfflineRecognizer(): OfflineRecognizer {
|
||||
fun createOfflineRecognizer(type: Int): OfflineRecognizer {
|
||||
val config = OfflineRecognizerConfig(
|
||||
featConfig = getFeatureConfig(sampleRate = 16000, featureDim = 80),
|
||||
modelConfig = getOfflineModelConfig(type = 2)!!,
|
||||
modelConfig = getOfflineModelConfig(type = type)!!,
|
||||
)
|
||||
|
||||
return OfflineRecognizer(config = config)
|
||||
|
||||
Reference in New Issue
Block a user