From 9f686700d47e8fcfa0fec65bfbfcf5d5cde3f752 Mon Sep 17 00:00:00 2001 From: Dominik Wenger Date: Fri, 11 Jan 2008 23:59:12 +0000 Subject: rbutil: added creation of voice files with rbutil. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16059 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/rbutilqt/createvoicefrm.ui | 191 +++++++++++++++++++++++ rbutil/rbutilqt/createvoicewindow.cpp | 113 ++++++++++++++ rbutil/rbutilqt/createvoicewindow.h | 56 +++++++ rbutil/rbutilqt/rbutil.ini | 141 +++++++++-------- rbutil/rbutilqt/rbutilqt.cpp | 16 ++ rbutil/rbutilqt/rbutilqt.h | 1 + rbutil/rbutilqt/rbutilqt.pro | 19 ++- rbutil/rbutilqt/rbutilqt.qrc | 3 + rbutil/rbutilqt/rbutilqtfrm.ui | 57 ++++++- rbutil/rbutilqt/tts.cpp | 4 +- rbutil/rbutilqt/voicefile.cpp | 275 ++++++++++++++++++++++++++++++++++ rbutil/rbutilqt/voicefile.h | 84 +++++++++++ 12 files changed, 871 insertions(+), 89 deletions(-) create mode 100644 rbutil/rbutilqt/createvoicefrm.ui create mode 100644 rbutil/rbutilqt/createvoicewindow.cpp create mode 100644 rbutil/rbutilqt/createvoicewindow.h create mode 100644 rbutil/rbutilqt/voicefile.cpp create mode 100644 rbutil/rbutilqt/voicefile.h (limited to 'rbutil') diff --git a/rbutil/rbutilqt/createvoicefrm.ui b/rbutil/rbutilqt/createvoicefrm.ui new file mode 100644 index 0000000000..8847409f37 --- /dev/null +++ b/rbutil/rbutilqt/createvoicefrm.ui @@ -0,0 +1,191 @@ + + CreateVoiceFrm + + + Qt::WindowModal + + + + 0 + 0 + 637 + 421 + + + + Create Voice File + + + + + + + + + :/icons/icons/wizard.xpm + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + Select the Language you want to generate a voicefile for: + + + + + + + + + + Generation settings + + + + + + Encoder profile: + + + + + + + TTS profile: + + + + + + + + 0 + 0 + + + + Change + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 201 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + &Install + + + :/icons/icons/go-next.png + + + + + + + &Cancel + + + :/icons/icons/process-stop.png + + + + + + + + + change + buttonOk + buttonCancel + + + + + + + buttonOk + clicked() + CreateVoiceFrm + accept() + + + 472 + 418 + + + 382 + 328 + + + + + buttonCancel + clicked() + CreateVoiceFrm + reject() + + + 561 + 428 + + + 522 + 332 + + + + + diff --git a/rbutil/rbutilqt/createvoicewindow.cpp b/rbutil/rbutilqt/createvoicewindow.cpp new file mode 100644 index 0000000000..b8a14498de --- /dev/null +++ b/rbutil/rbutilqt/createvoicewindow.cpp @@ -0,0 +1,113 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Riebeling + * $Id: createvoicewindow.cpp 15932 2007-12-15 13:13:57Z domonoky $ + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "createvoicewindow.h" +#include "ui_createvoicefrm.h" + +#include "browsedirtree.h" +#include "configure.h" + +CreateVoiceWindow::CreateVoiceWindow(QWidget *parent) : QDialog(parent) +{ + ui.setupUi(this); + voicecreator = new VoiceFileCreator(this); + + connect(ui.change,SIGNAL(clicked()),this,SLOT(change())); +} + +void CreateVoiceWindow::change() +{ + Config *cw = new Config(this,4); + cw->setUserSettings(userSettings); + cw->setDevices(devices); + cw->show(); + connect(cw, SIGNAL(settingsUpdated()), this, SIGNAL(settingsUpdated())); +} + +void CreateVoiceWindow::accept() +{ + logger = new ProgressLoggerGui(this); + logger->show(); + connect(logger,SIGNAL(closed()),this,SLOT(close())); + + QString platform = userSettings->value("platform").toString(); + QString lang = ui.comboLanguage->currentText(); + + //safe selected language + userSettings->setValue("voicelanguage",lang); + userSettings->sync(); + + //configure voicecreator + voicecreator->setUserSettings(userSettings); + voicecreator->setDeviceSettings(devices); + voicecreator->setMountPoint(userSettings->value("mountpoint").toString()); + voicecreator->setTargetId(devices->value(platform + "/targetid").toInt()); + voicecreator->setLang(lang); + voicecreator->setProxy(m_proxy); + + //start creating + voicecreator->createVoiceFile(logger); +} + + + +void CreateVoiceWindow::setDeviceSettings(QSettings *dev) +{ + devices = dev; + qDebug() << "Install::setDeviceSettings:" << devices; + + // fill in language combobox + devices->beginGroup("languages"); + QStringList keys = devices->allKeys(); + QStringList languages; + for(int i =0 ; i < keys.size();i++) + { + languages << devices->value(keys.at(i)).toString(); + } + devices->endGroup(); + + ui.comboLanguage->addItems(languages); + // set saved lang + ui.comboLanguage->setCurrentIndex(ui.comboLanguage->findText(userSettings->value("voicelanguage").toString())); +} + +void CreateVoiceWindow::setUserSettings(QSettings *user) +{ + userSettings = user; + + QString ttsName = userSettings->value("tts", "none").toString(); + TTSBase* tts = getTTS(ttsName); + tts->setUserCfg(userSettings); + if(tts->configOk()) + ui.labelTtsProfile->setText(tr("Selected TTS engine : %1").arg(ttsName)); + else + ui.labelTtsProfile->setText(tr("Selected TTS Engine: %1").arg("Invalid TTS configuration!")); + + QString encoder = userSettings->value("encoder", "none").toString(); + EncBase* enc = getEncoder(encoder); + enc->setUserCfg(userSettings); + if(enc->configOk()) + ui.labelEncProfile->setText(tr("Selected Encoder: %1").arg(encoder)); + else + ui.labelEncProfile->setText(tr("Selected Encoder: %1").arg("Invalid encoder configuration!")); + +} + + + diff --git a/rbutil/rbutilqt/createvoicewindow.h b/rbutil/rbutilqt/createvoicewindow.h new file mode 100644 index 0000000000..76472721fe --- /dev/null +++ b/rbutil/rbutilqt/createvoicewindow.h @@ -0,0 +1,56 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Wenger + * $Id: installtalkwindow.h 15926 2007-12-14 19:49:11Z domonoky $ + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef CREATEVOICEWINDOW_H +#define CREATEVOICEWINDOW_H + +#include + +#include + +#include "ui_createvoicefrm.h" +#include "progressloggergui.h" +#include "voicefile.h" + +class CreateVoiceWindow : public QDialog +{ + Q_OBJECT + public: + CreateVoiceWindow(QWidget *parent = 0); + void setUserSettings(QSettings*); + void setDeviceSettings(QSettings*); + void setProxy(QUrl proxy){m_proxy = proxy;} + + signals: + void settingsUpdated(void); + + public slots: + void accept(void); + void change(void); + + private: + VoiceFileCreator* voicecreator; + Ui::CreateVoiceFrm ui; + ProgressLoggerGui* logger; + QSettings *devices; + QSettings *userSettings; + QUrl m_proxy; +}; + +#endif diff --git a/rbutil/rbutilqt/rbutil.ini b/rbutil/rbutilqt/rbutil.ini index 1c118a5959..2f2e904ab4 100644 --- a/rbutil/rbutilqt/rbutil.ini +++ b/rbutil/rbutilqt/rbutil.ini @@ -13,6 +13,7 @@ themes_url=http://www.rockbox-themes.org manual_url=http://download.rockbox.org/manual doom_url=http://download.rockbox.org/useful/rockdoom.zip voice_url=http://www.rockbox.org/voices/ +genlang_url=http://www.rockbox.org/genlang/ [platforms] platform01=player @@ -56,6 +57,7 @@ resolution=11x2x1 manualname= brand=Archos voicename=player +targetid=1 [recorder] name="Jukebox Recorder 6 / 10 / 15 / 20" @@ -68,6 +70,7 @@ resolution=112x64x1 manualname= brand=Archos voicename=recorder +targetid=2 [recorder8mb] name="Jukebox Recorder 6 / 10 / 15 / 20 (with 8MiB memory)" @@ -80,6 +83,7 @@ resolution=112x64x1 manualname=rockbox-recorder brand=Archos voicename=recorder +targetid=2 [recorderv2] name="Jukebox Recorder v2 (20GB)" @@ -92,6 +96,7 @@ resolution=112x64x1 manualname= brand=Archos voicename=recorderv2 +targetid=4 [fmrecorder] name="Jukebox Recorder FM" @@ -104,6 +109,7 @@ resolution=112x64x1 manualname= brand=Archos voicename=fmrecorder +targetid=3 [fmrecorder8mb] name="Jukebox Recorder FM (with 8MiB memory)" @@ -116,6 +122,7 @@ resolution=112x64x1 manualname=rockbox-fmrecorder brand=Archos voicename=fmrecorder +targetid=3 [ondiosp] name="Ondio SP" @@ -128,6 +135,7 @@ resolution=112x64x1 manualname= brand=Archos voicename=ondiosp +targetid=7 [ondiofm] name="Ondio FM" @@ -140,6 +148,7 @@ resolution=112x64x1 manualname= brand=Archos voicename=ondiofm +targetid=8 [h100] name="iHP100 / iHP110" @@ -153,6 +162,7 @@ manualname=rockbox-h100 brand=Iriver usbid=0x10063001 voicename=h100 +targetid=11 [h120] name="iHP120 / iHP140 / H120 / H140" @@ -166,6 +176,7 @@ manualname=rockbox-h100 brand=Iriver usbid=0x10063002 voicename=h120 +targetid=9 [h300] name="H320 / H340" @@ -179,6 +190,7 @@ manualname=rockbox-h300 brand=Iriver usbid=0x10063003 voicename=h300 +targetid=10 [h10_5gbums] name="H10 (5 / 6GB) UMS" @@ -192,6 +204,7 @@ manualname= brand=Iriver usbid=0x41022002 voicename=h10_5gb +targetid=24 [h10_5gbmtp] name="H10 (5 / 6GB) MTP" @@ -205,6 +218,7 @@ manualname= brand=Iriver usbid=0x41022105 voicename=h10_5gb +targetid=24 [h10] name="H10 (20GB)" @@ -219,6 +233,7 @@ brand=Iriver usbid=0x0b7000ba usberror=0x41022101 voicename=h10 +targetid=22 [ipod1g2g] name="Ipod (1st / 2nd gen)" @@ -231,6 +246,7 @@ resolution=160x128x2 manualname= brand=Apple voicename=ipod1g2g +targetid=29 [ipodcolor] name="Ipod Colour / Photo / U2 (4th gen)" @@ -243,6 +259,7 @@ resolution=220x176x16 manualname= brand=Apple voicename=ipodcolor +targetid=13 [ipodnano] name="Ipod Nano (1st gen)" @@ -256,6 +273,7 @@ manualname= brand=Apple usbid=0x05ac120a voicename=ipodnano +targetid=14 [ipod4gray] name="Ipod (4th gen, greyscale)" @@ -268,6 +286,7 @@ resolution=160x128x2 manualname= brand=Apple voicename=ipod4gray +targetid=17 [ipodvideo] name="Ipod Video (5th gen) 30GB" @@ -280,6 +299,7 @@ resolution=320x240x16 manualname= brand=Apple voicename=ipodvideo +targetid=15 [ipodvideo64mb] name="Ipod Video (5th gen) 60/80GB" @@ -292,6 +312,7 @@ resolution=320x240x16 manualname= brand=Apple voicename=ipodvideo +targetid=15 [ipod3g] name="Ipod (3rd gen)" @@ -305,6 +326,7 @@ manualname= brand=Apple usbid=0x05ac1201 voicename=ipod3g +targetid=16 [ipodmini1g] name="Ipod Mini (1st gen)" @@ -317,6 +339,7 @@ resolution=138x110x2 manualname=rockbox-ipodmini2g brand=Apple voicename=ipodmini1g +targetid=18 [ipodmini2g] name="Ipod Mini (2nd gen)" @@ -329,6 +352,7 @@ resolution=138x110x2 manualname=rockbox-ipodmini2g brand=Apple voicename=ipodmini2g +targetid=21 [iaudiox5] name="iAudio X5 / X5L" @@ -343,6 +367,7 @@ brand=Cowon usbid=0x0e210510 usbid=0x0e210513 voicename=iaudiox5 +targetid=12 [iaudiox5v] name="iAudio X5V" @@ -355,6 +380,7 @@ resolution=160x128x2 manualname= brand=Cowon voicename=iaudiox5v +targetid=12 [iaudiom5] name="iAudio M5 / M5L" @@ -368,6 +394,7 @@ manualname= brand=Cowon usbid=0x0e210520 voicename=iaudiom5 +targetid=28 [gigabeatf] name="Gigabeat F / X" @@ -380,6 +407,7 @@ manualname= brand=Toshiba usbid=0x09300009 voicename=gigabeatf +targetid=20 [sansae200] name="Sansa E200" @@ -394,6 +422,7 @@ brand=Sandisk usbid=0x07817421 usberror=0x07810720 voicename=sansae200 +targetid=23 [sansac200] name="Sansa C200" @@ -406,80 +435,44 @@ resolution=132x80x16 manualname= brand=Sandisk voicename=sansac200 +targetid=30 + +[languages] +lang1=africaans +lang2=bulgarian +lang3=catala +lang4=chinese-simp +lang5=chinese-trad +lang6=czech +lang7=dansk +lang8=deutsch +lang9=eesti +lang10=english +lang11=espanol +lang12=esperanto +lang13=finnish +lang14=francais +lang15=galego +lang16=greek +lang17=hebrew +lang18=islenska +lang19=italiano +lang20=japanese +lang21=korean +lang22=magyar +lang23=nederlands +lang24=norsk +lang25=norsk-nynorsk +lang26=polski +lang27=portugues +lang28=portugues-brasileiro +lang29=romaneste +lang30=russian +lang31=slovenscina +lang32=svenska +lang33=thai +lang34=turkce +lang35=wallisertitsch -[tts] -ttspreset01 = "espeak (default)" -ttspreset02 = "espeak (user-adjusted)" -ttspreset03 = "flite (default)" -ttspreset04 = "flite (user-adjusted)" -ttspreset05 = "sapi (default)" -ttspreset06 = "sapi (user-adjusted)" -ttspreset07 = "swift (default)" -ttspreset08 = "swift (user-adjusted)" - - -[ttspreset01] -tts = "espeak" -options = "" -template = "\"%exe\" \"%options\" -w \"%wavfile\" \"%text\"" -edit = false -os = all -needslanguagecfg = false - -[ttspreset02] -tts = "espeak" -options = "" -template = "\"%exe\" \"%options\" -w \"%wavfile\" \"%text\"" -edit = true -os = all -needslanguagecfg = false - -[ttspreset03] -tts = "flite" -options = "" -template = "\"%exe\" \"%options\" -o \"%wavfile\" \"%text\"" -edit = false -os = all -needslanguagecfg = false - -[ttspreset04] -tts = "flite" -options = "" -template = "\"%exe\" \"%options\" -o \"%wavfile\" \"%text\"" -edit = true -os = all -needslanguagecfg = false - -[ttspreset05] -tts = "sapi" -options = "" -template = "cscript //nologo \"%exe\" /language:%lang \"%options\"" -edit = false -os = win32 -needslanguagecfg = true - -[ttspreset06] -tts = "sapi" -options = "" -template = "cscript //nologo \"%exe\" /language:%lang \"%options\"" -edit = true -os = win32 -needslanguagecfg = true - -[ttspreset07] -tts = "swift" -options = "" -template = "\"%exe\" \"%options\" -o \"%wavfile\" \"%text\"" -edit = false -os = all -needslanguagecfg = false - -[ttspreset08] -tts = "swift" -options = "" -template = "\"%exe\" \"%options\" -o \"%wavfile\" \"%text\"" -edit = true -os = all -needslanguagecfg = false diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 7d0a887849..a28defc413 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -26,6 +26,7 @@ #include "configure.h" #include "install.h" #include "installtalkwindow.h" +#include "createvoicewindow.h" #include "httpget.h" #include "installbootloader.h" #include "installthemes.h" @@ -89,6 +90,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent) connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFontsBtn())); connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoomBtn())); connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles())); + connect(ui.buttonCreateVoice, SIGNAL(clicked()), this, SLOT(createVoiceFile())); connect(ui.buttonVoice, SIGNAL(clicked()), this, SLOT(installVoice())); connect(ui.buttonThemes, SIGNAL(clicked()), this, SLOT(installThemes())); connect(ui.buttonRemoveRockbox, SIGNAL(clicked()), this, SLOT(uninstall())); @@ -106,6 +108,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent) connect(ui.actionInstall_Themes, SIGNAL(triggered()), this, SLOT(installThemes())); connect(ui.actionInstall_Game_Files, SIGNAL(triggered()), this, SLOT(installDoomBtn())); connect(ui.actionInstall_Voice_File, SIGNAL(triggered()), this, SLOT(installVoice())); + connect(ui.actionCreate_Voice_File, SIGNAL(triggered()), this, SLOT(createVoiceFile())); connect(ui.actionCreate_Talk_Files, SIGNAL(triggered()), this, SLOT(createTalkFiles())); connect(ui.actionRemove_bootloader, SIGNAL(triggered()), this, SLOT(uninstallBootloader())); connect(ui.actionUninstall_Rockbox, SIGNAL(triggered()), this, SLOT(uninstall())); @@ -753,6 +756,19 @@ void RbUtilQt::createTalkFiles(void) } +void RbUtilQt::createVoiceFile(void) +{ + if(chkConfig(true)) return; + CreateVoiceWindow *installWindow = new CreateVoiceWindow(this); + installWindow->setUserSettings(userSettings); + installWindow->setDeviceSettings(devices); + installWindow->setProxy(proxy()); + + installWindow->show(); + connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(downloadInfo())); + connect(installWindow, SIGNAL(settingsUpdated()), this, SLOT(updateSettings())); +} + void RbUtilQt::uninstall(void) { if(chkConfig(true)) return; diff --git a/rbutil/rbutilqt/rbutilqt.h b/rbutil/rbutilqt/rbutilqt.h index f656caf451..f030d69f3c 100644 --- a/rbutil/rbutilqt/rbutilqt.h +++ b/rbutil/rbutilqt/rbutilqt.h @@ -91,6 +91,7 @@ class RbUtilQt : public QMainWindow void installDoom(void); void createTalkFiles(void); + void createVoiceFile(void); void downloadDone(bool); void downloadDone(int, bool); void downloadBleedingDone(bool); diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro index b240770c33..fe95a4c665 100644 --- a/rbutil/rbutilqt/rbutilqt.pro +++ b/rbutil/rbutilqt/rbutilqt.pro @@ -42,8 +42,12 @@ SOURCES += rbutilqt.cpp \ browseof.cpp \ preview.cpp \ encoders.cpp \ - tts.cpp - + tts.cpp \ + ../../tools/wavtrim.c \ + ../../tools/voicefont.c \ + voicefile.cpp \ + createvoicewindow.cpp + HEADERS += rbutilqt.h \ install.h \ httpget.h \ @@ -80,10 +84,14 @@ HEADERS += rbutilqt.h \ browseof.h \ preview.h \ encoders.h \ - tts.h + tts.h \ + ../../tools/wavtrim.h \ + ../../tools/voicefont.h \ + voicefile.h \ + createvoicewindow.h # Needed by QT on Win -INCLUDEPATH = . irivertools zip zlib ../ipodpatcher ../sansapatcher ../../tools/rbspeex +INCLUDEPATH = . irivertools zip zlib ../ipodpatcher ../sansapatcher ../../tools/rbspeex ../../tools LIBS += -L../../tools/rbspeex -lrbspeex @@ -115,7 +123,8 @@ FORMS += rbutilqtfrm.ui \ rbspeexcfgfrm.ui \ encexescfgfrm.ui \ ttsexescfgfrm.ui \ - sapicfgfrm.ui + sapicfgfrm.ui \ + createvoicefrm.ui RESOURCES += rbutilqt.qrc win32 { diff --git a/rbutil/rbutilqt/rbutilqt.qrc b/rbutil/rbutilqt/rbutilqt.qrc index 0e571d6585..71e4c93d19 100644 --- a/rbutil/rbutilqt/rbutilqt.qrc +++ b/rbutil/rbutilqt/rbutilqt.qrc @@ -2,6 +2,9 @@ CREDITS gpl-2.0.html + + + ../../tools/VOICE_PAUSE.wav icons/audio-input-microphone.png diff --git a/rbutil/rbutilqt/rbutilqtfrm.ui b/rbutil/rbutilqt/rbutilqtfrm.ui index fe929db54d..2eec1be54c 100644 --- a/rbutil/rbutilqt/rbutilqtfrm.ui +++ b/rbutil/rbutilqt/rbutilqtfrm.ui @@ -490,16 +490,16 @@ p, li { white-space: pre-wrap; } <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Install Voice file</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Voice files are needed to make Rockbox speak the user interface. Speaking is enabled by default, so if you installed the voice file Rockbox will speak.</p></body></html> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><span style=" font-weight:600;">Install Voice file</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;">Voice files are needed to make Rockbox speak the user interface. Speaking is enabled by default, so if you installed the voice file Rockbox will speak.</p></body></html> true - + Install Talk files @@ -515,7 +515,7 @@ p, li { white-space: pre-wrap; } - + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> @@ -526,7 +526,7 @@ p, li { white-space: pre-wrap; } - + Qt::Vertical @@ -539,7 +539,7 @@ p, li { white-space: pre-wrap; } - + Qt::Vertical @@ -552,6 +552,34 @@ p, li { white-space: pre-wrap; } + + + + Install Voice files + + + :/icons/icons/talkfile_btn.png + + + + 56 + 46 + + + + + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><span style=" font-size:9pt; font-weight:600;">Create Voice file</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;">Voice files are needed to make Rockbox speak the user interface. Speaking is enabled by default, so</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"> if you installed the voice file Rockbox will speak.</p></body></html> + + + @@ -801,7 +829,7 @@ p, li { white-space: pre-wrap; } 0 0 662 - 29 + 21 @@ -853,6 +881,7 @@ p, li { white-space: pre-wrap; } Accessibility + @@ -1024,6 +1053,18 @@ p, li { white-space: pre-wrap; } Download HTML manual (zip) + + + :/icons/icons/talkfile_btn.png + + + Create Voice File + + + Create Voic<resource type="image" qrc="C:/cygwin/home/Domonoky/rockbox-svn/rockbox-rbspeex/rbutil/rbutilqt/rbutilqt.qrc" file=":/icons/icons/talkfile_btn.png" /> +e File + + tabWidget diff --git a/rbutil/rbutilqt/tts.cpp b/rbutil/rbutilqt/tts.cpp index aa5f661fcb..b7c89ecbe9 100644 --- a/rbutil/rbutilqt/tts.cpp +++ b/rbutil/rbutilqt/tts.cpp @@ -284,7 +284,7 @@ bool TTSSapi::voice(QString text,QString wavfile) { QString query = "SPEAK\t"+wavfile+"\t"+text+"\r\n"; qDebug() << "voicing" << query; - voicescript->write(query.toLocal8Bit()); + voicescript->write(query.toUtf8()); voicescript->write("SYNC\tbla\r\n"); voicescript->waitForReadyRead(); return true; @@ -293,7 +293,7 @@ bool TTSSapi::voice(QString text,QString wavfile) bool TTSSapi::stop() { QString query = "QUIT\r\n"; - voicescript->write(query.toLocal8Bit()); + voicescript->write(query.toUtf8()); voicescript->waitForFinished(); delete voicescript; return true; diff --git a/rbutil/rbutilqt/voicefile.cpp b/rbutil/rbutilqt/voicefile.cpp new file mode 100644 index 0000000000..9390fa2fe9 --- /dev/null +++ b/rbutil/rbutilqt/voicefile.cpp @@ -0,0 +1,275 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Wenger + * $Id: voicefile.h 15932 2007-12-15 13:13:57Z domonoky $ + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "voicefile.h" + +#define STATE_INVALID 0 +#define STATE_PHRASE 1 +#define STATE_VOICE 2 + + +VoiceFileCreator::VoiceFileCreator(QObject* parent) :QObject(parent) +{ + +} + +void VoiceFileCreator::abort() +{ + m_abort = true; +} + +bool VoiceFileCreator::createVoiceFile(ProgressloggerInterface* logger) +{ + m_abort = false; + m_logger = logger; + m_logger->addItem("Starting Voicefile generation",LOGINFO); + + // test if tempdir exists + if(!QDir(QDir::tempPath()+"/rbvoice/").exists()) + { + QDir(QDir::tempPath()).mkdir("rbvoice"); + } + + m_path = QDir::tempPath() + "/rbvoice/"; + + // read rockbox-info.txt + QFile info(m_mountpoint+"/.rockbox/rockbox-info.txt"); + if(!info.open(QIODevice::ReadOnly)) + { + m_logger->addItem("failed to open rockbox-info.txt",LOGERROR); + return false; + } + + QString target, features,version; + while (!info.atEnd()) { + QString line = info.readLine(); + + if(line.contains("Target:")) + { + target = line.remove("Target:").trimmed(); + } + else if(line.contains("Features:")) + { + features = line.remove("Features:").trimmed(); + } + else if(line.contains("Version:")) + { + version = line.remove("Version:").trimmed(); + version = version.left(version.indexOf("-")).remove(0,1); + } + } + info.close(); + + //prepare download url + QUrl genlangUrl = deviceSettings->value("genlang_url").toString() +"?lang=" +m_lang+"&t="+target+"&rev="+version+"&f="+features; + + qDebug() << "downloading " << genlangUrl; + + //download the correct genlang output + QTemporaryFile *downloadFile = new QTemporaryFile(this); + downloadFile->open(); + filename = downloadFile->fileName(); + downloadFile->close(); + // get the real file. + getter = new HttpGet(this); + getter->setProxy(m_proxy); + getter->setFile(downloadFile); + getter->getFile(genlangUrl); + + connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); + connect(getter, SIGNAL(downloadDone(int, bool)), this, SLOT(downloadRequestFinished(int, bool))); + connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int))); + connect(m_logger, SIGNAL(aborted()), getter, SLOT(abort())); + return true; + } + + +void VoiceFileCreator::downloadRequestFinished(int id, bool error) +{ + qDebug() << "Install::downloadRequestFinished" << id << error; + qDebug() << "error:" << getter->errorString(); + + downloadDone(error); +} + + +void VoiceFileCreator::downloadDone(bool error) +{ + qDebug() << "Voice creator::downloadDone, error:" << error; + + // update progress bar + int max = m_logger->getProgressMax(); + if(max == 0) { + max = 100; + m_logger->setProgressMax(max); + } + m_logger->setProgressValue(max); + if(getter->httpResponse() != 200 && !getter->isCached()) { + m_logger->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()),LOGERROR); + m_logger->abort(); + return; + } + if(getter->isCached()) m_logger->addItem(tr("Cached file used."), LOGINFO); + if(error) { + m_logger->addItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR); + m_logger->abort(); + return; + } + else m_logger->addItem(tr("Download finished."),LOGOK); + QApplication::processEvents(); + + + m_logger->setProgressMax(0); + //open downloaded file + QFile genlang(filename); + if(!genlang.open(QIODevice::ReadOnly)) + { + m_logger->addItem("failed to open downloaded file",LOGERROR); + m_logger->abort(); + return; + } + + //tts + m_tts = getTTS(userSettings->value("tts").toString()); + m_tts->setUserCfg(userSettings); + + if(!m_tts->start()) + { + m_logger->addItem("Init of TTS engine failed",LOGERROR); + m_logger->abort(); + return; + } + + // Encoder + m_enc = getEncoder(userSettings->value("encoder").toString()); + m_enc->setUserCfg(userSettings); + + if(!m_enc->start()) + { + m_logger->addItem("Init of Encoder engine failed",LOGERROR); + m_tts->stop(); + m_logger->abort(); + return; + } + + QApplication::processEvents(); + + connect(m_logger,SIGNAL(aborted()),this,SLOT(abort())); + QStringList mp3files; + + QTextStream in(&genlang); + in.setCodec("UTF-8"); + + bool emptyfile = true; + while (!in.atEnd()) + { + if(m_abort) + { + m_logger->addItem("aborted.",LOGERROR); + break; + } + + QString comment = in.readLine(); + QString id = in.readLine(); + QString voice = in.readLine(); + + id = id.remove("id:").remove('"').trimmed(); + voice = voice.remove("voice:").remove('"').trimmed(); + + QString wavname = m_path + "/" + id + ".wav"; + QString toSpeak = voice; + QString encodedname = m_path + "/" + id +".mp3"; + + // todo PAUSE + if(id == "VOICE_PAUSE") + { + QFile::copy(":/builtin/builtin/VOICE_PAUSE.wav",m_path + "/VOICE_PAUSE.wav"); + + } + else + { + if(voice == "") continue; + + m_logger->addItem(tr("creating ")+toSpeak,LOGINFO); + QApplication::processEvents(); + m_tts->voice(toSpeak,wavname); // generate wav + } + + // todo strip + char buffer[255]; + + wavtrim((char*)qPrintable(wavname),500,buffer,255); + + // encode wav + m_enc->encode(wavname,encodedname); + // remove the wav file + QFile::remove(wavname); + // remember the mp3 file for later removing + mp3files << encodedname; + // remember that we have done something + emptyfile = false; + + } + genlang.close(); + + if(emptyfile) + { + m_logger->addItem(tr("The downloaded file was empty!"),LOGERROR); + m_logger->abort(); + return; + } + + //make voicefile + FILE* ids2 = fopen(filename.toUtf8(), "r"); + if (ids2 == NULL) + { + m_logger->addItem("Error opening downloaded file",LOGERROR); + m_logger->abort(); + return; + } + + FILE* output = fopen(QString(m_mountpoint + "/.rockbox/langs/" + m_lang + ".voice").toUtf8(), "wb"); + if (output == NULL) + { + m_logger->addItem("Error opening output file",LOGERROR); + return; + } + + voicefont(ids2,m_targetid,(char*)(const char*)m_path.toUtf8(), output); + + //remove .mp3 files + for(int i=0;i< mp3files.size(); i++) + { + QFile::remove(mp3files.at(i)); + } + + m_logger->setProgressMax(100); + m_logger->setProgressValue(100); + m_logger->addItem("successfully created.",LOGOK); + m_logger->abort(); +} + +void VoiceFileCreator::updateDataReadProgress(int read, int total) +{ + m_logger->setProgressMax(total); + m_logger->setProgressValue(read); + //qDebug() << "progress:" << read << "/" << total; + +} + diff --git a/rbutil/rbutilqt/voicefile.h b/rbutil/rbutilqt/voicefile.h new file mode 100644 index 0000000000..b82f0373c7 --- /dev/null +++ b/rbutil/rbutilqt/voicefile.h @@ -0,0 +1,84 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Wenger + * $Id: voicefile.h 15932 2007-12-15 13:13:57Z domonoky $ + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + + +#ifndef VOICEFILE_H +#define VOICEFILE_H + +#include +#include "progressloggerinterface.h" + +#include "encoders.h" +#include "tts.h" +#include "httpget.h" + +extern "C" +{ + #include "wavtrim.h" + #include "voicefont.h" +} + +class VoiceFileCreator :public QObject +{ + Q_OBJECT +public: + VoiceFileCreator(QObject* parent=0); + + //start creation + bool createVoiceFile(ProgressloggerInterface* logger); + + // set infos + void setUserSettings(QSettings* setting) { userSettings = setting;} + void setDeviceSettings(QSettings* setting) { deviceSettings = setting;} + + void setMountPoint(QString mountpoint) {m_mountpoint =mountpoint; } + void setTargetId(int id){m_targetid = id;} + void setLang(QString name){m_lang =name;} + void setProxy(QUrl proxy){m_proxy = proxy;} + +private slots: + void abort(); + void downloadRequestFinished(int id, bool error); + void downloadDone(bool error); + void updateDataReadProgress(int read, int total); + +private: + + // ptr to encoder, tts and settings + TTSBase* m_tts; + EncBase* m_enc; + QSettings *userSettings; + QSettings *deviceSettings; + + HttpGet *getter; + + QUrl m_proxy; //proxy + QString filename; //the temporary file + + QString m_mountpoint; //mountpoint of the device + QString m_path; //path where the wav and mp3 files are stored to + int m_targetid; //the target id + QString m_lang; // the language which will be spoken + + ProgressloggerInterface* m_logger; + + bool m_abort; +}; + +#endif -- cgit