Example #1
0
void QtSpeech_proc::say(QString text) {
    try {
        if (player)
        {
            player->stop();
            delete player;
        }
        player = new WavePlayer;

        if (!init) {
            int heap_size = FESTIVAL_HEAP_SIZE;
            festival_initialize(true,heap_size);
            init = true;
        }
        has_error = false;
        EST_String est_text(text.toUtf8());
        EST_Wave est_wave;
        SysCall(festival_text_to_wave(est_text, est_wave), QtSpeech::LogicError);
        EST_String est_file(player->filePath().toUtf8());
        est_wave.save(est_file);

        connect(player, SIGNAL(finished(int)), this, SIGNAL(finished()));
        connect(player, SIGNAL(finished(int)), player, SLOT(deleteLater()));
        player->play();
    }
    catch(QtSpeech::LogicError e) {
        has_error = true;
        err = e;
    }
}
void QtSpeech_th::say(QString text) {
    try {
        if (!init) {
            int heap_size = FESTIVAL_HEAP_SIZE;
            festival_initialize(true,heap_size);
            init = true;
        }
        has_error = false;
        EST_String est_text(text.toUtf8());
        SysCall(festival_say_text(est_text), QtSpeech::LogicError);
    }
    catch(QtSpeech::LogicError e) {
        has_error = true;
        err = e;
    }
    emit finished();
}