Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Apr 24, 2024
1 parent ec8cfac commit 61ae3f9
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/apk-asr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ jobs:
env:
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}

- name: Display APK for audio tagging after signing
- name: Display APK after signing
shell: bash
run: |
ls -lh ./apks/
du -h -d1 .
- name: Rename APK for audio tagging after signing
- name: Rename APK after signing
shell: bash
run: |
cd apks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class MainActivity : AppCompatActivity() {
// See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
// for a list of available models
val type = 0
println("Select model type $type")
Log.i(TAG, "Select model type $type")
val config = OnlineRecognizerConfig(
featConfig = getFeatureConfig(sampleRate = sampleRateInHz, featureDim = 80),
modelConfig = getModelConfig(type = type)!!,
Expand Down
4 changes: 2 additions & 2 deletions android/SherpaOnnx2Pass/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:label="Next-gen Kaldi: Two-pass ASR"
android:label="2pass ASR: Next-gen Kaldi"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -30,4 +30,4 @@
</activity>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class MainActivity : AppCompatActivity() {
// See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
// for a list of available models
val firstType = 9
println("Select model type $firstType for the first pass")
Log.i(TAG, "Select model type $firstType for the first pass")
val config = OnlineRecognizerConfig(
featConfig = getFeatureConfig(sampleRate = sampleRateInHz, featureDim = 80),
modelConfig = getModelConfig(type = firstType)!!,
Expand All @@ -213,7 +213,7 @@ class MainActivity : AppCompatActivity() {
// See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
// for a list of available models
val secondType = 0
println("Select model type $secondType for the second pass")
Log.i(TAG, "Select model type $secondType for the second pass")

val config = OfflineRecognizerConfig(
featConfig = getFeatureConfig(sampleRate = sampleRateInHz, featureDim = 80),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ class MainActivity : AppCompatActivity() {


private fun copyDataDir(dataDir: String): String {
println("data dir is $dataDir")
Log.i(TAG, "data dir is $dataDir")
copyAssets(dataDir)

val newDataDir = application.getExternalFilesDir(null)!!.absolutePath
println("newDataDir: $newDataDir")
Log.i(TAG, "newDataDir: $newDataDir")
return newDataDir
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,14 @@ class OfflineTts(
}

protected fun finalize() {
delete(ptr)
if (ptr != 0L) {
delete(ptr)
ptr = 0
}
}

fun release() = finalize()

private external fun newFromAsset(
assetManager: AssetManager,
config: OfflineTtsConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ object TtsEngine {


private fun copyDataDir(context: Context, dataDir: String): String {
println("data dir is $dataDir")
Log.i(TAG, "data dir is $dataDir")
copyAssets(context, dataDir)

val newDataDir = context.getExternalFilesDir(null)!!.absolutePath
println("newDataDir: $newDataDir")
Log.i(TAG, "newDataDir: $newDataDir")
return newDataDir
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class MainActivity : AppCompatActivity() {

private fun initVadModel() {
val type = 0
println("Select VAD model type ${type}")
Log.i(TAG, "Select VAD model type ${type}")
val config = getVadModelConfig(type)

vad = Vad(
Expand Down Expand Up @@ -174,4 +174,4 @@ class MainActivity : AppCompatActivity() {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class MainActivity : AppCompatActivity() {

private fun initVadModel() {
val type = 0
println("Select VAD model type ${type}")
Log.i(TAG, "Select VAD model type ${type}")
val config = getVadModelConfig(type)

vad = Vad(
Expand Down Expand Up @@ -201,7 +201,7 @@ class MainActivity : AppCompatActivity() {
// See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
// for a list of available models
val secondType = 0
println("Select model type ${secondType} for the second pass")
Log.i(TAG, "Select model type ${secondType} for the second pass")

val config = OfflineRecognizerConfig(
featConfig = getFeatureConfig(sampleRate = sampleRateInHz, featureDim = 80),
Expand All @@ -219,6 +219,7 @@ class MainActivity : AppCompatActivity() {
stream.acceptWaveform(samples, sampleRateInHz)
offlineRecognizer.decode(stream)
val result = offlineRecognizer.getResult(stream)
stream.release()
return result.text
}
}
}
2 changes: 2 additions & 0 deletions kotlin-api-examples/test_language_id.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ fun testSpokenLanguageIdentifcation() {
println(waveFilename)
println(lang)
}

slid.release()
}

1 change: 1 addition & 0 deletions kotlin-api-examples/test_speaker_id.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fun testSpeakerRecognition() {
check(name.length == 0)

manager.release()
extractor.release()
println("Speaker ID test done!")
}

Expand Down
1 change: 1 addition & 0 deletions kotlin-api-examples/test_tts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fun testTts() {
val tts = OfflineTts(config=config)
val audio = tts.generateWithCallback(text="“Today as always, men fall into two groups: slaves and free men. Whoever does not have two-thirds of his day for himself, is a slave, whatever he may be: a statesman, a businessman, an official, or a scholar.”", callback=::callback)
audio.save(filename="test-en.wav")
tts.release()
println("Saved to test-en.wav")
}

Expand Down
2 changes: 1 addition & 1 deletion sherpa-onnx/jni/keyword-spotter.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// sherpa-onnx/csrc/keyword-spotter.cc
// sherpa-onnx/jni/keyword-spotter.cc
//
// Copyright (c) 2024 Xiaomi Corporation

Expand Down
2 changes: 1 addition & 1 deletion sherpa-onnx/jni/offline-recognizer.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// sherpa-onnx/csrc/offline-recognizer.h
// sherpa-onnx/jni/offline-recognizer.cc
//
// Copyright (c) 2024 Xiaomi Corporation

Expand Down
2 changes: 1 addition & 1 deletion sherpa-onnx/jni/online-recognizer.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// sherpa-onnx/csrc/online-recognizer.cc
// sherpa-onnx/jni/online-recognizer.cc
//
// Copyright (c) 2024 Xiaomi Corporation

Expand Down
2 changes: 1 addition & 1 deletion sherpa-onnx/jni/voice-activity-detector.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// sherpa-onnx/jni/voice-activity-detector.h"
// sherpa-onnx/csrc/voice-activity-detector.cc
//
// Copyright (c) 2024 Xiaomi Corporation
#include "sherpa-onnx/csrc/voice-activity-detector.h"
Expand Down
6 changes: 4 additions & 2 deletions sherpa-onnx/kotlin-api/Speaker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ class SpeakerEmbeddingExtractor(
}

protected fun finalize() {
delete(ptr)
ptr = 0
if (ptr != 0L) {
delete(ptr)
ptr = 0
}
}

fun release() = finalize()
Expand Down

0 comments on commit 61ae3f9

Please sign in to comment.