Inverse text normalization API of streaming ASR for various programming languages (#1022)
This commit is contained in:
@@ -196,6 +196,9 @@ class MainActivity : AppCompatActivity() {
|
||||
// See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
|
||||
// for a list of available models
|
||||
val type = 0
|
||||
var ruleFsts : String?
|
||||
ruleFsts = null
|
||||
|
||||
Log.i(TAG, "Select model type $type")
|
||||
val config = OnlineRecognizerConfig(
|
||||
featConfig = getFeatureConfig(sampleRate = sampleRateInHz, featureDim = 80),
|
||||
@@ -205,6 +208,10 @@ class MainActivity : AppCompatActivity() {
|
||||
enableEndpoint = true,
|
||||
)
|
||||
|
||||
if (ruleFsts != null) {
|
||||
config.ruleFsts = ruleFsts
|
||||
}
|
||||
|
||||
recognizer = OnlineRecognizer(
|
||||
assetManager = application.assets,
|
||||
config = config,
|
||||
|
||||
@@ -194,6 +194,8 @@ class MainActivity : AppCompatActivity() {
|
||||
// See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
|
||||
// for a list of available models
|
||||
val firstType = 9
|
||||
val firstRuleFsts: String?
|
||||
firstRuleFsts = null
|
||||
Log.i(TAG, "Select model type $firstType for the first pass")
|
||||
val config = OnlineRecognizerConfig(
|
||||
featConfig = getFeatureConfig(sampleRate = sampleRateInHz, featureDim = 80),
|
||||
@@ -201,6 +203,9 @@ class MainActivity : AppCompatActivity() {
|
||||
endpointConfig = getEndpointConfig(),
|
||||
enableEndpoint = true,
|
||||
)
|
||||
if (firstRuleFsts != null) {
|
||||
config.ruleFsts = firstRuleFsts;
|
||||
}
|
||||
|
||||
onlineRecognizer = OnlineRecognizer(
|
||||
assetManager = application.assets,
|
||||
@@ -213,6 +218,8 @@ class MainActivity : AppCompatActivity() {
|
||||
// See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
|
||||
// for a list of available models
|
||||
val secondType = 0
|
||||
var secondRuleFsts: String?
|
||||
secondRuleFsts = null
|
||||
Log.i(TAG, "Select model type $secondType for the second pass")
|
||||
|
||||
val config = OfflineRecognizerConfig(
|
||||
@@ -220,6 +227,10 @@ class MainActivity : AppCompatActivity() {
|
||||
modelConfig = getOfflineModelConfig(type = secondType)!!,
|
||||
)
|
||||
|
||||
if (secondRuleFsts != null) {
|
||||
config.ruleFsts = secondRuleFsts
|
||||
}
|
||||
|
||||
offlineRecognizer = OfflineRecognizer(
|
||||
assetManager = application.assets,
|
||||
config = config,
|
||||
|
||||
@@ -200,12 +200,17 @@ class MainActivity : AppCompatActivity() {
|
||||
// See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
|
||||
// for a list of available models
|
||||
val asrModelType = 0
|
||||
val asrRuleFsts: String?
|
||||
asrRuleFsts = null
|
||||
Log.i(TAG, "Select model type ${asrModelType} for ASR")
|
||||
|
||||
val config = OfflineRecognizerConfig(
|
||||
featConfig = getFeatureConfig(sampleRate = sampleRateInHz, featureDim = 80),
|
||||
modelConfig = getOfflineModelConfig(type = asrModelType)!!,
|
||||
)
|
||||
if (asrRuleFsts != null) {
|
||||
config.ruleFsts = asrRuleFsts;
|
||||
}
|
||||
|
||||
offlineRecognizer = OfflineRecognizer(
|
||||
assetManager = application.assets,
|
||||
|
||||
Reference in New Issue
Block a user