diff --git a/CMakeLists.txt b/CMakeLists.txt index 845d300eb..294dc9daf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.13 FATAL_ERROR) project(sherpa-onnx) -set(SHERPA_ONNX_VERSION "1.4.5") +set(SHERPA_ONNX_VERSION "1.4.6") # Disable warning about # diff --git a/android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx/MainActivity.kt b/android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx/MainActivity.kt index f8822a795..d8d7d4a9f 100644 --- a/android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx/MainActivity.kt +++ b/android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx/MainActivity.kt @@ -177,7 +177,7 @@ class MainActivity : AppCompatActivity() { // Please change getModelConfig() to add new models // See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html // for a list of available models - val type = 0 + val type = 3 println("Select model type ${type}") val config = OnlineRecognizerConfig( featConfig = getFeatureConfig(sampleRate = sampleRateInHz, featureDim = 80), diff --git a/android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx/SherpaOnnx.kt b/android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx/SherpaOnnx.kt index d3133829a..0fb5fe240 100644 --- a/android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx/SherpaOnnx.kt +++ b/android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx/SherpaOnnx.kt @@ -19,7 +19,7 @@ data class OnlineTransducerModelConfig( var decoder: String, var joiner: String, var tokens: String, - var numThreads: Int = 2, + var numThreads: Int = 1, var debug: Boolean = false, ) @@ -122,6 +122,9 @@ by following the code) 2 - csukuangfj/sherpa-onnx-lstm-en-2023-02-17 (English) https://k2-fsa.github.io/sherpa/onnx/pretrained_models/lstm-transducer-models.html#csukuangfj-sherpa-onnx-lstm-en-2023-02-17-english + +3 - pkufool/icefall-asr-zipformer-streaming-wenetspeech-20230615 + https://huggingface.co/pkufool/icefall-asr-zipformer-streaming-wenetspeech-20230615 */ fun getModelConfig(type: Int): OnlineTransducerModelConfig? { when (type) { @@ -153,6 +156,26 @@ fun getModelConfig(type: Int): OnlineTransducerModelConfig? { tokens = "$modelDir/tokens.txt", ) } + + 3 -> { + val modelDir = "icefall-asr-zipformer-streaming-wenetspeech-20230615" + return OnlineTransducerModelConfig( + encoder = "$modelDir/exp/encoder-epoch-12-avg-4-chunk-16-left-128.int8.onnx", + decoder = "$modelDir/exp/decoder-epoch-12-avg-4-chunk-16-left-128.onnx", + joiner = "$modelDir/exp/joiner-epoch-12-avg-4-chunk-16-left-128.onnx", + tokens = "$modelDir/data/lang_char/tokens.txt", + ) + } + + 4 -> { + val modelDir = "icefall-asr-zipformer-streaming-wenetspeech-20230615" + return OnlineTransducerModelConfig( + encoder = "$modelDir/exp/encoder-epoch-12-avg-4-chunk-16-left-128.onnx", + decoder = "$modelDir/exp/decoder-epoch-12-avg-4-chunk-16-left-128.onnx", + joiner = "$modelDir/exp/joiner-epoch-12-avg-4-chunk-16-left-128.onnx", + tokens = "$modelDir/data/lang_char/tokens.txt", + ) + } } return null; } diff --git a/build-android-arm64-v8a.sh b/build-android-arm64-v8a.sh index 671c3942b..7090db4fe 100755 --- a/build-android-arm64-v8a.sh +++ b/build-android-arm64-v8a.sh @@ -74,6 +74,7 @@ cmake -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake" -DSHERPA_ONNX_ENABLE_CHECK=OFF \ -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ -DSHERPA_ONNX_ENABLE_JNI=ON \ + -DSHERPA_ONNX_ENABLE_C_API=OFF \ -DCMAKE_INSTALL_PREFIX=./install \ -DANDROID_ABI="arm64-v8a" \ -DANDROID_PLATFORM=android-21 .. diff --git a/build-android-armv7-eabi.sh b/build-android-armv7-eabi.sh index 0e9819792..ad754794f 100755 --- a/build-android-armv7-eabi.sh +++ b/build-android-armv7-eabi.sh @@ -74,6 +74,7 @@ cmake -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake" -DSHERPA_ONNX_ENABLE_CHECK=OFF \ -DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \ -DSHERPA_ONNX_ENABLE_JNI=ON \ + -DSHERPA_ONNX_ENABLE_C_API=OFF \ -DCMAKE_INSTALL_PREFIX=./install \ -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON \ -DANDROID_PLATFORM=android-21 .. diff --git a/ios-swift/SherpaOnnx/SherpaOnnx/Model.swift b/ios-swift/SherpaOnnx/SherpaOnnx/Model.swift index 6c5b59997..4aeb97a95 100644 --- a/ios-swift/SherpaOnnx/SherpaOnnx/Model.swift +++ b/ios-swift/SherpaOnnx/SherpaOnnx/Model.swift @@ -30,6 +30,51 @@ func getBilingualStreamZhEnZipformer20230220() -> SherpaOnnxOnlineTransducerMode ) } +func getZhZipformer20230615() -> SherpaOnnxOnlineTransducerModelConfig { + let encoder = getResource("encoder-epoch-12-avg-4-chunk-16-left-128", "onnx") + let decoder = getResource("decoder-epoch-12-avg-4-chunk-16-left-128", "onnx") + let joiner = getResource("joiner-epoch-12-avg-4-chunk-16-left-128", "onnx") + let tokens = getResource("tokens", "txt") + + return sherpaOnnxOnlineTransducerModelConfig( + encoder: encoder, + decoder: decoder, + joiner: joiner, + tokens: tokens, + numThreads: 2 + ) +} + +func getZhZipformer20230615Int8() -> SherpaOnnxOnlineTransducerModelConfig { + let encoder = getResource("encoder-epoch-12-avg-4-chunk-16-left-128.int8", "onnx") + let decoder = getResource("decoder-epoch-12-avg-4-chunk-16-left-128", "onnx") + let joiner = getResource("joiner-epoch-12-avg-4-chunk-16-left-128", "onnx") + let tokens = getResource("tokens", "txt") + + return sherpaOnnxOnlineTransducerModelConfig( + encoder: encoder, + decoder: decoder, + joiner: joiner, + tokens: tokens, + numThreads: 2 + ) +} + +func getEnZipformer20230626() -> SherpaOnnxOnlineTransducerModelConfig { + let encoder = getResource("encoder-epoch-99-avg-1-chunk-16-left-128", "onnx") + let decoder = getResource("decoder-epoch-99-avg-1-chunk-16-left-128", "onnx") + let joiner = getResource("joiner-epoch-99-avg-1-chunk-16-left-128", "onnx") + let tokens = getResource("tokens", "txt") + + return sherpaOnnxOnlineTransducerModelConfig( + encoder: encoder, + decoder: decoder, + joiner: joiner, + tokens: tokens, + numThreads: 2 + ) +} + /// Please refer to /// https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html /// to add more models if you need diff --git a/ios-swift/SherpaOnnx/SherpaOnnx/ViewController.swift b/ios-swift/SherpaOnnx/SherpaOnnx/ViewController.swift index 963404b13..eb4706b61 100644 --- a/ios-swift/SherpaOnnx/SherpaOnnx/ViewController.swift +++ b/ios-swift/SherpaOnnx/SherpaOnnx/ViewController.swift @@ -85,7 +85,9 @@ class ViewController: UIViewController { // You can also modify Model.swift to add new pre-trained models from // https://k2-fsa.github.io/sherpa/ncnn/pretrained_models/index.html - let modelConfig = getBilingualStreamZhEnZipformer20230220() + // let modelConfig = getBilingualStreamZhEnZipformer20230220() + // let modelConfig = getZhZipformer20230615() + let modelConfig = getEnZipformer20230626() let featConfig = sherpaOnnxFeatureConfig( sampleRate: 16000,