Add Kotlin and Java API for online punctuation models (#1936)

This commit is contained in:
Fangjun Kuang
2025-02-27 16:52:36 +08:00
committed by GitHub
parent 815ebac8f9
commit f5dfcf8d2f
16 changed files with 474 additions and 13 deletions

View 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("---")
}
}