Beispiel #1
0
void TalkGenerator::ttsEntryPoint(TalkEntry& entry)
{
    if (!entry.voiced && !entry.toSpeak.isEmpty())
    {
        QString error;
        qDebug() << "[TalkGen] voicing: " << entry.toSpeak << "to" << entry.wavfilename;
        TTSStatus status = entry.refs.tts->voice(entry.toSpeak,entry.wavfilename, &error);
        if (status == Warning || status == FatalError)
        {
            entry.refs.generator->ttsFailEntry(entry, status, error);
            return;
        }
        if (entry.refs.wavtrim != -1)
        {
            char buffer[255];
            wavtrim(entry.wavfilename.toLocal8Bit().data(), entry.refs.wavtrim, buffer, 255);
        }
        entry.voiced = true;
    }
}
Beispiel #2
0
//! \brief Voices a List of string
//!
TalkGenerator::Status TalkGenerator::voiceList(QList<TalkEntry>* list,int wavtrimth)
{
    int progressMax = list->size();
    int m_progress = 0;
    emit logProgress(m_progress,progressMax);

    QStringList errors;
    QStringList dublicates;

    bool warnings = false;
    for(int i=0; i < list->size(); i++)
    {
        if(m_abort)
        {
            emit logItem(tr("Voicing aborted"), LOGERROR);
            return eERROR;
        }

        // skip dublicated wav entrys
        if(!dublicates.contains(list->at(i).wavfilename))
            dublicates.append(list->at(i).wavfilename);
        else
        {
            qDebug() << "dublicate skipped";
            (*list)[i].voiced = true;
            emit logProgress(++m_progress,progressMax);
            continue;
        }

        // skip already voiced entrys
        if(list->at(i).voiced == true)
        {
            emit logProgress(++m_progress,progressMax);
            continue;
        }
        // skip entry whith empty text
        if(list->at(i).toSpeak == "")
        {
            emit logProgress(++m_progress,progressMax);
            continue;
        }

        // voice entry
        QString error;
        qDebug() << "voicing: " << list->at(i).toSpeak << "to" << list->at(i).wavfilename;
        TTSStatus status = m_tts->voice(list->at(i).toSpeak,list->at(i).wavfilename, &error);
        if(status == Warning)
        {
            warnings = true;
            emit logItem(tr("Voicing of %1 failed: %2").arg(list->at(i).toSpeak).arg(error),
                    LOGWARNING);
        }
        else if (status == FatalError)
        {
            emit logItem(tr("Voicing of %1 failed: %2").arg(list->at(i).toSpeak).arg(error),
                    LOGERROR);
            return eERROR;
        }
        else
           (*list)[i].voiced = true;

        //wavetrim if needed
        if(wavtrimth != -1)
        {
            char buffer[255];
            wavtrim(list->at(i).wavfilename.toLocal8Bit().data(),wavtrimth,buffer,255);
        }

        emit logProgress(++m_progress,progressMax);
        QCoreApplication::processEvents();
    }
    if(warnings)
        return eWARNING;
    else
        return eOK;
}