20 lines
618 B
Plaintext
20 lines
618 B
Plaintext
#include "screenreader.h"
|
|
#include <QtCore>
|
|
#include <private/qt_mac_p.h>
|
|
|
|
void ScreenReader::speak(const QString &text, const QString &voice)
|
|
{
|
|
QString voiceBase = "com.apple.speech.synthesis.voice.";
|
|
if (voice.isEmpty())
|
|
voiceBase += "Vici";
|
|
else
|
|
voiceBase += voice;
|
|
|
|
CFStringRef cfVoice = QCFString::toCFStringRef(voiceBase);
|
|
NSSpeechSynthesizer *synth = [[NSSpeechSynthesizer alloc] initWithVoice:(NSString *)cfVoice];
|
|
CFStringRef cfText = QCFString::toCFStringRef(text);
|
|
[synth startSpeakingString: (NSString *)cfText];
|
|
CFRelease(cfText);
|
|
CFRelease(cfVoice);
|
|
}
|