Skip to content

Commit 8637f0d

Browse files
committed
sense_voice add hotwords
1 parent 95714db commit 8637f0d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

crates/sherpa-rs/src/sense_voice.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ pub struct SenseVoiceConfig {
1818
pub num_threads: Option<i32>,
1919
pub debug: bool,
2020
pub tokens: String,
21+
pub hotwords_file: Option<String>,
22+
pub hotwords_score: Option<f32>,
2123
}
2224

2325
impl Default for SenseVoiceConfig {
@@ -30,6 +32,8 @@ impl Default for SenseVoiceConfig {
3032
num_threads: Some(1),
3133
debug: false,
3234
tokens: String::new(),
35+
hotwords_file: None,
36+
hotwords_score: Some(0.0),
3337
}
3438
}
3539
}
@@ -92,15 +96,20 @@ impl SenseVoiceRecognizer {
9296
},
9397
};
9498

99+
let hotwords_score = config.hotwords_score.unwrap_or(0.0);
100+
let hotwords_file_cstr = config.hotwords_file.map(|f| cstring_from_str(&f));
95101
// Recognizer config
96102
let config = sherpa_rs_sys::SherpaOnnxOfflineRecognizerConfig {
97103
decoding_method: null(),
98104
feat_config: sherpa_rs_sys::SherpaOnnxFeatureConfig {
99105
sample_rate: 16000,
100106
feature_dim: 80,
101107
},
102-
hotwords_file: null(),
103-
hotwords_score: 0.0,
108+
hotwords_file: hotwords_file_cstr
109+
.as_ref()
110+
.map(|c| c.as_ptr())
111+
.unwrap_or(null()),
112+
hotwords_score,
104113
lm_config: sherpa_rs_sys::SherpaOnnxOfflineLMConfig {
105114
model: null(),
106115
scale: 0.0,

examples/tts_kokoro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727

2828
let sid = 0;
2929
let text = "This is generated by next generation Kaldi using Kokoro without Misaki.";
30-
let audio = tts.create(&text, sid, 1.0).unwrap();
30+
let audio = tts.create(text, sid, 1.0).unwrap();
3131
sherpa_rs::write_audio_file("audio.wav", &audio.samples, audio.sample_rate).unwrap();
3232
println!("Created audio.wav")
3333
}

0 commit comments

Comments
 (0)