1 // Copyright 2005-2019 The Mumble Developers. All rights reserved. 2 // Use of this source code is governed by a BSD-style license 3 // that can be found in the LICENSE file at the root of the 4 // Mumble source tree or at <https://www.mumble.info/LICENSE>. 5 6 #include "mumble_pch.hpp" 7 8 #include "TextToSpeech.h" 9 10 #include <QTextToSpeech> 11 12 class TextToSpeechPrivate { 13 public: 14 QTextToSpeech *m_tts; 15 QVector<QVoice> m_voices; 16 TextToSpeechPrivate(); 17 ~TextToSpeechPrivate(); 18 void say(const QString &text); 19 void setVolume(int v); 20 }; 21 TextToSpeechPrivate()22TextToSpeechPrivate::TextToSpeechPrivate() { 23 m_tts = new QTextToSpeech(); 24 } 25 ~TextToSpeechPrivate()26TextToSpeechPrivate::~TextToSpeechPrivate() { 27 delete m_tts; 28 } 29 say(const QString & text)30void TextToSpeechPrivate::say(const QString &text) { 31 m_tts->say(text); 32 } 33 setVolume(int volume)34void TextToSpeechPrivate::setVolume(int volume) { 35 m_tts->setVolume(volume); 36 } 37 TextToSpeech(QObject * p)38TextToSpeech::TextToSpeech(QObject *p) : QObject(p) { 39 enabled = true; 40 d = new TextToSpeechPrivate(); 41 } 42 ~TextToSpeech()43TextToSpeech::~TextToSpeech() { 44 delete d; 45 } 46 say(const QString & text)47void TextToSpeech::say(const QString &text) { 48 if (enabled) 49 d->say(text); 50 } 51 setEnabled(bool e)52void TextToSpeech::setEnabled(bool e) { 53 enabled = e; 54 } 55 setVolume(int volume)56void TextToSpeech::setVolume(int volume) { 57 d->setVolume(volume); 58 } 59 isEnabled() const60bool TextToSpeech::isEnabled() const { 61 return enabled; 62 } 63