Add Kotlin and Java API for online punctuation models (#1936)
This commit is contained in:
30
kotlin-api-examples/test_online_punctuation.kt
Normal file
30
kotlin-api-examples/test_online_punctuation.kt
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.k2fsa.sherpa.onnx
|
||||
|
||||
fun main() {
|
||||
testPunctuation()
|
||||
}
|
||||
|
||||
// https://github.com/k2-fsa/sherpa-onnx/releases/download/punctuation-models/sherpa-onnx-online-punct-en-2024-08-06.tar.bz2
|
||||
fun testPunctuation() {
|
||||
val config = OnlinePunctuationConfig(
|
||||
model=OnlinePunctuationModelConfig(
|
||||
cnnBilstm="./sherpa-onnx-online-punct-en-2024-08-06/model.int8.onnx",
|
||||
bpeVocab="./sherpa-onnx-online-punct-en-2024-08-06/bpe.vocab",
|
||||
numThreads=1,
|
||||
debug=true,
|
||||
provider="cpu",
|
||||
)
|
||||
)
|
||||
val punct = OnlinePunctuation(config = config)
|
||||
val sentences = arrayOf(
|
||||
"how are you doing fantastic thank you what is about you",
|
||||
"The African blogosphere is rapidly expanding bringing more voices online in the form of commentaries opinions analyses rants and poetry",
|
||||
)
|
||||
println("---")
|
||||
for (text in sentences) {
|
||||
val out = punct.addPunctuation(text)
|
||||
println("Input: $text")
|
||||
println("Output: $out")
|
||||
println("---")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user