@@ -72,6 +72,12 @@ static int32_t AudioGeneratedCallback(const float *s, int32_t n) {
7272 return 1 ;
7373}
7474
75+ static int32_t AudioGeneratedProgressCallback (const float *s, int32_t n,
76+ float /* progress*/ ,
77+ void * /* arg*/ ) {
78+ return AudioGeneratedCallback (s, n);
79+ }
80+
7581static int PlayCallback (const void * /* in*/ , void *out,
7682 unsigned long _n, // NOLINT
7783 const PaStreamCallbackTimeInfo * /* time_info*/ ,
@@ -667,25 +673,32 @@ void CNonStreamingTextToSpeechDlg::OnBnClickedOk() {
667673
668674 // generate_btn_.EnableWindow(FALSE);
669675
670- const SherpaOnnxGeneratedAudio *audio =
671- SherpaOnnxOfflineTtsGenerateWithCallback (tts_, text.c_str (), speaker_id, speed, &AudioGeneratedCallback);
676+ SherpaOnnxGenerationConfig config = {0 };
677+ config.silence_scale = 0 .2f ;
678+ config.sid = speaker_id;
679+ config.speed = speed;
680+
681+ const SherpaOnnxGeneratedAudio *audio =
682+ SherpaOnnxOfflineTtsGenerateWithConfig (tts_, text.c_str (), &config,
683+ &AudioGeneratedProgressCallback,
684+ nullptr );
672685 // generate_btn_.EnableWindow(TRUE);
673686 g_stopped = true ;
674687
675- int ok = SherpaOnnxWriteWave (audio->samples , audio->n , audio->sample_rate ,
676- filename.c_str ());
688+ int ok = SherpaOnnxWriteWave (audio->samples , audio->n , audio->sample_rate ,
689+ filename.c_str ());
677690
678- SherpaOnnxDestroyOfflineTtsGeneratedAudio (audio);
691+ SherpaOnnxDestroyOfflineTtsGeneratedAudio (audio);
679692
680- if (ok) {
681- // AfxMessageBox(Utf8ToUtf16(std::string("Saved to ") + filename + " successfully").c_str(), MB_OK);
693+ if (ok) {
694+ // AfxMessageBox(Utf8ToUtf16(std::string("Saved to ") + filename + " successfully").c_str(), MB_OK);
682695
683- // AppendLineToMultilineEditCtrl(my_hint_, std::string("Saved to ") + filename + " successfully");
684- } else {
685- // AfxMessageBox(Utf8ToUtf16(std::string("Failed to save to ") + filename).c_str(), MB_OK);
696+ // AppendLineToMultilineEditCtrl(my_hint_, std::string("Saved to ") + filename + " successfully");
697+ } else {
698+ // AfxMessageBox(Utf8ToUtf16(std::string("Failed to save to ") + filename).c_str(), MB_OK);
686699
687- // AppendLineToMultilineEditCtrl(my_hint_, std::string("Failed to saved to ") + filename);
688- }
700+ // AppendLineToMultilineEditCtrl(my_hint_, std::string("Failed to saved to ") + filename);
701+ }
689702 });
690703
691704 // CDialogEx::OnOK();
0 commit comments