更新 'src/Sound/flitevoice.cxx'

This commit is contained in:
zhongjin 2022-11-10 14:57:16 +08:00
parent c5800ff7af
commit 4c406324f4

View File

@ -23,6 +23,9 @@
# include "config.h" # include "config.h"
#endif #endif
#include <stdlib.h>
#include "flitevoice.hxx" #include "flitevoice.hxx"
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <simgear/sound/sample_group.hxx> #include <simgear/sound/sample_group.hxx>
@ -64,7 +67,22 @@ void FGFLITEVoice::speak(const string & msg)
// this is called from voice.cxx:FGVoiceMgr::FGVoiceThread::run // this is called from voice.cxx:FGVoiceMgr::FGVoiceThread::run
string s = simgear::strutils::strip(msg); string s = simgear::strutils::strip(msg);
if (!s.empty()) { if (!s.empty()) {
_sampleQueue.push(_synthesizer->synthesize(msg, 1.0, 0.5, 0.5));
//zhonjin
//_sampleQueue.push(_synthesizer->synthesize(msg, 1.0, 0.5, 0.5));
auto serverurl = fgGetString("/sim/sound/ttsurl");
if (!serverurl.empty() && fgGetBool("/sim/sound/voices/enabled",true)) {
SG_LOG(SG_SOUND, SG_INFO, "TTS Play '" << s << "'" );
string urlcmd = "ffplay -nodisp -autoexit -loglevel quiet -i ";
urlcmd.append("\"");
urlcmd.append(serverurl);
urlcmd.append("/speech/?str=");
urlcmd.append(msg);
urlcmd.append("\"");
system(urlcmd.c_str());
}
} }
} }