Ejemplo n.º 1
0
bool SpeechData::readConfig(){
    // Load configuration
    delete config;
    //config = KGlobal::config();
    config = new KConfig("kttsdrc");

    // Set the group general for the configuration of KTTSD itself (no plug ins)
    config->setGroup("General");

    // Load the configuration of the text interruption messages and sound
    textPreMsgEnabled = config->readBoolEntry("TextPreMsgEnabled", false);
    textPreMsg = config->readEntry("TextPreMsg");

    textPreSndEnabled = config->readBoolEntry("TextPreSndEnabled", false);
    textPreSnd = config->readEntry("TextPreSnd");

    textPostMsgEnabled = config->readBoolEntry("TextPostMsgEnabled", false);
    textPostMsg = config->readEntry("TextPostMsg");

    textPostSndEnabled = config->readBoolEntry("TextPostSndEnabled", false);
    textPostSnd = config->readEntry("TextPostSnd");
    keepAudio = config->readBoolEntry("KeepAudio", false);
    keepAudioPath = config->readEntry("KeepAudioPath", locateLocal("data", "kttsd/audio/"));

    // Notification (KNotify).
    notify = config->readBoolEntry("Notify", false);
    notifyExcludeEventsWithSound = config->readBoolEntry("ExcludeEventsWithSound", true);
    loadNotifyEventsFromFile( locateLocal("config", "kttsd_notifyevents.xml"), true );

    // KTTSMgr auto start and auto exit.
    autoStartManager = config->readBoolEntry("AutoStartManager", false);
    autoExitManager = config->readBoolEntry("AutoExitManager", false);

    // Clear the pool of filter managers so that filters re-init themselves.
    QPtrListIterator<PooledFilterMgr> it( m_pooledFilterMgrs );
    for( ; it.current(); ++it )
    {
        PooledFilterMgr* pooledFilterMgr = it.current();
        delete pooledFilterMgr->filterMgr;
        delete pooledFilterMgr->talkerCode;
        delete pooledFilterMgr;
    }
    m_pooledFilterMgrs.clear();

    // Create an initial FilterMgr for the pool to save time later.
    PooledFilterMgr* pooledFilterMgr = new PooledFilterMgr();
    FilterMgr* filterMgr = new FilterMgr();
    filterMgr->init(config, "General");
    supportsHTML = filterMgr->supportsHTML();
    pooledFilterMgr->filterMgr = filterMgr;
    pooledFilterMgr->busy = false;
    pooledFilterMgr->job = 0;
    pooledFilterMgr->partNum = 0;
    // Connect signals from FilterMgr.
    connect (filterMgr, SIGNAL(filteringFinished()), this, SLOT(slotFilterMgrFinished()));
    connect (filterMgr, SIGNAL(filteringStopped()),  this, SLOT(slotFilterMgrStopped()));
    m_pooledFilterMgrs.append(pooledFilterMgr);

    return true;
}
Ejemplo n.º 2
0
// Process output when xsltproc exits.
void XmlTransformerProc::processOutput()
{
    QFile::remove(m_inFilename);

    int exitStatus = 11;
    if (m_xsltProc->normalExit())
        exitStatus = m_xsltProc->exitStatus();
    else
        kdDebug() << "XmlTransformerProc::processOutput: xsltproc was killed." << endl;

    delete m_xsltProc;
    m_xsltProc = 0;

    if (exitStatus != 0)
    {
        kdDebug() << "XmlTransformerProc::processOutput: xsltproc abnormal exit.  Status = " << exitStatus << endl;
        m_state = fsFinished;
        QFile::remove(m_outFilename);
        emit filteringFinished();
        return;
    }

    /// Read back the data that was written to /tmp/fileName.output.
    QFile readfile(m_outFilename);
    if(!readfile.open(IO_ReadOnly)) {
        /// uhh yeah... Issues writing to the output file.
        kdDebug() << "XmlTransformerProc::processOutput: Could not read file " << m_outFilename << endl;
        m_state = fsFinished;
        emit filteringFinished();
    }
    QTextStream rstream(&readfile);
    m_text = rstream.read();
    readfile.close();

    kdDebug() << "XmlTransformerProc::processOutput: Read file at " + m_inFilename + " and created " + m_outFilename + " based on the stylesheet at " << m_xsltFilePath << endl;

    // Clean up.
    QFile::remove(m_outFilename);

    m_state = fsFinished;
    m_wasModified = true;
    emit filteringFinished();
}
Ejemplo n.º 3
0
void
TreeProxyModel::filterFinished()
{
    if ( m_artistsFilterCmd )
    {
        disconnect( dynamic_cast< QObject* >( m_artistsFilterCmd ), SIGNAL( artists( QList<Tomahawk::artist_ptr> ) ),
                    this, SLOT( onFilterArtists( QList<Tomahawk::artist_ptr> ) ) );

        delete m_artistsFilterCmd;
        m_artistsFilterCmd = 0;
    }

    setFilterRegExp( m_filter );
    emit filterChanged( m_filter );
    emit filteringFinished();
}
Ejemplo n.º 4
0
/**
* Assigns a FilterMgr to a job and starts filtering on it.
*/
void SpeechData::startJobFiltering(mlJob* job, const QString& text, bool noSBD)
{
    uint jobNum = job->jobNum;
    int partNum = job->partCount;
    // kdDebug() << "SpeechData::startJobFiltering: jobNum = " << jobNum << " partNum = " << partNum << " text.left(500) = " << text.left(500) << endl;
    // Find an idle FilterMgr, if any.
    // If filtering is already in progress for this job and part, do nothing.
    PooledFilterMgr* pooledFilterMgr = 0;
    QPtrListIterator<PooledFilterMgr> it( m_pooledFilterMgrs );
    for( ; it.current(); ++it )
    {
        if (it.current()->busy) {
            if ((it.current()->job->jobNum == jobNum) && (it.current()->partNum == partNum)) return;
        } else {
            if (!it.current()->job && !pooledFilterMgr) pooledFilterMgr = it.current();
        }
    }
    // Create a new FilterMgr if needed and add to pool.
    if (!pooledFilterMgr)
    {
        // kdDebug() << "SpeechData::startJobFiltering: adding new pooledFilterMgr for job " << jobNum << " part " << partNum << endl;
        pooledFilterMgr = new PooledFilterMgr();
        FilterMgr* filterMgr = new FilterMgr();
        filterMgr->init(config, "General");
        pooledFilterMgr->filterMgr = filterMgr;
        // Connect signals from FilterMgr.
        connect (filterMgr, SIGNAL(filteringFinished()), this, SLOT(slotFilterMgrFinished()));
        connect (filterMgr, SIGNAL(filteringStopped()),  this, SLOT(slotFilterMgrStopped()));
        m_pooledFilterMgrs.append(pooledFilterMgr);
    }
    // else kdDebug() << "SpeechData::startJobFiltering: re-using idle pooledFilterMgr for job " << jobNum << " part " << partNum << endl;
    // Flag the FilterMgr as busy and set it going.
    pooledFilterMgr->busy = true;
    pooledFilterMgr->job = job;
    pooledFilterMgr->partNum = partNum;
    pooledFilterMgr->filterMgr->setNoSBD( noSBD );
    // Get TalkerCode structure of closest matching Talker.
    pooledFilterMgr->talkerCode = m_talkerMgr->talkerToTalkerCode(job->talker);
    // Pass Sentence Boundary regular expression (if app overrode default);
    if (sentenceDelimiters.find(job->appId) != sentenceDelimiters.end())
        pooledFilterMgr->filterMgr->setSbRegExp(sentenceDelimiters[job->appId]);
    pooledFilterMgr->filterMgr->asyncConvert(text, pooledFilterMgr->talkerCode, job->appId);
}