void InstallTalkWindow::updateSettings(void)
{
    QString ttsName = RbSettings::value(RbSettings::Tts).toString();
    TTSBase* tts = TTSBase::getTTS(this,ttsName);
    if(tts->configOk())
        ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
            .arg(TTSBase::getTTSName(ttsName)));
    else
        ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
            .arg("Invalid TTS configuration!"));
    
    QString encoder = SystemInfo::value(SystemInfo::CurEncoder).toString();
    EncBase* enc = EncBase::getEncoder(this,encoder);
    if(enc != NULL) {
        if(enc->configOk())
            ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
                .arg(EncBase::getEncoderName(encoder)));
        else
            ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
                .arg("Invalid encoder configuration!"));
    }
    else
        ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
            .arg("Invalid encoder configuration!"));

    setTalkFolder(RbSettings::value(RbSettings::LastTalkedFolder).toString());
    emit settingsUpdated();
}
Example #2
0
/** @brief update displayed settings
 */
void CreateVoiceWindow::updateSettings(void)
{
    // fill in language combobox
    QMap<QString, QString> languages = SystemInfo::languages();

    for(int i = 0; i < languages.keys().size(); i++) {
        QString key = languages.keys().at(i);
        ui.comboLanguage->addItem(languages.value(key), key);
    }
    // set saved lang
    int sel = ui.comboLanguage->findText(
            RbSettings::value(RbSettings::VoiceLanguage).toString());
    // if no saved language is found try to figure the language from the UI lang
    if(sel == -1) {
        QString f = RbSettings::value(RbSettings::Language).toString();
        // if no language is set default to english. Make sure not to check an empty string.
        if(f.isEmpty()) f = "english";
        sel = ui.comboLanguage->findData(f);
        qDebug() << "sel =" << sel;
        // still nothing found?
        if(sel == -1)
            sel = ui.comboLanguage->findText("english", Qt::MatchStartsWith);
    }
    ui.comboLanguage->setCurrentIndex(sel);

    QString ttsName = RbSettings::value(RbSettings::Tts).toString();
    TTSBase* tts = TTSBase::getTTS(this,ttsName);
    if(tts->configOk())
        ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
            .arg(TTSBase::getTTSName(ttsName)));
    else
        ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
            .arg("Invalid TTS configuration!"));
    
    QString encoder = SystemInfo::value(SystemInfo::CurEncoder).toString();
    // only proceed if encoder setting is set
    EncBase* enc = EncBase::getEncoder(this,encoder);
    if(enc != NULL) {
        if(enc->configOk())
            ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
                .arg(EncBase::getEncoderName(encoder)));
        else
            ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
                .arg("Invalid encoder configuration!"));
    }
    else
        ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
            .arg("Invalid encoder configuration!"));
    ui.wavtrimthreshold->setValue(RbSettings::value(RbSettings::WavtrimThreshold).toInt());
    emit settingsUpdated();
}
Example #3
0
void Config::testTts()
{
    QString errstr;
    int index = ui.comboTts->currentIndex();
    TTSBase* tts;

    ui.testTTS->setEnabled(false);
    tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString());
    if(!tts->configOk())
    {
        QMessageBox::warning(this,tr("TTS configuration invalid"),
                tr("TTS configuration invalid. \n Please configure TTS engine."));
        return;
    }
    if(!tts->start(&errstr))
    {
        QMessageBox::warning(this,tr("Could not start TTS engine."),
                tr("Could not start TTS engine.\n") + errstr
                + tr("\nPlease configure TTS engine."));
        ui.testTTS->setEnabled(true);
        return;
    }

    QString filename;
    QTemporaryFile file(this);
    // keep filename empty if the TTS can do speaking for itself.
    if(!(tts->capabilities() & TTSBase::CanSpeak)) {
        file.open();
        filename = file.fileName();
        file.close();
    }

    if(tts->voice(tr("Rockbox Utility Voice Test"),filename,&errstr) == FatalError)
    {
        tts->stop();
        QMessageBox::warning(this,tr("Could not voice test string."),
                tr("Could not voice test string.\n") + errstr
                + tr("\nPlease configure TTS engine."));
        ui.testTTS->setEnabled(false);
        return;
    }
    tts->stop();
    if(!filename.isEmpty()) {
#if defined(Q_OS_LINUX)
        QString exe = Utils::findExecutable("aplay");
        if(exe == "") exe = Utils::findExecutable("play");
        if(exe != "")
        {
            QProcess::execute(exe+" "+filename);
        }
#else
        QSound::play(filename);
#endif
    }
    ui.testTTS->setEnabled(true);
    delete tts; /* Config objects are never deleted (in fact, they are
                   leaked..), so we can't rely on QObject, since that would
                   delete the TTSBase instance on application exit */
}
/** @brief update displayed settings
 */
void CreateVoiceWindow::updateSettings(void)
{
    // fill in language combobox
    QMap<QString, QStringList> languages = SystemInfo::languages();

    for(int i = 0; i < languages.keys().size(); i++) {
        QString key = languages.keys().at(i);
        ui.comboLanguage->addItem(languages.value(key).at(1), languages.value(key).at(0));
    }
    // set saved lang
    int sel = ui.comboLanguage->findData(
            RbSettings::value(RbSettings::VoiceLanguage).toString());
    // if no saved language is found try to figure the language from the UI lang
    if(sel == -1) {
        QString uilang = RbSettings::value(RbSettings::Language).toString();
        // if no language is set default to english. Make sure not to check an empty string.
        QString f = "english";
        if(!uilang.isEmpty() && languages.contains(uilang)) {
            f = languages.value(uilang).at(0);
        }
        sel = ui.comboLanguage->findData(f);
        qDebug() << "[CreateVoiceWindow] Selected language index:" << sel;
    }
    ui.comboLanguage->setCurrentIndex(sel);

    QString ttsName = RbSettings::value(RbSettings::Tts).toString();
    TTSBase* tts = TTSBase::getTTS(this,ttsName);
    if(!tts)
    {
        QMessageBox::critical(this, tr("TTS error"),
            tr("The selected TTS failed to initialize. You can't use this TTS."));
        return;
    }
    if(tts->configOk())
        ui.labelTtsProfile->setText(tr("Engine: <b>%1</b>")
            .arg(TTSBase::getTTSName(ttsName)));
    else
        ui.labelTtsProfile->setText(tr("Engine: <b>%1</b>")
            .arg("Invalid TTS configuration!"));

    ui.wavtrimthreshold->setValue(RbSettings::value(RbSettings::WavtrimThreshold).toInt());
    emit settingsUpdated();
}
Example #5
0
void Config::updateTtsState(int index)
{
    QString ttsName = ui.comboTts->itemData(index).toString();
    TTSBase* tts = TTSBase::getTTS(this,ttsName);

    if(tts->configOk())
    {
        ui.configTTSstatus->setText(tr("Configuration OK"));
        ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/go-next.png")));
        ui.testTTS->setEnabled(true);
    }
    else
    {
        ui.configTTSstatus->setText(tr("Configuration INVALID"));
        ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/dialog-error.png")));
        ui.testTTS->setEnabled(false);
    }

    delete tts; /* Config objects are never deleted (in fact, they are leaked..), so we can't rely on QObject,
                   since that would delete the TTSBase instance on application exit*/
}