File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff 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
2325impl 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 ,
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments