QStringList destroy my Voice Command , what is wrong?
-
I have to exec a QProcess comand but is not simple report escaped option ... on console run normal...
mac comand ( say -v "?" )
give me:
Whisper en_US # Pssssst, hey you, Yeah you, Who do ya think I'm talking to, the mouse?
Xander nl_NL # Hallo, mijn naam is Xander. Ik ben een Nederlandse stem.
Yannick de_DE # Hallo, ich heiße Yannick und ich bin eine deutsche Stimme.
Yelda tr_TR # Merhaba, benim adım Yelda. Ben Türkçe bir sesim.
Yuna ko_KR # 안녕하세요. 제 이름은 Yuna입니다. 저는 한국어 음성입니다.
Zarvox en_US # That looks like a peaceful planet.
Zosia pl_PL # Witaj. Mam na imię Zosia, jestem głosem kobiecym dla języka polskiego.
Zuzana cs_CZ # Dobrý den, jmenuji se Zuzana. Jsem český hlas.
..... ecc....
i not find it solution :-(i become:
("Voice `"?"' not found.")
("")void VoiceBlock::FillvaiableVoice() { QStringList cmd; //// mac comand ( say -v "?" ) cmd << QString("-v"); cmd << QByteArray("\"?\""); const QString litflat = say_comand_sdout(cmd); if (litflat.size() > 0) { QStringList linebyline = litflat.split(QString("\n")); for (int x = 0; x < linebyline.size(); x++) { QString liner =linebyline.at(x); QStringList dd = liner.trimmed().split(QString("\t")); SESSDEBUG() << dd; } } } QString VoiceBlock::say_comand_sdout( QStringList comandlist ) { SESSDEBUG() << __FUNCTION__ << " exec - #say " << comandlist; QString lstr; QString cmd=QString("say"); QProcess *process = new QProcess(NULL); process->setReadChannelMode(QProcess::MergedChannels); process->start(cmd,comandlist,QIODevice::ReadOnly ); if (!process->waitForFinished()) { lstr = QString(); } else { lstr = QString(process->readAll().constData()); } return lstr; }
-
You can't read from a finished program. you have to connect to
readyRead()
;replace
process->start(cmd,comandlist,QIODevice::ReadOnly ); if (!process->waitForFinished()) { lstr = QString(); } else { lstr = QString(process->readAll().constData()); } return lstr;
with
QObject::connect(process,&QProcess::readyReadStandardOutput,[&lstr,process]()->void{lstr.append(QString::fromLatin1(process->readAllStandardOutput()));}); process->start(cmd,comandlist,QIODevice::ReadOnly ); if (process->waitForFinished()) return lstr; return QString();