-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpunctuate.rs
34 lines (29 loc) · 1.45 KB
/
punctuate.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
We assume you have pre-downloaded the model files for testing
from https://github.com/k2-fsa/sherpa-onnx/releases/tag/punctuation-models
wget https://github.com/k2-fsa/sherpa-onnx/releases/download/punctuation-models/sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2
tar xvf sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2
rm sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12.tar.bz2
cargo run --example punctuate ./sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12/model.onnx
*/
fn main() {
let args: Vec<String> = std::env::args().collect();
let model = args.get(1).expect("Please specify model path");
let sentences = [
"这是一个测试你好吗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"
];
let config = sherpa_rs::punctuate::PunctuationConfig {
model: model.into(),
..Default::default()
};
let mut punctuate = sherpa_rs::punctuate::Punctuation::new(config).unwrap();
println!("--------------------");
for sentence in sentences {
let punctuated = punctuate.add_punctuation(sentence);
println!("Input text: {}", sentence);
println!("Output text: {}", punctuated);
println!("--------------------");
}
}