summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2007-12-15 13:13:57 +0000
committerDominik Wenger <domonoky@googlemail.com>2007-12-15 13:13:57 +0000
commitbebddd42c265bf63845f42bb29f48de5ed263f69 (patch)
treeb5dbb6e711d4d71034c4ee19ddfa7e0af043971b /rbutil/rbutilqt
parent1e489e53b8d0807fc52423ae7453d4b1d047d370 (diff)
downloadrockbox-bebddd42c265bf63845f42bb29f48de5ed263f69.tar.gz
rockbox-bebddd42c265bf63845f42bb29f48de5ed263f69.zip
rbutil: reworked configuration of TTS engines to the new Style.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15932 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/configure.cpp143
-rw-r--r--rbutil/rbutilqt/configure.h4
-rw-r--r--rbutil/rbutilqt/configurefrm.ui62
-rw-r--r--rbutil/rbutilqt/encoders.cpp8
-rw-r--r--rbutil/rbutilqt/encoders.h20
-rw-r--r--rbutil/rbutilqt/installtalkwindow.cpp55
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp2
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro10
-rw-r--r--rbutil/rbutilqt/sapicfgfrm.ui168
-rw-r--r--rbutil/rbutilqt/talkfile.cpp77
-rw-r--r--rbutil/rbutilqt/talkfile.h65
-rw-r--r--rbutil/rbutilqt/tts.cpp376
-rw-r--r--rbutil/rbutilqt/tts.h116
-rw-r--r--rbutil/rbutilqt/ttsexescfgfrm.ui158
14 files changed, 916 insertions, 348 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index 4e483ed894..337f5bc210 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -24,6 +24,7 @@
24#include "ui_configurefrm.h" 24#include "ui_configurefrm.h"
25#include "browsedirtree.h" 25#include "browsedirtree.h"
26#include "encoders.h" 26#include "encoders.h"
27#include "tts.h"
27 28
28#include <stdio.h> 29#include <stdio.h>
29#if defined(Q_OS_WIN32) 30#if defined(Q_OS_WIN32)
@@ -75,9 +76,9 @@ Config::Config(QWidget *parent,int index) : QDialog(parent)
75 connect(ui.buttonAutodetect,SIGNAL(clicked()),this,SLOT(autodetect())); 76 connect(ui.buttonAutodetect,SIGNAL(clicked()),this,SLOT(autodetect()));
76 connect(ui.buttonCacheBrowse, SIGNAL(clicked()), this, SLOT(browseCache())); 77 connect(ui.buttonCacheBrowse, SIGNAL(clicked()), this, SLOT(browseCache()));
77 connect(ui.buttonCacheClear, SIGNAL(clicked()), this, SLOT(cacheClear())); 78 connect(ui.buttonCacheClear, SIGNAL(clicked()), this, SLOT(cacheClear()));
78 connect(ui.browseTts, SIGNAL(clicked()), this, SLOT(browseTts())); 79 connect(ui.configTts, SIGNAL(clicked()), this, SLOT(configTts()));
79 connect(ui.configEncoder, SIGNAL(clicked()), this, SLOT(configEnc())); 80 connect(ui.configEncoder, SIGNAL(clicked()), this, SLOT(configEnc()));
80 connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsOpts(int))); 81 connect(ui.comboTts, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTtsState(int)));
81 connect(ui.comboEncoder, SIGNAL(currentIndexChanged(int)), this, SLOT(updateEncState(int))); 82 connect(ui.comboEncoder, SIGNAL(currentIndexChanged(int)), this, SLOT(updateEncState(int)));
82 83
83} 84}
@@ -131,20 +132,7 @@ void Config::accept()
131 userSettings->setValue("offline", ui.cacheOfflineMode->isChecked()); 132 userSettings->setValue("offline", ui.cacheOfflineMode->isChecked());
132 133
133 // tts settings 134 // tts settings
134 QString preset; 135 userSettings->setValue("tts",ui.comboTts->currentText());
135 preset = ui.comboTts->itemData(ui.comboTts->currentIndex(), Qt::UserRole).toString();
136 userSettings->setValue("ttspreset", preset);
137 userSettings->beginGroup(preset);
138
139 if(QFileInfo(ui.ttsExecutable->text()).exists())
140 userSettings->setValue("binary", ui.ttsExecutable->text());
141 userSettings->setValue("options", ui.ttsOptions->text());
142 userSettings->setValue("language", ui.ttsLanguage->text());
143 devices->beginGroup(preset);
144 userSettings->setValue("template", devices->value("template").toString());
145 userSettings->setValue("type", devices->value("tts").toString());
146 devices->endGroup();
147 userSettings->endGroup();
148 136
149 //encoder settings 137 //encoder settings
150 userSettings->setValue("encoder",ui.comboEncoder->currentText()); 138 userSettings->setValue("encoder",ui.comboEncoder->currentText());
@@ -316,86 +304,34 @@ void Config::setDevices(QSettings *dev)
316 updateEncState(index); 304 updateEncState(index);
317 305
318 //tts 306 //tts
319 devices->beginGroup("tts"); 307 ui.comboTts->addItems(getTTSList());
320 QStringList keys = devices->allKeys(); 308
321 for(int i=0; i < keys.size();i++) 309
322 { 310 //update index of combobox
323 devices->endGroup(); 311 index = ui.comboTts->findText(userSettings->value("tts").toString(),Qt::MatchExactly);
324 devices->beginGroup(keys.at(i));
325 QString os = devices->value("os").toString();
326 devices->endGroup();
327 devices->beginGroup("tts");
328
329 if(os == "all")
330 ui.comboTts->addItem(devices->value(keys.at(i), "null").toString(), keys.at(i));
331
332#if defined(Q_OS_WIN32)
333 if(os == "win32")
334 ui.comboTts->addItem(devices->value(keys.at(i), "null").toString(), keys.at(i));
335#endif
336 }
337 devices->endGroup();
338
339
340 index = ui.comboTts->findData(userSettings->value("ttspreset").toString(),
341 Qt::UserRole, Qt::MatchExactly);
342 if(index < 0) index = 0; 312 if(index < 0) index = 0;
343 ui.comboTts->setCurrentIndex(index); 313 ui.comboTts->setCurrentIndex(index);
344 updateTtsOpts(index); 314 updateTtsState(index);
345 315
346
347} 316}
348 317
349 318
350void Config::updateTtsOpts(int index) 319void Config::updateTtsState(int index)
351{ 320{
352 bool edit; 321 QString ttsName = ui.comboTts->itemText(index);
353 QString e; 322 TTSBase* tts = getTTS(ttsName);
354 bool needsLanguageCfg; 323 tts->setUserCfg(userSettings);
355 QString c = ui.comboTts->itemData(index, Qt::UserRole).toString();
356 devices->beginGroup(c);
357 edit = devices->value("edit").toBool();
358 needsLanguageCfg = devices->value("needslanguagecfg").toBool();
359 ui.ttsLanguage->setVisible(needsLanguageCfg);
360 ui.ttsLanguageLabel->setVisible(needsLanguageCfg);
361 ui.ttsOptions->setText(devices->value("options").toString());
362 ui.ttsOptions->setEnabled(devices->value("edit").toBool());
363 e = devices->value("tts").toString();
364 devices->endGroup();
365
366#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
367 QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
368#elif defined(Q_OS_WIN)
369 QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
370#endif
371 qDebug() << path;
372 ui.ttsExecutable->setEnabled(true);
373 for(int i = 0; i < path.size(); i++) {
374 QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + e;
375#if defined(Q_OS_WIN)
376 executable += ".exe";
377 QStringList ex = executable.split("\"", QString::SkipEmptyParts);
378 executable = ex.join("");
379#endif
380 qDebug() << executable;
381 if(QFileInfo(executable).isExecutable()) {
382 ui.ttsExecutable->setText(QDir::toNativeSeparators(executable));
383 // disallow changing the detected path if non-customizable profile
384 if(!edit)
385 ui.ttsExecutable->setEnabled(false);
386 break;
387 }
388 }
389 324
390 //user settings 325 if(tts->configOk())
391 userSettings->beginGroup(c); 326 {
392 QString temp = userSettings->value("binary","null").toString(); 327 ui.configTTSstatus->setText("Configuration OK");
393 if(temp != "null") ui.ttsExecutable->setText(temp); 328 ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/icons/go-next.png")));
394 temp = userSettings->value("options","null").toString(); 329 }
395 if(temp != "null") ui.ttsOptions->setText(temp); 330 else
396 temp = userSettings->value("language","null").toString(); 331 {
397 if(temp != "null") ui.ttsLanguage->setText(temp); 332 ui.configTTSstatus->setText("Configuration INVALID");
398 userSettings->endGroup(); 333 ui.configTTSstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/icons/dialog-error.png")));
334 }
399} 335}
400 336
401void Config::updateEncState(int index) 337void Config::updateEncState(int index)
@@ -406,13 +342,13 @@ void Config::updateEncState(int index)
406 342
407 if(enc->configOk()) 343 if(enc->configOk())
408 { 344 {
409 ui.configstatus->setText("Configuration OK"); 345 ui.configEncstatus->setText("Configuration OK");
410 ui.configstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/icons/go-next.png"))); 346 ui.configEncstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/icons/go-next.png")));
411 } 347 }
412 else 348 else
413 { 349 {
414 ui.configstatus->setText("Configuration INVALID"); 350 ui.configEncstatus->setText("Configuration INVALID");
415 ui.configstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/icons/dialog-error.png"))); 351 ui.configEncstatusimg->setPixmap(QPixmap(QString::fromUtf8(":/icons/icons/dialog-error.png")));
416 } 352 }
417} 353}
418 354
@@ -676,24 +612,13 @@ void Config::cacheClear()
676} 612}
677 613
678 614
679void Config::browseTts() 615void Config::configTts()
680{ 616{
681 BrowseDirtree browser(this); 617 TTSBase* tts =getTTS(ui.comboTts->currentText());
682 browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); 618
683 619 tts->setUserCfg(userSettings);
684 if(QFileInfo(ui.ttsExecutable->text()).isDir()) 620 tts->showCfg();
685 { 621 updateTtsState(ui.comboTts->currentIndex());
686 browser.setDir(ui.ttsExecutable->text());
687 }
688 if(browser.exec() == QDialog::Accepted)
689 {
690 qDebug() << browser.getSelected();
691 QString exe = browser.getSelected();
692 if(!QFileInfo(exe).exists())
693 return;
694 ui.ttsExecutable->setText(exe);
695 }
696
697} 622}
698 623
699 624
diff --git a/rbutil/rbutilqt/configure.h b/rbutil/rbutilqt/configure.h
index 3679d0c0f5..c7068e01dc 100644
--- a/rbutil/rbutilqt/configure.h
+++ b/rbutil/rbutilqt/configure.h
@@ -64,9 +64,9 @@ class Config : public QDialog
64 void setMountpoint(QString); 64 void setMountpoint(QString);
65 void setCache(QString); 65 void setCache(QString);
66 void cacheClear(void); 66 void cacheClear(void);
67 void browseTts(void); 67 void configTts(void);
68 void configEnc(void); 68 void configEnc(void);
69 void updateTtsOpts(int); 69 void updateTtsState(int);
70 void updateEncState(int); 70 void updateEncState(int);
71}; 71};
72 72
diff --git a/rbutil/rbutilqt/configurefrm.ui b/rbutil/rbutilqt/configurefrm.ui
index 78bb929af0..d6d13f6d6f 100644
--- a/rbutil/rbutilqt/configurefrm.ui
+++ b/rbutil/rbutilqt/configurefrm.ui
@@ -358,8 +358,8 @@
358 <attribute name="icon" > 358 <attribute name="icon" >
359 <iconset resource="rbutilqt.qrc" >:/icons/icons/audio-input-microphone.png</iconset> 359 <iconset resource="rbutilqt.qrc" >:/icons/icons/audio-input-microphone.png</iconset>
360 </attribute> 360 </attribute>
361 <layout class="QGridLayout" > 361 <layout class="QVBoxLayout" >
362 <item row="0" column="0" > 362 <item>
363 <widget class="QGroupBox" name="groupBox_2" > 363 <widget class="QGroupBox" name="groupBox_2" >
364 <property name="title" > 364 <property name="title" >
365 <string>TTS Engine</string> 365 <string>TTS Engine</string>
@@ -368,66 +368,54 @@
368 <item row="0" column="0" > 368 <item row="0" column="0" >
369 <widget class="QLabel" name="labelTts" > 369 <widget class="QLabel" name="labelTts" >
370 <property name="text" > 370 <property name="text" >
371 <string>&amp;Select TTS profile</string> 371 <string>&amp;Select TTS Engine</string>
372 </property> 372 </property>
373 <property name="buddy" > 373 <property name="buddy" >
374 <cstring>comboTts</cstring> 374 <cstring>comboTts</cstring>
375 </property> 375 </property>
376 </widget> 376 </widget>
377 </item> 377 </item>
378 <item row="0" column="1" colspan="2" > 378 <item row="0" column="1" colspan="3" >
379 <widget class="QComboBox" name="comboTts" /> 379 <widget class="QComboBox" name="comboTts" />
380 </item> 380 </item>
381 <item row="1" column="0" > 381 <item row="1" column="0" >
382 <widget class="QLabel" name="labelTtsExecutable" > 382 <widget class="QLabel" name="labelTtsExecutable" >
383 <property name="text" > 383 <property name="text" >
384 <string>TTS executable</string> 384 <string>Configure TTS Engine</string>
385 </property>
386 <property name="buddy" >
387 <cstring>ttsExecutable</cstring>
388 </property> 385 </property>
389 </widget> 386 </widget>
390 </item> 387 </item>
391 <item row="1" column="1" > 388 <item row="1" column="1" >
392 <widget class="QLineEdit" name="ttsExecutable" /> 389 <widget class="QLabel" name="configTTSstatus" >
393 </item>
394 <item row="1" column="2" >
395 <widget class="QPushButton" name="browseTts" >
396 <property name="text" > 390 <property name="text" >
397 <string>&amp;Browse</string> 391 <string>Configuration invalid !</string>
398 </property>
399 <property name="icon" >
400 <iconset resource="rbutilqt.qrc" >:/icons/icons/edit-find.png</iconset>
401 </property> 392 </property>
402 </widget> 393 </widget>
403 </item> 394 </item>
404 <item row="2" column="0" > 395 <item row="1" column="2" >
405 <widget class="QLabel" name="labelTtsOptions" > 396 <widget class="QLabel" name="configTTSstatusimg" >
406 <property name="text" > 397 <property name="text" >
407 <string>TTS Options</string> 398 <string/>
408 </property> 399 </property>
409 <property name="buddy" > 400 <property name="pixmap" >
410 <cstring>ttsOptions</cstring> 401 <pixmap resource="rbutilqt.qrc" >:/icons/icons/dialog-error.png</pixmap>
411 </property> 402 </property>
412 </widget> 403 </widget>
413 </item> 404 </item>
414 <item row="2" column="1" colspan="2" > 405 <item row="1" column="3" >
415 <widget class="QLineEdit" name="ttsOptions" /> 406 <widget class="QPushButton" name="configTts" >
416 </item>
417 <item row="3" column="0" >
418 <widget class="QLabel" name="ttsLanguageLabel" >
419 <property name="text" > 407 <property name="text" >
420 <string>TTS Language</string> 408 <string>Configure &amp;TTS</string>
409 </property>
410 <property name="icon" >
411 <iconset resource="rbutilqt.qrc" >:/icons/icons/edit-find.png</iconset>
421 </property> 412 </property>
422 </widget> 413 </widget>
423 </item> 414 </item>
424 <item row="3" column="1" colspan="2" >
425 <widget class="QLineEdit" name="ttsLanguage" />
426 </item>
427 </layout> 415 </layout>
428 </widget> 416 </widget>
429 </item> 417 </item>
430 <item row="1" column="0" > 418 <item>
431 <widget class="QGroupBox" name="groupBox_3" > 419 <widget class="QGroupBox" name="groupBox_3" >
432 <property name="title" > 420 <property name="title" >
433 <string>Encoder Engine</string> 421 <string>Encoder Engine</string>
@@ -454,14 +442,14 @@
454 </widget> 442 </widget>
455 </item> 443 </item>
456 <item row="1" column="1" > 444 <item row="1" column="1" >
457 <widget class="QLabel" name="configstatus" > 445 <widget class="QLabel" name="configEncstatus" >
458 <property name="text" > 446 <property name="text" >
459 <string>Configuration invalid !</string> 447 <string>Configuration invalid !</string>
460 </property> 448 </property>
461 </widget> 449 </widget>
462 </item> 450 </item>
463 <item row="1" column="2" > 451 <item row="1" column="2" >
464 <widget class="QLabel" name="configstatusimg" > 452 <widget class="QLabel" name="configEncstatusimg" >
465 <property name="text" > 453 <property name="text" >
466 <string/> 454 <string/>
467 </property> 455 </property>
@@ -473,7 +461,7 @@
473 <item row="1" column="3" > 461 <item row="1" column="3" >
474 <widget class="QPushButton" name="configEncoder" > 462 <widget class="QPushButton" name="configEncoder" >
475 <property name="text" > 463 <property name="text" >
476 <string>&amp;Configure</string> 464 <string> Configure &amp;Enc</string>
477 </property> 465 </property>
478 <property name="icon" > 466 <property name="icon" >
479 <iconset resource="rbutilqt.qrc" >:/icons/icons/edit-find.png</iconset> 467 <iconset resource="rbutilqt.qrc" >:/icons/icons/edit-find.png</iconset>
@@ -483,15 +471,15 @@
483 </layout> 471 </layout>
484 </widget> 472 </widget>
485 </item> 473 </item>
486 <item row="2" column="0" > 474 <item>
487 <spacer> 475 <spacer>
488 <property name="orientation" > 476 <property name="orientation" >
489 <enum>Qt::Vertical</enum> 477 <enum>Qt::Vertical</enum>
490 </property> 478 </property>
491 <property name="sizeHint" > 479 <property name="sizeHint" >
492 <size> 480 <size>
493 <width>226</width> 481 <width>458</width>
494 <height>51</height> 482 <height>131</height>
495 </size> 483 </size>
496 </property> 484 </property>
497 </spacer> 485 </spacer>
diff --git a/rbutil/rbutilqt/encoders.cpp b/rbutil/rbutilqt/encoders.cpp
index 4f25f813dd..54fc5ad201 100644
--- a/rbutil/rbutilqt/encoders.cpp
+++ b/rbutil/rbutilqt/encoders.cpp
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * 8 *
9 * Copyright (C) 2007 by Dominik Wenger 9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id: talkfile.cpp 15212 2007-10-19 21:49:07Z domonoky $ 10 * $Id: encoders.cpp 15212 2007-10-19 21:49:07Z domonoky $
11 * 11 *
12 * All files in this archive are subject to the GNU General Public License. 12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement. 13 * See the file COPYING in the source tree root for full license agreement.
@@ -33,6 +33,9 @@ void initEncoderList()
33// function to get a specific encoder 33// function to get a specific encoder
34EncBase* getEncoder(QString encname) 34EncBase* getEncoder(QString encname)
35{ 35{
36 // init list if its empty
37 if(encoderList.count() == 0) initEncoderList();
38
36 QString encoder = encoderList.key(encname); 39 QString encoder = encoderList.key(encname);
37 40
38 // check cache 41 // check cache
@@ -59,6 +62,9 @@ EncBase* getEncoder(QString encname)
59// get the list of encoders, nice names 62// get the list of encoders, nice names
60QStringList getEncoderList() 63QStringList getEncoderList()
61{ 64{
65 // init list if its empty
66 if(encoderList.count() == 0) initEncoderList();
67
62 QStringList encList; 68 QStringList encList;
63 QMapIterator<QString, QString> i(encoderList); 69 QMapIterator<QString, QString> i(encoderList);
64 while (i.hasNext()) { 70 while (i.hasNext()) {
diff --git a/rbutil/rbutilqt/encoders.h b/rbutil/rbutilqt/encoders.h
index f69c3ba611..688ffbcd25 100644
--- a/rbutil/rbutilqt/encoders.h
+++ b/rbutil/rbutilqt/encoders.h
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * 8 *
9 * Copyright (C) 2007 by Dominik Wenger 9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id: talkfile.h 15212 2007-10-19 21:49:07Z domonoky $ 10 * $Id: encoders.h 15212 2007-10-19 21:49:07Z domonoky $
11 * 11 *
12 * All files in this archive are subject to the GNU General Public License. 12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement. 13 * See the file COPYING in the source tree root for full license agreement.
@@ -45,19 +45,19 @@ class EncBase : public QDialog
45 Q_OBJECT 45 Q_OBJECT
46public: 46public:
47 EncBase(QWidget *parent ); 47 EncBase(QWidget *parent );
48 virtual ~EncBase(){} 48
49 virtual bool encode(QString input,QString output) = 0; 49 virtual bool encode(QString input,QString output){return false;}
50 virtual bool start() = 0; 50 virtual bool start(){return false;}
51 virtual bool stop() = 0; 51 virtual bool stop(){return false;}
52 virtual void showCfg() = 0; 52 virtual void showCfg(){}
53 virtual bool configOk()=0; 53 virtual bool configOk(){return false;}
54 54
55 void setUserCfg(QSettings *uSettings){userSettings = uSettings;} 55 void setUserCfg(QSettings *uSettings){userSettings = uSettings;}
56 56
57public slots: 57public slots:
58 virtual void accept(void)=0; 58 virtual void accept(void){}
59 virtual void reject(void)=0; 59 virtual void reject(void){}
60 virtual void reset(void)=0; 60 virtual void reset(void){}
61 61
62protected: 62protected:
63 63
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp
index caceb03176..4634ba3eaf 100644
--- a/rbutil/rbutilqt/installtalkwindow.cpp
+++ b/rbutil/rbutilqt/installtalkwindow.cpp
@@ -79,26 +79,7 @@ void InstallTalkWindow::accept()
79 connect(logger,SIGNAL(closed()),this,SLOT(close())); 79 connect(logger,SIGNAL(closed()),this,SLOT(close()));
80 80
81 QString folderToTalk = ui.lineTalkFolder->text(); 81 QString folderToTalk = ui.lineTalkFolder->text();
82 82
83 // tts
84 QString preset = userSettings->value("ttspreset").toString();
85 userSettings->beginGroup(preset);
86 QString pathTTS = userSettings->value("binary").toString();
87 QString ttsOpts = userSettings->value("options").toString();
88 QString ttsLanguage = userSettings->value("language").toString();
89 QString ttsTemplate = userSettings->value("template").toString();
90 QString ttsType =userSettings->value("type").toString();
91 userSettings->endGroup();
92
93 //encoder
94 QString encoderPreset = userSettings->value("encpreset").toString();
95 userSettings->beginGroup(encoderPreset);
96 QString pathEncoder = userSettings->value("binary").toString();
97 QString encOpts = userSettings->value("options").toString();
98 QString encTemplate = userSettings->value("template").toString();
99 QString encType =userSettings->value("type").toString();
100 userSettings->endGroup();
101
102 if(!QFileInfo(folderToTalk).isDir()) 83 if(!QFileInfo(folderToTalk).isDir())
103 { 84 {
104 logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR); 85 logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR);
@@ -106,20 +87,6 @@ void InstallTalkWindow::accept()
106 return; 87 return;
107 } 88 }
108 89
109 if(!QFileInfo(pathEncoder).isExecutable())
110 {
111 logger->addItem(tr("Path to Encoder is wrong!"),LOGERROR);
112 logger->abort();
113 return;
114 }
115
116 if(!QFileInfo(pathTTS).exists())
117 {
118 logger->addItem(tr("Path to TTS is wrong!"),LOGERROR);
119 logger->abort();
120 return;
121 }
122
123 userSettings->setValue("last_talked_folder", folderToTalk); 90 userSettings->setValue("last_talked_folder", folderToTalk);
124 91
125 userSettings->sync(); 92 userSettings->sync();
@@ -127,11 +94,6 @@ void InstallTalkWindow::accept()
127 talkcreator->setUserSettings(userSettings); 94 talkcreator->setUserSettings(userSettings);
128 talkcreator->setDir(QDir(folderToTalk)); 95 talkcreator->setDir(QDir(folderToTalk));
129 talkcreator->setMountPoint(userSettings->value("mountpoint").toString()); 96 talkcreator->setMountPoint(userSettings->value("mountpoint").toString());
130 talkcreator->setTTSexe(pathTTS);
131 talkcreator->setTTsOpts(ttsOpts);
132 talkcreator->setTTsLanguage(ttsLanguage);
133 talkcreator->setTTsType(ttsType);
134 talkcreator->setTTsTemplate(ttsTemplate);
135 97
136 talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked()); 98 talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked());
137 talkcreator->setOverwriteWav(ui.OverwriteWav->isChecked()); 99 talkcreator->setOverwriteWav(ui.OverwriteWav->isChecked());
@@ -150,14 +112,13 @@ void InstallTalkWindow::setDeviceSettings(QSettings *dev)
150 devices = dev; 112 devices = dev;
151 qDebug() << "Install::setDeviceSettings:" << devices; 113 qDebug() << "Install::setDeviceSettings:" << devices;
152 114
153 QString profile; 115 QString ttsName = userSettings->value("tts", "none").toString();
154 116 TTSBase* tts = getTTS(ttsName);
155 profile = userSettings->value("ttspreset", "none").toString(); 117 tts->setUserCfg(userSettings);
156 devices->beginGroup("tts"); 118 if(tts->configOk())
157 ui.labelTtsProfile->setText(tr("TTS Profile: <b>%1</b>") 119 ui.labelTtsProfile->setText(tr("Selected TTS engine : <b>%1</b>").arg(ttsName));
158 .arg(devices->value(profile, tr("Invalid TTS profile!")).toString())); 120 else
159 qDebug() << profile; 121 ui.labelTtsProfile->setText(tr("Selected TTS Engine: <b>%1</b>").arg("Invalid TTS configuration!"));
160 devices->endGroup();
161 122
162 QString encoder = userSettings->value("encoder", "none").toString(); 123 QString encoder = userSettings->value("encoder", "none").toString();
163 EncBase* enc = getEncoder(encoder); 124 EncBase* enc = getEncoder(encoder);
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 558e903e3e..395e538040 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -31,7 +31,6 @@
31#include "installthemes.h" 31#include "installthemes.h"
32#include "uninstallwindow.h" 32#include "uninstallwindow.h"
33#include "browseof.h" 33#include "browseof.h"
34#include "encoders.h"
35 34
36#if defined(Q_OS_LINUX) 35#if defined(Q_OS_LINUX)
37#include <stdio.h> 36#include <stdio.h>
@@ -120,7 +119,6 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
120 initIpodpatcher(); 119 initIpodpatcher();
121 initSansapatcher(); 120 initSansapatcher();
122 downloadInfo(); 121 downloadInfo();
123 initEncoderList();
124 122
125} 123}
126 124
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index 85f76f350b..c344d6ac70 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -36,7 +36,8 @@ SOURCES += rbutilqt.cpp \
36 utils.cpp \ 36 utils.cpp \
37 browseof.cpp \ 37 browseof.cpp \
38 preview.cpp \ 38 preview.cpp \
39 encoders.cpp 39 encoders.cpp \
40 tts.cpp
40 41
41HEADERS += rbutilqt.h \ 42HEADERS += rbutilqt.h \
42 install.h \ 43 install.h \
@@ -73,7 +74,8 @@ HEADERS += rbutilqt.h \
73 utils.h \ 74 utils.h \
74 browseof.h \ 75 browseof.h \
75 preview.h \ 76 preview.h \
76 encoders.h 77 encoders.h \
78 tts.h
77 79
78# Needed by QT on Win 80# Needed by QT on Win
79INCLUDEPATH = . irivertools zip zlib ../ipodpatcher ../sansapatcher ../../tools/rbspeex 81INCLUDEPATH = . irivertools zip zlib ../ipodpatcher ../sansapatcher ../../tools/rbspeex
@@ -106,7 +108,9 @@ FORMS += rbutilqtfrm.ui \
106 browseoffrm.ui \ 108 browseoffrm.ui \
107 previewfrm.ui \ 109 previewfrm.ui \
108 rbspeexcfgfrm.ui \ 110 rbspeexcfgfrm.ui \
109 encexescfgfrm.ui 111 encexescfgfrm.ui \
112 ttsexescfgfrm.ui \
113 sapicfgfrm.ui
110 114
111RESOURCES += rbutilqt.qrc 115RESOURCES += rbutilqt.qrc
112 116
diff --git a/rbutil/rbutilqt/sapicfgfrm.ui b/rbutil/rbutilqt/sapicfgfrm.ui
new file mode 100644
index 0000000000..34e3591aba
--- /dev/null
+++ b/rbutil/rbutilqt/sapicfgfrm.ui
@@ -0,0 +1,168 @@
1<ui version="4.0" >
2 <class>SapiCfgFrm</class>
3 <widget class="QDialog" name="SapiCfgFrm" >
4 <property name="geometry" >
5 <rect>
6 <x>0</x>
7 <y>0</y>
8 <width>511</width>
9 <height>242</height>
10 </rect>
11 </property>
12 <property name="windowTitle" >
13 <string>Configuration</string>
14 </property>
15 <layout class="QHBoxLayout" >
16 <item>
17 <widget class="QGroupBox" name="groupBox" >
18 <property name="title" >
19 <string>Configure TTS Engine</string>
20 </property>
21 <layout class="QVBoxLayout" >
22 <item>
23 <widget class="QLabel" name="label" >
24 <property name="sizePolicy" >
25 <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
26 <horstretch>0</horstretch>
27 <verstretch>255</verstretch>
28 </sizepolicy>
29 </property>
30 <property name="text" >
31 <string>Path to TTS Engine</string>
32 </property>
33 </widget>
34 </item>
35 <item>
36 <layout class="QHBoxLayout" >
37 <item>
38 <widget class="QLineEdit" name="ttspath" />
39 </item>
40 <item>
41 <widget class="QPushButton" name="browse" >
42 <property name="text" >
43 <string>&amp;Browse</string>
44 </property>
45 </widget>
46 </item>
47 </layout>
48 </item>
49 <item>
50 <widget class="QLabel" name="label_2" >
51 <property name="text" >
52 <string>TTS options</string>
53 </property>
54 </widget>
55 </item>
56 <item>
57 <widget class="QLineEdit" name="ttsoptions" />
58 </item>
59 <item>
60 <widget class="QLabel" name="label_3" >
61 <property name="text" >
62 <string>Language</string>
63 </property>
64 </widget>
65 </item>
66 <item>
67 <widget class="QLineEdit" name="ttslanguage" />
68 </item>
69 <item>
70 <spacer>
71 <property name="orientation" >
72 <enum>Qt::Vertical</enum>
73 </property>
74 <property name="sizeHint" >
75 <size>
76 <width>20</width>
77 <height>40</height>
78 </size>
79 </property>
80 </spacer>
81 </item>
82 <item>
83 <layout class="QHBoxLayout" >
84 <item>
85 <widget class="QPushButton" name="reset" >
86 <property name="text" >
87 <string>Reset</string>
88 </property>
89 </widget>
90 </item>
91 <item>
92 <spacer>
93 <property name="orientation" >
94 <enum>Qt::Horizontal</enum>
95 </property>
96 <property name="sizeHint" >
97 <size>
98 <width>40</width>
99 <height>20</height>
100 </size>
101 </property>
102 </spacer>
103 </item>
104 <item>
105 <widget class="QPushButton" name="buttonOk" >
106 <property name="text" >
107 <string>&amp;Ok</string>
108 </property>
109 <property name="icon" >
110 <iconset resource="rbutilqt.qrc" >:/icons/icons/go-next.png</iconset>
111 </property>
112 </widget>
113 </item>
114 <item>
115 <widget class="QPushButton" name="buttonCancel" >
116 <property name="text" >
117 <string>&amp;Cancel</string>
118 </property>
119 <property name="icon" >
120 <iconset resource="rbutilqt.qrc" >:/icons/icons/process-stop.png</iconset>
121 </property>
122 </widget>
123 </item>
124 </layout>
125 </item>
126 </layout>
127 </widget>
128 </item>
129 </layout>
130 </widget>
131 <resources>
132 <include location="rbutilqt.qrc" />
133 </resources>
134 <connections>
135 <connection>
136 <sender>buttonOk</sender>
137 <signal>clicked()</signal>
138 <receiver>SapiCfgFrm</receiver>
139 <slot>accept()</slot>
140 <hints>
141 <hint type="sourcelabel" >
142 <x>253</x>
143 <y>147</y>
144 </hint>
145 <hint type="destinationlabel" >
146 <x>203</x>
147 <y>86</y>
148 </hint>
149 </hints>
150 </connection>
151 <connection>
152 <sender>buttonCancel</sender>
153 <signal>clicked()</signal>
154 <receiver>SapiCfgFrm</receiver>
155 <slot>reject()</slot>
156 <hints>
157 <hint type="sourcelabel" >
158 <x>352</x>
159 <y>147</y>
160 </hint>
161 <hint type="destinationlabel" >
162 <x>203</x>
163 <y>86</y>
164 </hint>
165 </hints>
166 </connection>
167 </connections>
168</ui>
diff --git a/rbutil/rbutilqt/talkfile.cpp b/rbutil/rbutilqt/talkfile.cpp
index 141af0b5ec..6f70111aff 100644
--- a/rbutil/rbutilqt/talkfile.cpp
+++ b/rbutil/rbutilqt/talkfile.cpp
@@ -30,15 +30,9 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
30 m_logger = logger; 30 m_logger = logger;
31 m_logger->addItem("Starting Talk file generation",LOGINFO); 31 m_logger->addItem("Starting Talk file generation",LOGINFO);
32 32
33 if(m_curTTS == "sapi") 33 //tts
34 m_tts = new TTSSapi(); 34 m_tts = getTTS(userSettings->value("tts").toString());
35 else 35 m_tts->setUserCfg(userSettings);
36 m_tts = new TTSExes();
37
38 m_tts->setTTSexe(m_TTSexec);
39 m_tts->setTTsOpts(m_TTSOpts);
40 m_tts->setTTsLanguage(m_TTSLanguage);
41 m_tts->setTTsTemplate(m_curTTSTemplate);
42 36
43 if(!m_tts->start()) 37 if(!m_tts->start())
44 { 38 {
@@ -183,68 +177,3 @@ void TalkFileCreator::abort()
183 m_abort = true; 177 m_abort = true;
184} 178}
185 179
186bool TTSSapi::start()
187{
188 QFileInfo tts(m_TTSexec);
189 if(!tts.exists())
190 return false;
191
192 // create the voice process
193 QString execstring = m_TTSTemplate;
194 execstring.replace("%exe",m_TTSexec);
195 execstring.replace("%options",m_TTSOpts);
196 execstring.replace("%lang",m_TTSLanguage);
197 qDebug() << "init" << execstring;
198 voicescript = new QProcess(NULL);
199 voicescript->start(execstring);
200 if(!voicescript->waitForStarted())
201 return false;
202 return true;
203}
204
205bool TTSSapi::voice(QString text,QString wavfile)
206{
207 QString query = "SPEAK\t"+wavfile+"\t"+text+"\r\n";
208 qDebug() << "voicing" << query;
209 voicescript->write(query.toLocal8Bit());
210 voicescript->write("SYNC\tbla\r\n");
211 voicescript->waitForReadyRead();
212 return true;
213}
214
215bool TTSSapi::stop()
216{
217 QString query = "QUIT\r\n";
218 voicescript->write(query.toLocal8Bit());
219 voicescript->waitForFinished();
220 delete voicescript;
221 return true;
222}
223
224bool TTSExes::start()
225{
226 QFileInfo tts(m_TTSexec);
227 qDebug() << "ttsexe init";
228 if(tts.exists())
229 {
230 return true;
231 }
232 else
233 {
234 return false;
235 }
236}
237
238bool TTSExes::voice(QString text,QString wavfile)
239{
240 QString execstring = m_TTSTemplate;
241
242 execstring.replace("%exe",m_TTSexec);
243 execstring.replace("%options",m_TTSOpts);
244 execstring.replace("%wavfile",wavfile);
245 execstring.replace("%text",text);
246 //qDebug() << "voicing" << execstring;
247 QProcess::execute(execstring);
248 return true;
249
250}
diff --git a/rbutil/rbutilqt/talkfile.h b/rbutil/rbutilqt/talkfile.h
index 2e2c3d7a01..d45d3a1907 100644
--- a/rbutil/rbutilqt/talkfile.h
+++ b/rbutil/rbutilqt/talkfile.h
@@ -25,30 +25,7 @@
25#include "progressloggerinterface.h" 25#include "progressloggerinterface.h"
26 26
27#include "encoders.h" 27#include "encoders.h"
28 28#include "tts.h"
29
30class TTSBase : public QObject
31{
32 Q_OBJECT
33public:
34 TTSBase(){}
35 virtual ~TTSBase(){}
36 virtual bool voice(QString text,QString wavfile){(void)text; (void)wavfile; return false;}
37 virtual bool start(){return false;}
38 virtual bool stop(){return false;}
39
40 void setTTSexe(QString exe){m_TTSexec=exe;}
41 void setTTsOpts(QString opts) {m_TTSOpts=opts;}
42 void setTTsLanguage(QString language) {m_TTSLanguage = language;}
43 void setTTsTemplate(QString t) { m_TTSTemplate = t; }
44
45protected:
46 QString m_TTSexec;
47 QString m_TTSOpts;
48 QString m_TTSTemplate;
49 QString m_TTSLanguage;
50};
51
52 29
53class TalkFileCreator :public QObject 30class TalkFileCreator :public QObject
54{ 31{
@@ -61,14 +38,6 @@ public:
61 38
62 void setUserSettings(QSettings* setting) { userSettings = setting;} 39 void setUserSettings(QSettings* setting) { userSettings = setting;}
63 40
64 void setTTSexe(QString exe){m_TTSexec=exe;}
65
66 void setTTsType(QString tts) { m_curTTS = tts; }
67 void setTTsOpts(QString opts) {m_TTSOpts=opts;}
68 void setTTsLanguage(QString language) {m_TTSLanguage = language;}
69 void setTTsTemplate(QString t) { m_curTTSTemplate = t; }
70
71
72 void setDir(QDir dir){m_dir = dir; } 41 void setDir(QDir dir){m_dir = dir; }
73 void setMountPoint(QString mountpoint) {m_mountpoint =mountpoint; } 42 void setMountPoint(QString mountpoint) {m_mountpoint =mountpoint; }
74 43
@@ -90,12 +59,7 @@ private:
90 59
91 QDir m_dir; 60 QDir m_dir;
92 QString m_mountpoint; 61 QString m_mountpoint;
93 QString m_curTTS; 62
94 QString m_TTSexec;
95 QString m_TTSOpts;
96 QString m_TTSLanguage;
97 QString m_curTTSTemplate;
98
99 bool m_overwriteTalk; 63 bool m_overwriteTalk;
100 bool m_overwriteWav; 64 bool m_overwriteWav;
101 bool m_removeWav; 65 bool m_removeWav;
@@ -109,31 +73,6 @@ private:
109 bool m_abort; 73 bool m_abort;
110}; 74};
111 75
112class TTSSapi : public TTSBase
113{
114public:
115 TTSSapi() {};
116 virtual bool voice(QString text,QString wavfile);
117 virtual bool start();
118 virtual bool stop();
119
120private:
121 QProcess* voicescript;
122};
123
124class TTSExes : public TTSBase
125{
126public:
127 TTSExes() {};
128 virtual bool voice(QString text,QString wavfile);
129 virtual bool start();
130 virtual bool stop() {return true;}
131
132private:
133
134};
135
136
137 76
138#endif 77#endif
139 78
diff --git a/rbutil/rbutilqt/tts.cpp b/rbutil/rbutilqt/tts.cpp
new file mode 100644
index 0000000000..63e1188851
--- /dev/null
+++ b/rbutil/rbutilqt/tts.cpp
@@ -0,0 +1,376 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id: tts.cpp 15212 2007-10-19 21:49:07Z domonoky $
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "tts.h"
21
22#include "browsedirtree.h"
23
24static QMap<QString,QString> ttsList;
25static QMap<QString,TTSBase*> ttsCache;
26
27void initTTSList()
28{
29 ttsList["espeak"] = "Espeak TTS Engine";
30 ttsList["flite"] = "Flite TTS Engine";
31 ttsList["swift"] = "Swift TTS Engine";
32#if defined(Q_OS_WIN)
33 ttsList["sapi"] = "Sapi 5 TTS Engine";
34#endif
35
36}
37
38// function to get a specific encoder
39TTSBase* getTTS(QString ttsname)
40{
41 // init list if its empty
42 if(ttsList.count() == 0) initTTSList();
43
44 QString ttsName = ttsList.key(ttsname);
45
46 // check cache
47 if(ttsCache.contains(ttsName))
48 return ttsCache.value(ttsName);
49
50 TTSBase* tts;
51 if(ttsName == "sapi")
52 {
53 tts = new TTSSapi();
54 ttsCache[ttsName] = tts;
55 return tts;
56 }
57 else
58 {
59 tts = new TTSExes(ttsName);
60 ttsCache[ttsName] = tts;
61 return tts;
62 }
63}
64
65// get the list of encoders, nice names
66QStringList getTTSList()
67{
68 // init list if its empty
69 if(ttsList.count() == 0) initTTSList();
70
71 QStringList ttsNameList;
72 QMapIterator<QString, QString> i(ttsList);
73 while (i.hasNext()) {
74 i.next();
75 ttsNameList << i.value();
76 }
77
78 return ttsNameList;
79}
80
81
82/*********************************************************************
83* TTS Base
84**********************************************************************/
85TTSBase::TTSBase(QWidget *parent): QDialog(parent)
86{
87
88}
89
90/*********************************************************************
91* General TTS Exes
92**********************************************************************/
93TTSExes::TTSExes(QString name,QWidget *parent) : TTSBase(parent)
94{
95 m_name = name;
96
97 m_TemplateMap["espeak"] = "\"%exe\" \"%options\" -w \"%wavfile\" \"%text\"";
98 m_TemplateMap["flite"] = "\"%exe\" \"%options\" -o \"%wavfile\" \"%text\"";
99 m_TemplateMap["swift"] = "\"%exe\" \"%options\" -o \"%wavfile\" \"%text\"";
100
101 ui.setupUi(this);
102 this->hide();
103 connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
104 connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse()));
105}
106
107bool TTSExes::start()
108{
109 userSettings->beginGroup(m_name);
110 m_TTSexec = userSettings->value("ttspath","").toString();
111 m_TTSOpts = userSettings->value("ttsoptions","").toString();
112 userSettings->endGroup();
113
114 m_TTSTemplate = m_TemplateMap.value(m_name);
115
116 QFileInfo tts(m_TTSexec);
117 if(tts.exists())
118 {
119 return true;
120 }
121 else
122 {
123 return false;
124 }
125}
126
127bool TTSExes::voice(QString text,QString wavfile)
128{
129 QString execstring = m_TTSTemplate;
130
131 execstring.replace("%exe",m_TTSexec);
132 execstring.replace("%options",m_TTSOpts);
133 execstring.replace("%wavfile",wavfile);
134 execstring.replace("%text",text);
135 //qDebug() << "voicing" << execstring;
136 QProcess::execute(execstring);
137 return true;
138
139}
140
141
142void TTSExes::reset()
143{
144 ui.ttspath->setText("");
145 ui.ttsoptions->setText("");
146}
147
148void TTSExes::showCfg()
149{
150 // try to get config from settings
151 userSettings->beginGroup(m_name);
152 QString exepath =userSettings->value("ttspath","").toString();
153 ui.ttsoptions->setText(userSettings->value("ttsoptions","").toString());
154 userSettings->endGroup();
155
156 if(exepath == "")
157 {
158
159 //try autodetect tts
160#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
161 QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts);
162#elif defined(Q_OS_WIN)
163 QStringList path = QString(getenv("PATH")).split(";", QString::SkipEmptyParts);
164#endif
165 qDebug() << path;
166 for(int i = 0; i < path.size(); i++)
167 {
168 QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + m_name;
169#if defined(Q_OS_WIN)
170 executable += ".exe";
171 QStringList ex = executable.split("\"", QString::SkipEmptyParts);
172 executable = ex.join("");
173#endif
174 qDebug() << executable;
175 if(QFileInfo(executable).isExecutable())
176 {
177 exepath= QDir::toNativeSeparators(executable);
178 break;
179 }
180 }
181
182 }
183
184 ui.ttspath->setText(exepath);
185
186 //show dialog
187 this->exec();
188
189}
190
191void TTSExes::accept(void)
192{
193 if(userSettings != NULL)
194 {
195 //save settings in user config
196 userSettings->beginGroup(m_name);
197 userSettings->setValue("ttspath",ui.ttspath->text());
198 userSettings->setValue("ttsoptions",ui.ttsoptions->text());
199 userSettings->endGroup();
200 // sync settings
201 userSettings->sync();
202 }
203 this->close();
204}
205
206void TTSExes::reject(void)
207{
208 this->close();
209}
210
211bool TTSExes::configOk()
212{
213 userSettings->beginGroup(m_name);
214 QString path = userSettings->value("ttspath","").toString();
215 userSettings->endGroup();
216
217 if (QFileInfo(path).exists())
218 return true;
219
220 return false;
221}
222
223void TTSExes::browse()
224{
225 BrowseDirtree browser(this);
226 browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
227
228 if(QFileInfo(ui.ttspath->text()).isDir())
229 {
230 browser.setDir(ui.ttspath->text());
231 }
232 if(browser.exec() == QDialog::Accepted)
233 {
234 qDebug() << browser.getSelected();
235 QString exe = browser.getSelected();
236 if(!QFileInfo(exe).isExecutable())
237 return;
238 ui.ttspath->setText(exe);
239 }
240}
241
242/*********************************************************************
243* TTS Sapi
244**********************************************************************/
245TTSSapi::TTSSapi(QWidget *parent) : TTSBase(parent)
246{
247 m_TTSTemplate = "cscript //nologo \"%exe\" /language:%lang \"%options\"";
248 defaultLanguage ="english";
249 ui.setupUi(this);
250 this->hide();
251 connect(ui.reset,SIGNAL(clicked()),this,SLOT(reset()));
252 connect(ui.browse,SIGNAL(clicked()),this,SLOT(browse()));
253}
254
255
256bool TTSSapi::start()
257{
258
259 userSettings->beginGroup("sapi");
260 m_TTSexec = userSettings->value("ttspath","").toString();
261 m_TTSOpts = userSettings->value("ttsoptions","").toString();
262 m_TTSLanguage =userSettings->value("ttslanguage","").toString();
263 userSettings->endGroup();
264
265 QFileInfo tts(m_TTSexec);
266 if(!tts.exists())
267 return false;
268
269 // create the voice process
270 QString execstring = m_TTSTemplate;
271 execstring.replace("%exe",m_TTSexec);
272 execstring.replace("%options",m_TTSOpts);
273 execstring.replace("%lang",m_TTSLanguage);
274 qDebug() << "init" << execstring;
275 voicescript = new QProcess(NULL);
276 voicescript->start(execstring);
277 if(!voicescript->waitForStarted())
278 return false;
279 return true;
280}
281
282bool TTSSapi::voice(QString text,QString wavfile)
283{
284 QString query = "SPEAK\t"+wavfile+"\t"+text+"\r\n";
285 qDebug() << "voicing" << query;
286 voicescript->write(query.toLocal8Bit());
287 voicescript->write("SYNC\tbla\r\n");
288 voicescript->waitForReadyRead();
289 return true;
290}
291
292bool TTSSapi::stop()
293{
294 QString query = "QUIT\r\n";
295 voicescript->write(query.toLocal8Bit());
296 voicescript->waitForFinished();
297 delete voicescript;
298 return true;
299}
300
301
302void TTSSapi::reset()
303{
304 ui.ttspath->setText("");
305 ui.ttsoptions->setText("");
306 ui.ttslanguage->setText(defaultLanguage);
307}
308
309void TTSSapi::showCfg()
310{
311 // try to get config from settings
312 userSettings->beginGroup("sapi");
313 QString exepath =userSettings->value("ttspath","").toString();
314 ui.ttsoptions->setText(userSettings->value("ttsoptions","").toString());
315 ui.ttslanguage->setText(userSettings->value("ttsoptions",defaultLanguage).toString());
316 userSettings->endGroup();
317
318 ui.ttspath->setText(exepath);
319
320 //show dialog
321 this->exec();
322
323}
324
325void TTSSapi::accept(void)
326{
327 if(userSettings != NULL)
328 {
329 //save settings in user config
330 userSettings->beginGroup("sapi");
331 userSettings->setValue("ttspath",ui.ttspath->text());
332 userSettings->setValue("ttsoptions",ui.ttsoptions->text());
333 userSettings->setValue("ttslanguage",ui.ttslanguage->text());
334 userSettings->endGroup();
335 // sync settings
336 userSettings->sync();
337 }
338 this->close();
339}
340
341void TTSSapi::reject(void)
342{
343 this->close();
344}
345
346bool TTSSapi::configOk()
347{
348 userSettings->beginGroup("sapi");
349 QString path = userSettings->value("ttspath","").toString();
350 userSettings->endGroup();
351
352 if (QFileInfo(path).exists())
353 return true;
354
355 return false;
356}
357
358void TTSSapi::browse()
359{
360 BrowseDirtree browser(this);
361 browser.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
362
363 if(QFileInfo(ui.ttspath->text()).isDir())
364 {
365 browser.setDir(ui.ttspath->text());
366 }
367 if(browser.exec() == QDialog::Accepted)
368 {
369 qDebug() << browser.getSelected();
370 QString exe = browser.getSelected();
371 if(!QFileInfo(exe).isExecutable())
372 return;
373 ui.ttspath->setText(exe);
374 }
375}
376
diff --git a/rbutil/rbutilqt/tts.h b/rbutil/rbutilqt/tts.h
new file mode 100644
index 0000000000..83fcda35ac
--- /dev/null
+++ b/rbutil/rbutilqt/tts.h
@@ -0,0 +1,116 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id: tts.h 15212 2007-10-19 21:49:07Z domonoky $
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20
21#ifndef TTS_H
22#define TTS_H
23
24#include "ui_ttsexescfgfrm.h"
25#include "ui_sapicfgfrm.h"
26#include <QtGui>
27
28
29class TTSBase;
30
31//inits the tts List
32void initTTSList();
33// function to get a specific tts
34TTSBase* getTTS(QString ttsname);
35// get the list of tts, nice names
36QStringList getTTSList();
37
38
39class TTSBase : public QDialog
40{
41 Q_OBJECT
42public:
43 TTSBase(QWidget *parent );
44 virtual bool voice(QString text,QString wavfile) {return false;}
45 virtual bool start(){return false;}
46 virtual bool stop(){return false;}
47 virtual void showCfg(){}
48 virtual bool configOk(){return false;}
49
50 void setUserCfg(QSettings *uSettings){userSettings = uSettings;}
51
52public slots:
53 virtual void accept(void){}
54 virtual void reject(void){}
55 virtual void reset(void){}
56
57protected:
58 QSettings *userSettings;
59};
60
61class TTSSapi : public TTSBase
62{
63 Q_OBJECT
64public:
65 TTSSapi(QWidget *parent = NULL);
66 virtual bool voice(QString text,QString wavfile);
67 virtual bool start();
68 virtual bool stop();
69 virtual void showCfg();
70 virtual bool configOk();
71
72public slots:
73 virtual void accept(void);
74 virtual void reject(void);
75 virtual void reset(void);
76 void browse(void);
77
78private:
79 Ui::SapiCfgFrm ui;
80 QProcess* voicescript;
81
82 QString defaultLanguage;
83
84 QString m_TTSexec;
85 QString m_TTSOpts;
86 QString m_TTSTemplate;
87 QString m_TTSLanguage;
88};
89
90class TTSExes : public TTSBase
91{
92 Q_OBJECT
93public:
94 TTSExes(QString name,QWidget *parent = NULL);
95 virtual bool voice(QString text,QString wavfile);
96 virtual bool start();
97 virtual bool stop() {return true;}
98 virtual void showCfg();
99 virtual bool configOk();
100
101public slots:
102 virtual void accept(void);
103 virtual void reject(void);
104 virtual void reset(void);
105 void browse(void);
106
107private:
108 Ui::TTSExesCfgFrm ui;
109 QString m_name;
110 QString m_TTSexec;
111 QString m_TTSOpts;
112 QString m_TTSTemplate;
113 QMap<QString,QString> m_TemplateMap;
114};
115
116#endif
diff --git a/rbutil/rbutilqt/ttsexescfgfrm.ui b/rbutil/rbutilqt/ttsexescfgfrm.ui
new file mode 100644
index 0000000000..8893d9ccf4
--- /dev/null
+++ b/rbutil/rbutilqt/ttsexescfgfrm.ui
@@ -0,0 +1,158 @@
1<ui version="4.0" >
2 <class>TTSExesCfgFrm</class>
3 <widget class="QDialog" name="TTSExesCfgFrm" >
4 <property name="geometry" >
5 <rect>
6 <x>0</x>
7 <y>0</y>
8 <width>463</width>
9 <height>214</height>
10 </rect>
11 </property>
12 <property name="windowTitle" >
13 <string>Configuration</string>
14 </property>
15 <layout class="QHBoxLayout" >
16 <item>
17 <widget class="QGroupBox" name="groupBox" >
18 <property name="title" >
19 <string>Configure TTS Engine</string>
20 </property>
21 <layout class="QVBoxLayout" >
22 <item>
23 <widget class="QLabel" name="label" >
24 <property name="sizePolicy" >
25 <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
26 <horstretch>0</horstretch>
27 <verstretch>255</verstretch>
28 </sizepolicy>
29 </property>
30 <property name="text" >
31 <string>Path to TTS Engine</string>
32 </property>
33 </widget>
34 </item>
35 <item>
36 <layout class="QHBoxLayout" >
37 <item>
38 <widget class="QLineEdit" name="ttspath" />
39 </item>
40 <item>
41 <widget class="QPushButton" name="browse" >
42 <property name="text" >
43 <string>&amp;Browse</string>
44 </property>
45 </widget>
46 </item>
47 </layout>
48 </item>
49 <item>
50 <widget class="QLabel" name="label_2" >
51 <property name="text" >
52 <string>TTS options</string>
53 </property>
54 </widget>
55 </item>
56 <item>
57 <widget class="QLineEdit" name="ttsoptions" />
58 </item>
59 <item>
60 <spacer>
61 <property name="orientation" >
62 <enum>Qt::Vertical</enum>
63 </property>
64 <property name="sizeHint" >
65 <size>
66 <width>20</width>
67 <height>40</height>
68 </size>
69 </property>
70 </spacer>
71 </item>
72 <item>
73 <layout class="QHBoxLayout" >
74 <item>
75 <widget class="QPushButton" name="reset" >
76 <property name="text" >
77 <string>Reset</string>
78 </property>
79 </widget>
80 </item>
81 <item>
82 <spacer>
83 <property name="orientation" >
84 <enum>Qt::Horizontal</enum>
85 </property>
86 <property name="sizeHint" >
87 <size>
88 <width>40</width>
89 <height>20</height>
90 </size>
91 </property>
92 </spacer>
93 </item>
94 <item>
95 <widget class="QPushButton" name="buttonOk" >
96 <property name="text" >
97 <string>&amp;Ok</string>
98 </property>
99 <property name="icon" >
100 <iconset resource="rbutilqt.qrc" >:/icons/icons/go-next.png</iconset>
101 </property>
102 </widget>
103 </item>
104 <item>
105 <widget class="QPushButton" name="buttonCancel" >
106 <property name="text" >
107 <string>&amp;Cancel</string>
108 </property>
109 <property name="icon" >
110 <iconset resource="rbutilqt.qrc" >:/icons/icons/process-stop.png</iconset>
111 </property>
112 </widget>
113 </item>
114 </layout>
115 </item>
116 </layout>
117 </widget>
118 </item>
119 </layout>
120 </widget>
121 <resources>
122 <include location="rbutilqt.qrc" />
123 </resources>
124 <connections>
125 <connection>
126 <sender>buttonOk</sender>
127 <signal>clicked()</signal>
128 <receiver>TTSExesCfgFrm</receiver>
129 <slot>accept()</slot>
130 <hints>
131 <hint type="sourcelabel" >
132 <x>253</x>
133 <y>147</y>
134 </hint>
135 <hint type="destinationlabel" >
136 <x>203</x>
137 <y>86</y>
138 </hint>
139 </hints>
140 </connection>
141 <connection>
142 <sender>buttonCancel</sender>
143 <signal>clicked()</signal>
144 <receiver>TTSExesCfgFrm</receiver>
145 <slot>reject()</slot>
146 <hints>
147 <hint type="sourcelabel" >
148 <x>352</x>
149 <y>147</y>
150 </hint>
151 <hint type="destinationlabel" >
152 <x>203</x>
153 <y>86</y>
154 </hint>
155 </hints>
156 </connection>
157 </connections>
158</ui>