TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr) { qDebug() << "[Festival] Voicing " << text << "->" << wavfile; QString path = RbSettings::subValue("festival-client", RbSettings::TtsPath).toString(); QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp" " --output \"%2\" --prolog \"%3\" - ").arg(path).arg(wavfile).arg(prologPath); qDebug() << "[Festival] Client cmd: " << cmd; QProcess clientProcess; clientProcess.start(cmd); clientProcess.write(QString("%1.\n").arg(text).toAscii()); clientProcess.waitForBytesWritten(); clientProcess.closeWriteChannel(); clientProcess.waitForReadyRead(); QString response = clientProcess.readAll(); response = response.trimmed(); if(!response.contains("Utterance")) { qDebug() << "[Festival] Could not voice string: " << response; *errStr = tr("engine could not voice string"); return Warning; /* do not stop the voicing process because of a single string TODO: needs proper settings */ } clientProcess.closeReadChannel(QProcess::StandardError); clientProcess.closeReadChannel(QProcess::StandardOutput); clientProcess.terminate(); clientProcess.kill(); return NoError; }
void ServerManager::startServer(int id) const { QStringList args = QCoreApplication::arguments(); args.removeFirst(); if (id < 0) { id = startCounter; } TWebApplication::MultiProcessingModule mpm = Tf::app()->multiProcessingModule(); if (mpm == TWebApplication::Hybrid || mpm == TWebApplication::Thread) { if (id < maxServers) { args.prepend(QString::number(id)); args.prepend("-i"); // give ID for app server } } if (listeningSocket > 0) { args.prepend(QString::number(listeningSocket)); args.prepend("-s"); } QProcess *tfserver = new QProcess; serversStatus.insert(tfserver, id); connect(tfserver, SIGNAL(started()), this, SLOT(updateServerStatus())); connect(tfserver, SIGNAL(error(QProcess::ProcessError)), this, SLOT(errorDetect(QProcess::ProcessError))); connect(tfserver, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(serverFinish(int, QProcess::ExitStatus))); connect(tfserver, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError())); // For error notification #if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) // Sets LD_LIBRARY_PATH environment variable QString ldpath = "."; // means the lib dir QString sysldpath = QProcess::systemEnvironment().filter("LD_LIBRARY_PATH=", Qt::CaseSensitive).value(0).mid(16); if (!sysldpath.isEmpty()) { ldpath += ":"; ldpath += sysldpath; } QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("LD_LIBRARY_PATH", ldpath); tSystemDebug("export %s=%s", "LD_LIBRARY_PATH", qPrintable(ldpath)); QString preload = Tf::appSettings()->value(Tf::LDPreload).toString(); if (!preload.isEmpty()) { env.insert("LD_PRELOAD", preload); tSystemDebug("export %s=%s", "LD_PRELOAD", qPrintable(preload)); } tfserver->setProcessEnvironment(env); #endif // Executes treefrog server tfserver->start(TFSERVER_CMD, args, QIODevice::ReadOnly); tfserver->closeReadChannel(QProcess::StandardOutput); tfserver->closeWriteChannel(); tSystemDebug("tfserver started"); ++startCounter; }
void QProcessProto::closeReadChannel(QProcess::ProcessChannel channel) { QProcess *item = qscriptvalue_cast<QProcess*>(thisObject()); if (item) item->closeReadChannel(channel); }
void US_Win::launch( int index ) { static const int trig_secs=3600; index -= P_CONFIG; QString pname = p[ index ].name; // At each launch, check for notices if last check was over 24 hours ago if ( ln_time.secsTo( QDateTime::currentDateTime() ) > trig_secs ) notice_check(); if ( p[ index ].maxRunCount <= p[ index ].currentRunCount && p[ index ].maxRunCount > 0 ) { if ( p[ index ].index == P_CONFIG ) { QMessageBox::information( this, tr( "Already Running" ), tr( "The configuration program is already running.\n" "Click on the task bar item named UltraScan " "Configuration to continue." ) ); } else { QMessageBox::warning( this, tr( "Error" ), pname + tr( " is already running." ) ); } return; } statusBar()->showMessage( tr( "Loading " ) + p[ index ].runningMsg + "..." ); QProcess* process = new QProcess( 0 ); process->closeReadChannel( QProcess::StandardOutput ); process->closeReadChannel( QProcess::StandardError ); connect ( process, SIGNAL( finished ( int, QProcess::ExitStatus ) ), this , SLOT ( terminated( int, QProcess::ExitStatus ) ) ); #ifndef Q_OS_MAC process->start( pname ); #else QString procbin = US_Settings::appBaseDir() + "/bin/" + pname; QString procapp = procbin + ".app"; if ( !QFile( procapp ).exists() ) procapp = procbin; process->start( "open", QStringList(procapp) ); #endif if ( ! process->waitForStarted( 10000 ) ) // 10 second timeout { QMessageBox::information( this, tr( "Error" ), tr( "There was a problem creating a subprocess\nfor " ) + pname ); } else { p[ index ].currentRunCount++; procData* pr = new procData; pr->proc = process; pr->name = pname; pr->index = index; procs << pr; } statusBar()->showMessage( tr( "Loaded " ) + p[ index ].runningMsg + "..." ); }