diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-04-03 08:06:59 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-04-03 08:06:59 +0000 |
commit | 746f01dd775feb9b53577a2338fd9182d879c0d3 (patch) | |
tree | bc6daa8c97b4ef9665e7113f14b68e1dbdf17d7d /rbutil/rbutilqt/configure.cpp | |
parent | 76c112ce6e3b79cdbc8545637d2bffbedff3f178 (diff) | |
download | rockbox-746f01dd775feb9b53577a2338fd9182d879c0d3.tar.gz rockbox-746f01dd775feb9b53577a2338fd9182d879c0d3.zip |
Add capability to speak directly from the TTS engine.
The OS X TTS engine (and likely others) allows outputting its speech directly
to the sound system. This avoids the extra step of creating a temporary file to
play for TTS preview. Currently implemented as TTS capability reported.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29672 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/configure.cpp')
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 8bfa20e6a0..9b6376e469 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -731,14 +731,16 @@ void Config::testTts() | |||
731 | { | 731 | { |
732 | QString errstr; | 732 | QString errstr; |
733 | int index = ui.comboTts->currentIndex(); | 733 | int index = ui.comboTts->currentIndex(); |
734 | TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString()); | 734 | TTSBase* tts; |
735 | |||
736 | ui.testTTS->setEnabled(false); | ||
737 | tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString()); | ||
735 | if(!tts->configOk()) | 738 | if(!tts->configOk()) |
736 | { | 739 | { |
737 | QMessageBox::warning(this,tr("TTS configuration invalid"), | 740 | QMessageBox::warning(this,tr("TTS configuration invalid"), |
738 | tr("TTS configuration invalid. \n Please configure TTS engine.")); | 741 | tr("TTS configuration invalid. \n Please configure TTS engine.")); |
739 | return; | 742 | return; |
740 | } | 743 | } |
741 | ui.testTTS->setEnabled(false); | ||
742 | if(!tts->start(&errstr)) | 744 | if(!tts->start(&errstr)) |
743 | { | 745 | { |
744 | QMessageBox::warning(this,tr("Could not start TTS engine."), | 746 | QMessageBox::warning(this,tr("Could not start TTS engine."), |
@@ -748,10 +750,13 @@ void Config::testTts() | |||
748 | return; | 750 | return; |
749 | } | 751 | } |
750 | 752 | ||
751 | QTemporaryFile file(this); | 753 | QString filename; |
752 | file.open(); | 754 | if(!(tts->capabilities() & TTSBase::CanSpeak)) { |
753 | QString filename = file.fileName(); | 755 | QTemporaryFile file(this); |
754 | file.close(); | 756 | file.open(); |
757 | filename = file.fileName(); | ||
758 | file.close(); | ||
759 | } | ||
755 | 760 | ||
756 | if(tts->voice(tr("Rockbox Utility Voice Test"),filename,&errstr) == FatalError) | 761 | if(tts->voice(tr("Rockbox Utility Voice Test"),filename,&errstr) == FatalError) |
757 | { | 762 | { |
@@ -763,16 +768,18 @@ void Config::testTts() | |||
763 | return; | 768 | return; |
764 | } | 769 | } |
765 | tts->stop(); | 770 | tts->stop(); |
771 | if(!(tts->capabilities() & TTSBase::CanSpeak)) { | ||
766 | #if defined(Q_OS_LINUX) | 772 | #if defined(Q_OS_LINUX) |
767 | QString exe = Utils::findExecutable("aplay"); | 773 | QString exe = Utils::findExecutable("aplay"); |
768 | if(exe == "") exe = Utils::findExecutable("play"); | 774 | if(exe == "") exe = Utils::findExecutable("play"); |
769 | if(exe != "") | 775 | if(exe != "") |
770 | { | 776 | { |
771 | QProcess::execute(exe+" "+filename); | 777 | QProcess::execute(exe+" "+filename); |
772 | } | 778 | } |
773 | #else | 779 | #else |
774 | QSound::play(filename); | 780 | QSound::play(filename); |
775 | #endif | 781 | #endif |
782 | } | ||
776 | ui.testTTS->setEnabled(true); | 783 | ui.testTTS->setEnabled(true); |
777 | delete tts; /* Config objects are never deleted (in fact, they are | 784 | delete tts; /* Config objects are never deleted (in fact, they are |
778 | leaked..), so we can't rely on QObject, since that would | 785 | leaked..), so we can't rely on QObject, since that would |