diff options
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 96 | ||||
-rw-r--r-- | rbutil/rbutilqt/configurefrm.ui | 16 | ||||
-rw-r--r-- | rbutil/rbutilqt/installtalkwindow.cpp | 60 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutil.ini | 17 | ||||
-rw-r--r-- | rbutil/rbutilqt/talkfile.cpp | 110 | ||||
-rw-r--r-- | rbutil/rbutilqt/talkfile.h | 60 |
6 files changed, 276 insertions, 83 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 967e0111e9..f45eb42f14 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -128,18 +128,35 @@ void Config::accept() | |||
128 | userSettings->setValue("offline", ui.cacheOfflineMode->isChecked()); | 128 | userSettings->setValue("offline", ui.cacheOfflineMode->isChecked()); |
129 | 129 | ||
130 | // tts settings | 130 | // tts settings |
131 | if(QFileInfo(ui.ttsExecutable->text()).isExecutable()) | ||
132 | userSettings->setValue("ttsbin", ui.ttsExecutable->text()); | ||
133 | userSettings->setValue("ttsopts", ui.ttsOptions->text()); | ||
134 | if(QFileInfo(ui.encoderExecutable->text()).isExecutable()) | ||
135 | userSettings->setValue("encbin", ui.encoderExecutable->text()); | ||
136 | userSettings->setValue("ttsopts", ui.ttsOptions->text()); | ||
137 | QString preset; | 131 | QString preset; |
138 | preset = ui.comboEncoder->itemData(ui.comboEncoder->currentIndex(), Qt::UserRole).toString(); | ||
139 | userSettings->setValue("encpreset", preset); | ||
140 | preset = ui.comboTts->itemData(ui.comboTts->currentIndex(), Qt::UserRole).toString(); | 132 | preset = ui.comboTts->itemData(ui.comboTts->currentIndex(), Qt::UserRole).toString(); |
141 | userSettings->setValue("ttspreset", preset); | 133 | userSettings->setValue("ttspreset", preset); |
142 | 134 | userSettings->beginGroup(preset); | |
135 | |||
136 | if(QFileInfo(ui.ttsExecutable->text()).exists()) | ||
137 | userSettings->setValue("binary", ui.ttsExecutable->text()); | ||
138 | userSettings->setValue("options", ui.ttsOptions->text()); | ||
139 | userSettings->setValue("language", ui.ttsLanguage->text()); | ||
140 | devices->beginGroup(preset); | ||
141 | userSettings->setValue("template", devices->value("template").toString()); | ||
142 | userSettings->setValue("type", devices->value("tts").toString()); | ||
143 | devices->endGroup(); | ||
144 | userSettings->endGroup(); | ||
145 | |||
146 | //encoder settings | ||
147 | preset = ui.comboEncoder->itemData(ui.comboEncoder->currentIndex(), Qt::UserRole).toString(); | ||
148 | userSettings->setValue("encpreset", preset); | ||
149 | userSettings->beginGroup(preset); | ||
150 | |||
151 | if(QFileInfo(ui.encoderExecutable->text()).isExecutable()) | ||
152 | userSettings->setValue("binary", ui.encoderExecutable->text()); | ||
153 | userSettings->setValue("options", ui.encoderOptions->text()); | ||
154 | devices->beginGroup(preset); | ||
155 | userSettings->setValue("template", devices->value("template").toString()); | ||
156 | userSettings->setValue("type", devices->value("tts").toString()); | ||
157 | devices->endGroup(); | ||
158 | userSettings->endGroup(); | ||
159 | |||
143 | // sync settings | 160 | // sync settings |
144 | userSettings->sync(); | 161 | userSettings->sync(); |
145 | this->close(); | 162 | this->close(); |
@@ -302,7 +319,21 @@ void Config::setDevices(QSettings *dev) | |||
302 | devices->beginGroup("tts"); | 319 | devices->beginGroup("tts"); |
303 | keys = devices->allKeys(); | 320 | keys = devices->allKeys(); |
304 | for(int i=0; i < keys.size();i++) | 321 | for(int i=0; i < keys.size();i++) |
305 | ui.comboTts->addItem(devices->value(keys.at(i), "null").toString(), keys.at(i)); | 322 | { |
323 | devices->endGroup(); | ||
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 | } | ||
306 | devices->endGroup(); | 337 | devices->endGroup(); |
307 | 338 | ||
308 | int index; | 339 | int index; |
@@ -311,14 +342,12 @@ void Config::setDevices(QSettings *dev) | |||
311 | if(index < 0) index = 0; | 342 | if(index < 0) index = 0; |
312 | ui.comboTts->setCurrentIndex(index); | 343 | ui.comboTts->setCurrentIndex(index); |
313 | updateTtsOpts(index); | 344 | updateTtsOpts(index); |
314 | ui.ttsExecutable->setText(userSettings->value("ttsbin").toString()); | 345 | |
315 | |||
316 | index = ui.comboEncoder->findData(userSettings->value("encpreset").toString(), | 346 | index = ui.comboEncoder->findData(userSettings->value("encpreset").toString(), |
317 | Qt::UserRole, Qt::MatchExactly); | 347 | Qt::UserRole, Qt::MatchExactly); |
318 | if(index < 0) index = 0; | 348 | if(index < 0) index = 0; |
319 | ui.comboEncoder->setCurrentIndex(index); | 349 | ui.comboEncoder->setCurrentIndex(index); |
320 | updateEncOpts(index); | 350 | updateEncOpts(index); |
321 | ui.encoderExecutable->setText(userSettings->value("encbin").toString()); | ||
322 | 351 | ||
323 | } | 352 | } |
324 | 353 | ||
@@ -347,9 +376,9 @@ void Config::updateEncOpts(int index) | |||
347 | for(int i = 0; i < path.size(); i++) { | 376 | for(int i = 0; i < path.size(); i++) { |
348 | QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + e; | 377 | QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + e; |
349 | #if defined(Q_OS_WIN) | 378 | #if defined(Q_OS_WIN) |
350 | executable += ".exe"; | 379 | executable += ".exe"; |
351 | QStringList ex = executable.split("\"", QString::SkipEmptyParts); | 380 | QStringList ex = executable.split("\"", QString::SkipEmptyParts); |
352 | executable = ex.join(""); | 381 | executable = ex.join(""); |
353 | #endif | 382 | #endif |
354 | if(QFileInfo(executable).isExecutable()) { | 383 | if(QFileInfo(executable).isExecutable()) { |
355 | qDebug() << "found:" << executable; | 384 | qDebug() << "found:" << executable; |
@@ -360,6 +389,15 @@ void Config::updateEncOpts(int index) | |||
360 | break; | 389 | break; |
361 | } | 390 | } |
362 | } | 391 | } |
392 | |||
393 | //user settings | ||
394 | userSettings->beginGroup(c); | ||
395 | QString temp = userSettings->value("binary","null").toString(); | ||
396 | if(temp != "null") ui.encoderExecutable->setText(temp); | ||
397 | temp = userSettings->value("options","null").toString(); | ||
398 | if(temp != "null") ui.encoderOptions->setText(temp); | ||
399 | userSettings->endGroup(); | ||
400 | |||
363 | } | 401 | } |
364 | 402 | ||
365 | 403 | ||
@@ -367,14 +405,18 @@ void Config::updateTtsOpts(int index) | |||
367 | { | 405 | { |
368 | bool edit; | 406 | bool edit; |
369 | QString e; | 407 | QString e; |
408 | bool needsLanguageCfg; | ||
370 | QString c = ui.comboTts->itemData(index, Qt::UserRole).toString(); | 409 | QString c = ui.comboTts->itemData(index, Qt::UserRole).toString(); |
371 | devices->beginGroup(c); | 410 | devices->beginGroup(c); |
372 | edit = devices->value("edit").toBool(); | 411 | edit = devices->value("edit").toBool(); |
412 | needsLanguageCfg = devices->value("needslanguagecfg").toBool(); | ||
413 | ui.ttsLanguage->setVisible(needsLanguageCfg); | ||
414 | ui.ttsLanguageLabel->setVisible(needsLanguageCfg); | ||
373 | ui.ttsOptions->setText(devices->value("options").toString()); | 415 | ui.ttsOptions->setText(devices->value("options").toString()); |
374 | ui.ttsOptions->setEnabled(devices->value("edit").toBool()); | 416 | ui.ttsOptions->setEnabled(devices->value("edit").toBool()); |
375 | e = devices->value("tts").toString(); | 417 | e = devices->value("tts").toString(); |
376 | devices->endGroup(); | 418 | devices->endGroup(); |
377 | 419 | ||
378 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) | 420 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) |
379 | QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts); | 421 | QStringList path = QString(getenv("PATH")).split(":", QString::SkipEmptyParts); |
380 | #elif defined(Q_OS_WIN) | 422 | #elif defined(Q_OS_WIN) |
@@ -385,11 +427,11 @@ void Config::updateTtsOpts(int index) | |||
385 | for(int i = 0; i < path.size(); i++) { | 427 | for(int i = 0; i < path.size(); i++) { |
386 | QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + e; | 428 | QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + e; |
387 | #if defined(Q_OS_WIN) | 429 | #if defined(Q_OS_WIN) |
388 | executable += ".exe"; | 430 | executable += ".exe"; |
389 | QStringList ex = executable.split("\"", QString::SkipEmptyParts); | 431 | QStringList ex = executable.split("\"", QString::SkipEmptyParts); |
390 | executable = ex.join(""); | 432 | executable = ex.join(""); |
391 | #endif | 433 | #endif |
392 | qDebug() << executable; | 434 | qDebug() << executable; |
393 | if(QFileInfo(executable).isExecutable()) { | 435 | if(QFileInfo(executable).isExecutable()) { |
394 | ui.ttsExecutable->setText(QDir::toNativeSeparators(executable)); | 436 | ui.ttsExecutable->setText(QDir::toNativeSeparators(executable)); |
395 | // disallow changing the detected path if non-customizable profile | 437 | // disallow changing the detected path if non-customizable profile |
@@ -398,6 +440,16 @@ void Config::updateTtsOpts(int index) | |||
398 | break; | 440 | break; |
399 | } | 441 | } |
400 | } | 442 | } |
443 | |||
444 | //user settings | ||
445 | userSettings->beginGroup(c); | ||
446 | QString temp = userSettings->value("binary","null").toString(); | ||
447 | if(temp != "null") ui.ttsExecutable->setText(temp); | ||
448 | temp = userSettings->value("options","null").toString(); | ||
449 | if(temp != "null") ui.ttsOptions->setText(temp); | ||
450 | temp = userSettings->value("language","null").toString(); | ||
451 | if(temp != "null") ui.ttsLanguage->setText(temp); | ||
452 | userSettings->endGroup(); | ||
401 | } | 453 | } |
402 | 454 | ||
403 | 455 | ||
@@ -672,7 +724,7 @@ void Config::browseTts() | |||
672 | { | 724 | { |
673 | qDebug() << browser.getSelected(); | 725 | qDebug() << browser.getSelected(); |
674 | QString exe = browser.getSelected(); | 726 | QString exe = browser.getSelected(); |
675 | if(!QFileInfo(exe).isExecutable()) | 727 | if(!QFileInfo(exe).exists()) |
676 | return; | 728 | return; |
677 | ui.ttsExecutable->setText(exe); | 729 | ui.ttsExecutable->setText(exe); |
678 | } | 730 | } |
diff --git a/rbutil/rbutilqt/configurefrm.ui b/rbutil/rbutilqt/configurefrm.ui index 4533b44500..f0bd712091 100644 --- a/rbutil/rbutilqt/configurefrm.ui +++ b/rbutil/rbutilqt/configurefrm.ui | |||
@@ -5,8 +5,8 @@ | |||
5 | <rect> | 5 | <rect> |
6 | <x>0</x> | 6 | <x>0</x> |
7 | <y>0</y> | 7 | <y>0</y> |
8 | <width>500</width> | 8 | <width>548</width> |
9 | <height>435</height> | 9 | <height>472</height> |
10 | </rect> | 10 | </rect> |
11 | </property> | 11 | </property> |
12 | <property name="windowTitle" > | 12 | <property name="windowTitle" > |
@@ -23,7 +23,7 @@ | |||
23 | <item row="1" column="0" colspan="3" > | 23 | <item row="1" column="0" colspan="3" > |
24 | <widget class="QTabWidget" name="tabConfiguration" > | 24 | <widget class="QTabWidget" name="tabConfiguration" > |
25 | <property name="currentIndex" > | 25 | <property name="currentIndex" > |
26 | <number>0</number> | 26 | <number>4</number> |
27 | </property> | 27 | </property> |
28 | <widget class="QWidget" name="tabDevice" > | 28 | <widget class="QWidget" name="tabDevice" > |
29 | <attribute name="title" > | 29 | <attribute name="title" > |
@@ -414,6 +414,16 @@ | |||
414 | <item row="2" column="1" colspan="2" > | 414 | <item row="2" column="1" colspan="2" > |
415 | <widget class="QLineEdit" name="ttsOptions" /> | 415 | <widget class="QLineEdit" name="ttsOptions" /> |
416 | </item> | 416 | </item> |
417 | <item row="3" column="0" > | ||
418 | <widget class="QLabel" name="ttsLanguageLabel" > | ||
419 | <property name="text" > | ||
420 | <string>TTS Language</string> | ||
421 | </property> | ||
422 | </widget> | ||
423 | </item> | ||
424 | <item row="3" column="1" colspan="2" > | ||
425 | <widget class="QLineEdit" name="ttsLanguage" /> | ||
426 | </item> | ||
417 | </layout> | 427 | </layout> |
418 | </widget> | 428 | </widget> |
419 | </item> | 429 | </item> |
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp index 4324f693a9..4c341fa793 100644 --- a/rbutil/rbutilqt/installtalkwindow.cpp +++ b/rbutil/rbutilqt/installtalkwindow.cpp | |||
@@ -69,24 +69,41 @@ void InstallTalkWindow::accept() | |||
69 | connect(logger,SIGNAL(closed()),this,SLOT(close())); | 69 | connect(logger,SIGNAL(closed()),this,SLOT(close())); |
70 | 70 | ||
71 | QString folderToTalk = ui.lineTalkFolder->text(); | 71 | QString folderToTalk = ui.lineTalkFolder->text(); |
72 | QString pathEncoder = userSettings->value("encbin").toString(); | 72 | |
73 | QString pathTTS = userSettings->value("ttsbin").toString(); | 73 | // tts |
74 | 74 | QString preset = userSettings->value("ttspreset").toString(); | |
75 | userSettings->beginGroup(preset); | ||
76 | QString pathTTS = userSettings->value("binary").toString(); | ||
77 | QString ttsOpts = userSettings->value("options").toString(); | ||
78 | QString ttsLanguage = userSettings->value("language").toString(); | ||
79 | QString ttsTemplate = userSettings->value("template").toString(); | ||
80 | QString ttsType =userSettings->value("type").toString(); | ||
81 | userSettings->endGroup(); | ||
82 | |||
83 | //encoder | ||
84 | QString encoderPreset = userSettings->value("encpreset").toString(); | ||
85 | userSettings->beginGroup(encoderPreset); | ||
86 | QString pathEncoder = userSettings->value("binary").toString(); | ||
87 | QString encOpts = userSettings->value("options").toString(); | ||
88 | QString encTemplate = userSettings->value("template").toString(); | ||
89 | QString encType =userSettings->value("type").toString(); | ||
90 | userSettings->endGroup(); | ||
91 | |||
75 | if(!QFileInfo(folderToTalk).isDir()) | 92 | if(!QFileInfo(folderToTalk).isDir()) |
76 | { | 93 | { |
77 | logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR); | 94 | logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR); |
78 | logger->abort(); | 95 | logger->abort(); |
79 | return; | 96 | return; |
80 | } | 97 | } |
81 | 98 | ||
82 | if(!QFileInfo(pathEncoder).isExecutable()) | 99 | if(!QFileInfo(pathEncoder).isExecutable()) |
83 | { | 100 | { |
84 | logger->addItem(tr("Path to Encoder is wrong!"),LOGERROR); | 101 | logger->addItem(tr("Path to Encoder is wrong!"),LOGERROR); |
85 | logger->abort(); | 102 | logger->abort(); |
86 | return; | 103 | return; |
87 | } | 104 | } |
88 | 105 | ||
89 | if(!QFileInfo(pathTTS).isExecutable()) | 106 | if(!QFileInfo(pathTTS).exists()) |
90 | { | 107 | { |
91 | logger->addItem(tr("Path to TTS is wrong!"),LOGERROR); | 108 | logger->addItem(tr("Path to TTS is wrong!"),LOGERROR); |
92 | logger->abort(); | 109 | logger->abort(); |
@@ -99,21 +116,16 @@ void InstallTalkWindow::accept() | |||
99 | 116 | ||
100 | talkcreator->setDir(folderToTalk); | 117 | talkcreator->setDir(folderToTalk); |
101 | talkcreator->setTTSexe(pathTTS); | 118 | talkcreator->setTTSexe(pathTTS); |
119 | talkcreator->setTTsOpts(ttsOpts); | ||
120 | talkcreator->setTTsLanguage(ttsLanguage); | ||
121 | talkcreator->setTTsType(ttsType); | ||
122 | talkcreator->setTTsTemplate(ttsTemplate); | ||
123 | |||
102 | talkcreator->setEncexe(pathEncoder); | 124 | talkcreator->setEncexe(pathEncoder); |
103 | talkcreator->setEncOpts(userSettings->value("encopts").toString()); | 125 | talkcreator->setEncOpts(encOpts); |
104 | talkcreator->setTTsOpts(userSettings->value("ttsopts").toString()); | 126 | talkcreator->setEncTemplate(encTemplate); |
105 | 127 | talkcreator->setEncType(encType); | |
106 | devices->beginGroup(userSettings->value("ttspreset").toString()); | 128 | |
107 | talkcreator->setTTsType(devices->value("tts").toString()); | ||
108 | talkcreator->setTTsOpts(devices->value("options").toString()); | ||
109 | talkcreator->setTTsTemplate(devices->value("template").toString()); | ||
110 | devices->endGroup(); | ||
111 | devices->beginGroup(userSettings->value("encpreset").toString()); | ||
112 | talkcreator->setEncType(devices->value("encoder").toString()); | ||
113 | talkcreator->setEncOpts(devices->value("options").toString()); | ||
114 | talkcreator->setEncTemplate(devices->value("template").toString()); | ||
115 | devices->endGroup(); | ||
116 | |||
117 | talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked()); | 129 | talkcreator->setOverwriteTalk(ui.OverwriteTalk->isChecked()); |
118 | talkcreator->setOverwriteWav(ui.OverwriteWav->isChecked()); | 130 | talkcreator->setOverwriteWav(ui.OverwriteWav->isChecked()); |
119 | talkcreator->setRemoveWav(ui.RemoveWav->isChecked()); | 131 | talkcreator->setRemoveWav(ui.RemoveWav->isChecked()); |
diff --git a/rbutil/rbutilqt/rbutil.ini b/rbutil/rbutilqt/rbutil.ini index 74c0c4d92e..ea6a1a4cd4 100644 --- a/rbutil/rbutilqt/rbutil.ini +++ b/rbutil/rbutilqt/rbutil.ini | |||
@@ -399,27 +399,44 @@ ttspreset01 = "espeak (default)" | |||
399 | ttspreset02 = "espeak (user-adjusted)" | 399 | ttspreset02 = "espeak (user-adjusted)" |
400 | ttspreset03 = "flite (default)" | 400 | ttspreset03 = "flite (default)" |
401 | ttspreset04 = "flite (user-adjusted)" | 401 | ttspreset04 = "flite (user-adjusted)" |
402 | ttspreset05 = "sapi (default)" | ||
402 | 403 | ||
403 | [ttspreset01] | 404 | [ttspreset01] |
404 | tts = "espeak" | 405 | tts = "espeak" |
405 | options = "" | 406 | options = "" |
406 | template = "\"%exe\" %options -w \"%wavfile\" \"%text\"" | 407 | template = "\"%exe\" %options -w \"%wavfile\" \"%text\"" |
407 | edit = false | 408 | edit = false |
409 | os = all | ||
410 | needslanguagecfg = false | ||
408 | 411 | ||
409 | [ttspreset02] | 412 | [ttspreset02] |
410 | tts = "espeak" | 413 | tts = "espeak" |
411 | options = "" | 414 | options = "" |
412 | template = "\"%exe\" %options -w \"%wavfile\" \"%text\"" | 415 | template = "\"%exe\" %options -w \"%wavfile\" \"%text\"" |
413 | edit = true | 416 | edit = true |
417 | os = all | ||
418 | needslanguagecfg = false | ||
414 | 419 | ||
415 | [ttspreset03] | 420 | [ttspreset03] |
416 | tts = "flite" | 421 | tts = "flite" |
417 | options = "" | 422 | options = "" |
418 | template = "\"%exe\" %options -o \"%wavfile\" \"%text\"" | 423 | template = "\"%exe\" %options -o \"%wavfile\" \"%text\"" |
419 | edit = false | 424 | edit = false |
425 | os = all | ||
426 | needslanguagecfg = false | ||
420 | 427 | ||
421 | [ttspreset04] | 428 | [ttspreset04] |
422 | tts = "flite" | 429 | tts = "flite" |
423 | options = "" | 430 | options = "" |
424 | template = "\"%exe\" %options -o \"%wavfile\" \"%text\"" | 431 | template = "\"%exe\" %options -o \"%wavfile\" \"%text\"" |
425 | edit = true | 432 | edit = true |
433 | os = all | ||
434 | needslanguagecfg = false | ||
435 | |||
436 | [ttspreset05] | ||
437 | tts = "sapi" | ||
438 | options = "" | ||
439 | template = "cscript //nologo \"%exe\" /language:english %options" | ||
440 | edit = false | ||
441 | os = win32 | ||
442 | needslanguagecfg = true | ||
diff --git a/rbutil/rbutilqt/talkfile.cpp b/rbutil/rbutilqt/talkfile.cpp index 2096c8150b..d3e3a24781 100644 --- a/rbutil/rbutilqt/talkfile.cpp +++ b/rbutil/rbutilqt/talkfile.cpp | |||
@@ -38,26 +38,24 @@ bool TalkFileCreator::initEncoder() | |||
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | bool TalkFileCreator::initTTS() | ||
42 | { | ||
43 | QFileInfo tts(m_TTSexec); | ||
44 | |||
45 | if(tts.exists()) | ||
46 | { | ||
47 | return true; | ||
48 | } | ||
49 | else | ||
50 | { | ||
51 | return false; | ||
52 | } | ||
53 | } | ||
54 | 41 | ||
55 | bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | 42 | bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) |
56 | { | 43 | { |
57 | m_abort = false; | 44 | m_abort = false; |
58 | m_logger = logger; | 45 | m_logger = logger; |
59 | m_logger->addItem("Starting Talkfile generation",LOGINFO); | 46 | m_logger->addItem("Starting Talkfile generation",LOGINFO); |
60 | if(!initTTS()) | 47 | |
48 | if(m_curTTS == "sapi") | ||
49 | m_tts = new TTSSapi(); | ||
50 | else | ||
51 | m_tts = new TTSExes(); | ||
52 | |||
53 | m_tts->setTTSexe(m_TTSexec); | ||
54 | m_tts->setTTsOpts(m_TTSOpts); | ||
55 | m_tts->setTTsLanguage(m_TTSLanguage); | ||
56 | m_tts->setTTsTemplate(m_curTTSTemplate); | ||
57 | |||
58 | if(!m_tts->start()) | ||
61 | { | 59 | { |
62 | m_logger->addItem("Init of TTS engine failed",LOGERROR); | 60 | m_logger->addItem("Init of TTS engine failed",LOGERROR); |
63 | return false; | 61 | return false; |
@@ -65,6 +63,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
65 | if(!initEncoder()) | 63 | if(!initEncoder()) |
66 | { | 64 | { |
67 | m_logger->addItem("Init of encoder failed",LOGERROR); | 65 | m_logger->addItem("Init of encoder failed",LOGERROR); |
66 | m_tts->stop(); | ||
68 | return false; | 67 | return false; |
69 | } | 68 | } |
70 | QApplication::processEvents(); | 69 | QApplication::processEvents(); |
@@ -80,6 +79,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
80 | if(m_abort) | 79 | if(m_abort) |
81 | { | 80 | { |
82 | m_logger->addItem("Talkfile creation aborted",LOGERROR); | 81 | m_logger->addItem("Talkfile creation aborted",LOGERROR); |
82 | m_tts->stop(); | ||
83 | return false; | 83 | return false; |
84 | } | 84 | } |
85 | 85 | ||
@@ -117,10 +117,11 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
117 | if(!wavfilenameInf.exists() || m_overwriteWav) | 117 | if(!wavfilenameInf.exists() || m_overwriteWav) |
118 | { | 118 | { |
119 | m_logger->addItem("Voicing of " + toSpeak,LOGINFO); | 119 | m_logger->addItem("Voicing of " + toSpeak,LOGINFO); |
120 | if(!voice(toSpeak,wavfilename)) | 120 | if(!m_tts->voice(toSpeak,wavfilename)) |
121 | { | 121 | { |
122 | m_logger->addItem("Voicing of " + toSpeak + " failed",LOGERROR); | 122 | m_logger->addItem("Voicing of " + toSpeak + " failed",LOGERROR); |
123 | m_logger->abort(); | 123 | m_logger->abort(); |
124 | m_tts->stop(); | ||
124 | return false; | 125 | return false; |
125 | } | 126 | } |
126 | } | 127 | } |
@@ -129,6 +130,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
129 | { | 130 | { |
130 | m_logger->addItem("Encoding of " + wavfilename + " failed",LOGERROR); | 131 | m_logger->addItem("Encoding of " + wavfilename + " failed",LOGERROR); |
131 | m_logger->abort(); | 132 | m_logger->abort(); |
133 | m_tts->stop(); | ||
132 | return false; | 134 | return false; |
133 | } | 135 | } |
134 | } | 136 | } |
@@ -148,6 +150,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
148 | } | 150 | } |
149 | 151 | ||
150 | installlog.endGroup(); | 152 | installlog.endGroup(); |
153 | m_tts->stop(); | ||
151 | m_logger->addItem("Finished creating Talkfiles",LOGOK); | 154 | m_logger->addItem("Finished creating Talkfiles",LOGOK); |
152 | m_logger->setProgressMax(1); | 155 | m_logger->setProgressMax(1); |
153 | m_logger->setProgressValue(1); | 156 | m_logger->setProgressValue(1); |
@@ -162,33 +165,82 @@ void TalkFileCreator::abort() | |||
162 | m_abort = true; | 165 | m_abort = true; |
163 | } | 166 | } |
164 | 167 | ||
165 | bool TalkFileCreator::voice(QString text,QString wavfile) | 168 | bool TalkFileCreator::encode(QString input,QString output) |
166 | { | 169 | { |
170 | qDebug() << "encoding.."; | ||
171 | QString execstring = m_curEncTemplate; | ||
167 | 172 | ||
168 | QString execstring = m_curTTSTemplate; | 173 | execstring.replace("%exe",m_EncExec); |
174 | execstring.replace("%options",m_EncOpts); | ||
175 | execstring.replace("%input",input); | ||
176 | execstring.replace("%output",output); | ||
177 | qDebug() << execstring; | ||
178 | QProcess::execute(execstring); | ||
179 | return true; | ||
180 | |||
181 | } | ||
169 | 182 | ||
183 | bool TTSSapi::start() | ||
184 | { | ||
185 | QFileInfo tts(m_TTSexec); | ||
186 | if(!tts.exists()) | ||
187 | return false; | ||
188 | |||
189 | // create the voice process | ||
190 | QString execstring = m_TTSTemplate; | ||
170 | execstring.replace("%exe",m_TTSexec); | 191 | execstring.replace("%exe",m_TTSexec); |
171 | execstring.replace("%options",m_TTSOpts); | 192 | execstring.replace("%options",m_TTSOpts); |
172 | execstring.replace("%wavfile",wavfile); | 193 | qDebug() << "init" << execstring; |
173 | execstring.replace("%text",text); | 194 | voicescript = new QProcess(NULL); |
195 | voicescript->start(execstring); | ||
196 | if(!voicescript->waitForStarted()) | ||
197 | return false; | ||
198 | return true; | ||
199 | } | ||
174 | 200 | ||
175 | QProcess::execute(execstring); | 201 | bool TTSSapi::voice(QString text,QString wavfile) |
202 | { | ||
203 | QString query = "SPEAK\t"+wavfile+"\t"+text+"\r\n"; | ||
204 | qDebug() << "voicing" << query; | ||
205 | voicescript->write(query.toLocal8Bit()); | ||
206 | voicescript->write("SYNC\tbla\r\n"); | ||
207 | voicescript->waitForReadyRead(); | ||
176 | return true; | 208 | return true; |
209 | } | ||
177 | 210 | ||
211 | bool TTSSapi::stop() | ||
212 | { | ||
213 | QString query = "QUIT\r\n"; | ||
214 | voicescript->write(query.toLocal8Bit()); | ||
215 | voicescript->waitForFinished(); | ||
216 | delete voicescript; | ||
217 | return true; | ||
178 | } | 218 | } |
179 | 219 | ||
180 | bool TalkFileCreator::encode(QString input,QString output) | 220 | bool TTSExes::start() |
181 | { | 221 | { |
182 | QString execstring = m_curEncTemplate; | 222 | QFileInfo tts(m_TTSexec); |
223 | qDebug() << "ttsexe init"; | ||
224 | if(tts.exists()) | ||
225 | { | ||
226 | return true; | ||
227 | } | ||
228 | else | ||
229 | { | ||
230 | return false; | ||
231 | } | ||
232 | } | ||
183 | 233 | ||
184 | execstring.replace("%exe",m_EncExec); | 234 | bool TTSExes::voice(QString text,QString wavfile) |
185 | execstring.replace("%options",m_EncOpts); | 235 | { |
186 | execstring.replace("%input",input); | 236 | QString execstring = m_TTSTemplate; |
187 | execstring.replace("%output",output); | ||
188 | 237 | ||
238 | execstring.replace("%exe",m_TTSexec); | ||
239 | execstring.replace("%options",m_TTSOpts); | ||
240 | execstring.replace("%wavfile",wavfile); | ||
241 | execstring.replace("%text",text); | ||
242 | qDebug() << "voicing" << execstring; | ||
189 | QProcess::execute(execstring); | 243 | QProcess::execute(execstring); |
190 | return true; | 244 | return true; |
191 | 245 | ||
192 | } | 246 | } \ No newline at end of file |
193 | |||
194 | |||
diff --git a/rbutil/rbutilqt/talkfile.h b/rbutil/rbutilqt/talkfile.h index f2119bc447..b2d6aa4483 100644 --- a/rbutil/rbutilqt/talkfile.h +++ b/rbutil/rbutilqt/talkfile.h | |||
@@ -23,6 +23,29 @@ | |||
23 | 23 | ||
24 | #include "progressloggerinterface.h" | 24 | #include "progressloggerinterface.h" |
25 | 25 | ||
26 | class TTSBase : public QObject | ||
27 | { | ||
28 | Q_OBJECT | ||
29 | public: | ||
30 | TTSBase(){} | ||
31 | virtual ~TTSBase(){} | ||
32 | virtual bool voice(QString text,QString wavfile){return false;} | ||
33 | virtual bool start(){return false;} | ||
34 | virtual bool stop(){return false;} | ||
35 | |||
36 | void setTTSexe(QString exe){m_TTSexec=exe;} | ||
37 | void setTTsOpts(QString opts) {m_TTSOpts=opts;} | ||
38 | void setTTsLanguage(QString language) {m_TTSLanguage = language;} | ||
39 | void setTTsTemplate(QString t) { m_TTSTemplate = t; } | ||
40 | |||
41 | protected: | ||
42 | QString m_TTSexec; | ||
43 | QString m_TTSOpts; | ||
44 | QString m_TTSTemplate; | ||
45 | QString m_TTSLanguage; | ||
46 | }; | ||
47 | |||
48 | |||
26 | class TalkFileCreator :public QObject | 49 | class TalkFileCreator :public QObject |
27 | { | 50 | { |
28 | Q_OBJECT | 51 | Q_OBJECT |
@@ -37,6 +60,7 @@ public: | |||
37 | 60 | ||
38 | void setTTsType(QString tts) { m_curTTS = tts; } | 61 | void setTTsType(QString tts) { m_curTTS = tts; } |
39 | void setTTsOpts(QString opts) {m_TTSOpts=opts;} | 62 | void setTTsOpts(QString opts) {m_TTSOpts=opts;} |
63 | void setTTsLanguage(QString language) {m_TTSLanguage = language;} | ||
40 | void setTTsTemplate(QString t) { m_curTTSTemplate = t; } | 64 | void setTTsTemplate(QString t) { m_curTTSTemplate = t; } |
41 | 65 | ||
42 | void setEncType(QString enc) { m_curEnc = enc; } | 66 | void setEncType(QString enc) { m_curEnc = enc; } |
@@ -56,19 +80,20 @@ private slots: | |||
56 | void abort(); | 80 | void abort(); |
57 | 81 | ||
58 | private: | 82 | private: |
59 | 83 | TTSBase* m_tts; | |
60 | bool initTTS(); | 84 | //bool initTTS(); |
61 | bool stopTTS(); | 85 | //bool stopTTS(); |
62 | bool initEncoder(); | 86 | bool initEncoder(); |
63 | 87 | ||
64 | bool encode(QString input,QString output); | 88 | bool encode(QString input,QString output); |
65 | bool voice(QString text,QString wavfile); | 89 | //bool voice(QString text,QString wavfile); |
66 | 90 | ||
67 | QString m_dir; | 91 | QString m_dir; |
68 | QString m_mountpoint; | 92 | QString m_mountpoint; |
69 | QString m_curTTS; | 93 | QString m_curTTS; |
70 | QString m_TTSexec; | 94 | QString m_TTSexec; |
71 | QString m_TTSOpts; | 95 | QString m_TTSOpts; |
96 | QString m_TTSLanguage; | ||
72 | QString m_curTTSTemplate; | 97 | QString m_curTTSTemplate; |
73 | 98 | ||
74 | QString m_curEnc; | 99 | QString m_curEnc; |
@@ -87,4 +112,29 @@ private: | |||
87 | bool m_abort; | 112 | bool m_abort; |
88 | }; | 113 | }; |
89 | 114 | ||
115 | class TTSSapi : public TTSBase | ||
116 | { | ||
117 | public: | ||
118 | TTSSapi() {}; | ||
119 | virtual bool voice(QString text,QString wavfile); | ||
120 | virtual bool start(); | ||
121 | virtual bool stop(); | ||
122 | |||
123 | private: | ||
124 | QProcess* voicescript; | ||
125 | }; | ||
126 | |||
127 | class TTSExes : public TTSBase | ||
128 | { | ||
129 | public: | ||
130 | TTSExes() {}; | ||
131 | virtual bool voice(QString text,QString wavfile); | ||
132 | virtual bool start(); | ||
133 | virtual bool stop() {return true;} | ||
134 | |||
135 | private: | ||
136 | |||
137 | }; | ||
138 | |||
90 | #endif | 139 | #endif |
140 | |||