예제 #1
0
void TTSFestival::startServer()
{
    if(!configOk())
        return;

    if(serverProcess.state() != QProcess::Running)
    {
        QString path;
        /* currentPath is set by the GUI - if it's set, it is the currently set
         path in the configuration GUI; if it's not set, use the saved path */
        if (currentPath == "")
            path = RbSettings::subValue("festival-server",RbSettings::TtsPath).toString();
        else
            path = currentPath;

        serverProcess.start(QString("%1 --server").arg(path));
        serverProcess.waitForStarted();

        /* A friendlier version of a spinlock */
        while (serverProcess.pid() == 0 && serverProcess.state() != QProcess::Running)
            QCoreApplication::processEvents(QEventLoop::AllEvents, 50);

        if(serverProcess.state() == QProcess::Running)
            qDebug() << "[Festival] Server is up and running";
        else
            qDebug() << "[Festival] Server failed to start, state: " << serverProcess.state();
    }
}
예제 #2
0
QStringList TTSFestival::getVoiceList()
{
    if(!configOk())
        return QStringList();

    if(voices.size() > 0)
    {
        qDebug() << "[Festival] Using voice cache";
        return voices;
    }

    QString response = queryServer("(voice.list)", 10000);

    // get the 2nd line. It should be (<voice_name>, <voice_name>)
    response = response.mid(response.indexOf('\n') + 1, -1);
    response = response.left(response.indexOf('\n')).trimmed();

    voices = response.mid(1, response.size()-2).split(' ');

    voices.sort();
    if (voices.size() == 1 && voices[0].size() == 0)
        voices.removeAt(0);
    if (voices.size() > 0)
        qDebug() << "[Festival] Voices: " << voices;
    else
        qDebug() << "[Festival] No voices. Response was: " << response;

    return voices;
}
예제 #3
0
QString TTSFestival::getVoiceInfo(QString voice)
{
    if(!configOk())
        return "";

    if(!getVoiceList().contains(voice))
        return "";

    if(voiceDescriptions.contains(voice))
        return voiceDescriptions[voice];

    QString response = queryServer(QString("(voice.description '%1)").arg(voice),
                            10000);

    if (response == "")
    {
        voiceDescriptions[voice]=tr("No description available");
    }
    else
    {
        response = response.remove(QRegExp("(description \"*\")",
                    Qt::CaseInsensitive, QRegExp::Wildcard));
        qDebug() << "[Festival] voiceInfo w/o descr: " << response;
        response = response.remove(')');
        QStringList responseLines = response.split('(', QString::SkipEmptyParts);
        responseLines.removeAt(0); // the voice name itself

        QString description;
        foreach(QString line, responseLines)
        {
            line = line.remove('(');
            line = line.simplified();

            line[0] = line[0].toUpper(); // capitalize the key

            int firstSpace = line.indexOf(' ');
            if (firstSpace > 0)
            {
                // add a colon between the key and the value
                line = line.insert(firstSpace, ':');
                // capitalize the value
                line[firstSpace+2] = line[firstSpace+2].toUpper();
            }

            description += line + "\n";
        }
        voiceDescriptions[voice] = description.trimmed();
    }
예제 #4
0
void TTSFestival::startServer(QString path)
{
    if(!configOk())
        return;

    if(path == "")
        path = RbSettings::subValue("festival-server",RbSettings::TtsPath).toString();

    serverProcess.start(QString("%1 --server").arg(path));
    serverProcess.waitForStarted();

    queryServer("(getpid)",300,path);
    if(serverProcess.state() == QProcess::Running)
        qDebug() << "Festival is up and running";
    else
        qDebug() << "Festival failed to start";
}