This repository has been archived on 2025-08-26. You can view files and clone it, but cannot push or open issues or pull requests.
Files
enginex_bi_series-sherpa-onnx/swift-api-examples/add-punctuations.swift
2024-07-15 15:30:40 +08:00

32 lines
864 B
Swift

func run() {
let model = "./sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12/model.onnx"
let modelConfig = sherpaOnnxOfflinePunctuationModelConfig(
ctTransformer: model,
numThreads: 1,
debug: 1,
provider: "cpu"
)
var config = sherpaOnnxOfflinePunctuationConfig(model: modelConfig)
let punct = SherpaOnnxOfflinePunctuationWrapper(config: &config)
let textList = [
"这是一个测试你好吗How are you我很好thank you are you ok谢谢你",
"我们都是木头人不会说话不会动",
"The African blogosphere is rapidly expanding bringing more voices online in the form of commentaries opinions analyses rants and poetry",
]
for i in 0..<textList.count {
let t = punct.addPunct(text: textList[i])
print("\nresult is:\n\(t)")
}
}
@main
struct App {
static func main() {
run()
}
}