Fix modified beam search for iOS and android (#76)
* Use Int type for sampling rate * Fix swift * Fix iOS
This commit is contained in:
1
.github/scripts/.gitignore
vendored
1
.github/scripts/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
Makefile
|
||||
*.jar
|
||||
hs_err_pid*.log
|
||||
|
||||
19
.github/scripts/Main.kt
vendored
19
.github/scripts/Main.kt
vendored
@@ -4,7 +4,7 @@ import android.content.res.AssetManager
|
||||
|
||||
fun main() {
|
||||
var featConfig = FeatureConfig(
|
||||
sampleRate = 16000.0f,
|
||||
sampleRate = 16000,
|
||||
featureDim = 80,
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ fun main() {
|
||||
decoder = "./sherpa-onnx-streaming-zipformer-en-2023-02-21/decoder-epoch-99-avg-1.onnx",
|
||||
joiner = "./sherpa-onnx-streaming-zipformer-en-2023-02-21/joiner-epoch-99-avg-1.onnx",
|
||||
tokens = "./sherpa-onnx-streaming-zipformer-en-2023-02-21/tokens.txt",
|
||||
numThreads = 4,
|
||||
numThreads = 1,
|
||||
debug = false,
|
||||
)
|
||||
|
||||
@@ -24,22 +24,31 @@ fun main() {
|
||||
featConfig = featConfig,
|
||||
endpointConfig = endpointConfig,
|
||||
enableEndpoint = true,
|
||||
decodingMethod = "greedy_search",
|
||||
maxActivePaths = 4,
|
||||
)
|
||||
|
||||
var model = SherpaOnnx(
|
||||
assetManager = AssetManager(),
|
||||
config = config,
|
||||
)
|
||||
|
||||
var samples = WaveReader.readWave(
|
||||
assetManager = AssetManager(),
|
||||
filename = "./sherpa-onnx-streaming-zipformer-en-2023-02-21/test_wavs/1089-134686-0001.wav",
|
||||
)
|
||||
|
||||
model.decodeSamples(samples!!)
|
||||
model.acceptWaveform(samples!!, sampleRate=16000)
|
||||
while (model.isReady()) {
|
||||
model.decode()
|
||||
}
|
||||
|
||||
var tail_paddings = FloatArray(8000) // 0.5 seconds
|
||||
model.decodeSamples(tail_paddings)
|
||||
|
||||
model.acceptWaveform(tail_paddings, sampleRate=16000)
|
||||
model.inputFinished()
|
||||
while (model.isReady()) {
|
||||
model.decode()
|
||||
}
|
||||
|
||||
println("results: ${model.text}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user