Add WearOS demo for audio tagging (#777)
This commit is contained in:
@@ -103,14 +103,14 @@ class AudioTagging(
|
||||
//
|
||||
// See also
|
||||
// https://k2-fsa.github.io/sherpa/onnx/audio-tagging/
|
||||
fun getAudioTaggingConfig(type: Int): AudioTaggingConfig? {
|
||||
fun getAudioTaggingConfig(type: Int, numThreads: Int=1): AudioTaggingConfig? {
|
||||
when (type) {
|
||||
0 -> {
|
||||
val modelDir = "sherpa-onnx-zipformer-small-audio-tagging-2024-04-15"
|
||||
return AudioTaggingConfig(
|
||||
model = AudioTaggingModelConfig(
|
||||
zipformer = OfflineZipformerAudioTaggingModelConfig(model = "$modelDir/model.int8.onnx"),
|
||||
numThreads = 1,
|
||||
numThreads = numThreads,
|
||||
debug = true,
|
||||
),
|
||||
labels = "$modelDir/class_labels_indices.csv",
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.k2fsa.sherpa.onnx.audio.tagging
|
||||
import android.content.res.AssetManager
|
||||
import android.util.Log
|
||||
import com.k2fsa.sherpa.onnx.AudioTagging
|
||||
import com.k2fsa.sherpa.onnx.audio.tagging.wear.os.presentation.TAG
|
||||
import com.k2fsa.sherpa.onnx.getAudioTaggingConfig
|
||||
|
||||
object Tagger {
|
||||
@@ -11,14 +12,14 @@ object Tagger {
|
||||
get() {
|
||||
return _tagger!!
|
||||
}
|
||||
fun initTagger(assetManager: AssetManager? = null) {
|
||||
fun initTagger(assetManager: AssetManager? = null, numThreads: Int = 1) {
|
||||
synchronized(this) {
|
||||
if (_tagger != null) {
|
||||
return
|
||||
}
|
||||
|
||||
Log.i(TAG, "Initializing audio tagger")
|
||||
val config = getAudioTaggingConfig(type = 0)!!
|
||||
val config = getAudioTaggingConfig(type = 0, numThreads=numThreads)!!
|
||||
_tagger = AudioTagging(assetManager, config)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">SherpaOnnxAudioTagging</string>
|
||||
</resources>
|
||||
<string name="app_name">Audio Tagging</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user