Newer
Older
WorkCardReader / utils / SpeakerUtil.cpp
tanyue on 18 Jun 2022 414 bytes 20220618 界面调整
#include "SpeakerUtil.h"

SpeakerUtil::SpeakerUtil(QObject *parent) : QObject(parent)
{
    tts = new QTextToSpeech(parent);
    tts->setLocale(QLocale::Chinese);
    tts->setRate(0.0);
    tts->setPitch(1.0);
    tts->setVolume(1.0);
}

void SpeakerUtil::speak(QString content)
{
    if (tts->state() == QTextToSpeech::Ready && tts->state() != QTextToSpeech::Speaking)
    {
        tts->say(content);
    }
}