mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 05:05:20 -05:00
rbutil: improve voice creation: better parser for genlang output. Make progressbar working while voicegeneration. Sort the voice language list. Make the rbutil Translations built in. (run lrelease before make)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16075 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bf6d5cce68
commit
62f7f9e550
4 changed files with 74 additions and 39 deletions
|
|
@ -82,6 +82,7 @@ void CreateVoiceWindow::setDeviceSettings(QSettings *dev)
|
||||||
}
|
}
|
||||||
devices->endGroup();
|
devices->endGroup();
|
||||||
|
|
||||||
|
languages.sort();
|
||||||
ui.comboLanguage->addItems(languages);
|
ui.comboLanguage->addItems(languages);
|
||||||
// set saved lang
|
// set saved lang
|
||||||
ui.comboLanguage->setCurrentIndex(ui.comboLanguage->findText(userSettings->value("voicelanguage").toString()));
|
ui.comboLanguage->setCurrentIndex(ui.comboLanguage->findText(userSettings->value("voicelanguage").toString()));
|
||||||
|
|
|
||||||
|
|
@ -434,9 +434,12 @@ bootloadername=firmware.mi4
|
||||||
resolution=132x80x16
|
resolution=132x80x16
|
||||||
manualname=
|
manualname=
|
||||||
brand=Sandisk
|
brand=Sandisk
|
||||||
|
usbid=0x07817450
|
||||||
|
usbid=0x07817451
|
||||||
voicename=sansac200
|
voicename=sansac200
|
||||||
targetid=30
|
targetid=30
|
||||||
|
|
||||||
|
|
||||||
[languages]
|
[languages]
|
||||||
lang1=africaans
|
lang1=africaans
|
||||||
lang2=bulgarian
|
lang2=bulgarian
|
||||||
|
|
|
||||||
|
|
@ -36,4 +36,11 @@
|
||||||
<qresource prefix="/ini" >
|
<qresource prefix="/ini" >
|
||||||
<file>rbutil.ini</file>
|
<file>rbutil.ini</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
|
<qresource prefix="/lang" >
|
||||||
|
<file>rbutil_de.qm</file>
|
||||||
|
<file>rbutil_tr.qm</file>
|
||||||
|
<file>rbutil_fr.qm</file>
|
||||||
|
<file>rbutil_zh_CN.qm</file>
|
||||||
|
<file>rbutil_zh_TW.qm</file>
|
||||||
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ bool VoiceFileCreator::createVoiceFile(ProgressloggerInterface* logger)
|
||||||
{
|
{
|
||||||
m_abort = false;
|
m_abort = false;
|
||||||
m_logger = logger;
|
m_logger = logger;
|
||||||
m_logger->addItem("Starting Voicefile generation",LOGINFO);
|
m_logger->addItem(tr("Starting Voicefile generation"),LOGINFO);
|
||||||
|
|
||||||
// test if tempdir exists
|
// test if tempdir exists
|
||||||
if(!QDir(QDir::tempPath()+"/rbvoice/").exists())
|
if(!QDir(QDir::tempPath()+"/rbvoice/").exists())
|
||||||
|
|
@ -52,8 +52,7 @@ bool VoiceFileCreator::createVoiceFile(ProgressloggerInterface* logger)
|
||||||
QFile info(m_mountpoint+"/.rockbox/rockbox-info.txt");
|
QFile info(m_mountpoint+"/.rockbox/rockbox-info.txt");
|
||||||
if(!info.open(QIODevice::ReadOnly))
|
if(!info.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
m_logger->addItem("failed to open rockbox-info.txt",LOGERROR);
|
m_logger->addItem(tr("failed to open rockbox-info.txt"),LOGERROR);
|
||||||
m_logger->abort();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,7 +140,7 @@ void VoiceFileCreator::downloadDone(bool error)
|
||||||
QFile genlang(filename);
|
QFile genlang(filename);
|
||||||
if(!genlang.open(QIODevice::ReadOnly))
|
if(!genlang.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
m_logger->addItem("failed to open downloaded file",LOGERROR);
|
m_logger->addItem(tr("failed to open downloaded file"),LOGERROR);
|
||||||
m_logger->abort();
|
m_logger->abort();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -152,7 +151,7 @@ void VoiceFileCreator::downloadDone(bool error)
|
||||||
|
|
||||||
if(!m_tts->start())
|
if(!m_tts->start())
|
||||||
{
|
{
|
||||||
m_logger->addItem("Init of TTS engine failed",LOGERROR);
|
m_logger->addItem(tr("Init of TTS engine failed"),LOGERROR);
|
||||||
m_logger->abort();
|
m_logger->abort();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -163,49 +162,84 @@ void VoiceFileCreator::downloadDone(bool error)
|
||||||
|
|
||||||
if(!m_enc->start())
|
if(!m_enc->start())
|
||||||
{
|
{
|
||||||
m_logger->addItem("Init of Encoder engine failed",LOGERROR);
|
m_logger->addItem(tr("Init of Encoder engine failed"),LOGERROR);
|
||||||
m_tts->stop();
|
m_tts->stop();
|
||||||
m_logger->abort();
|
m_logger->abort();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
|
|
||||||
connect(m_logger,SIGNAL(aborted()),this,SLOT(abort()));
|
connect(m_logger,SIGNAL(aborted()),this,SLOT(abort()));
|
||||||
QStringList mp3files;
|
|
||||||
|
|
||||||
|
//read in downloaded file
|
||||||
|
QList<QPair<QString,QString> > voicepairs;
|
||||||
QTextStream in(&genlang);
|
QTextStream in(&genlang);
|
||||||
in.setCodec("UTF-8");
|
in.setCodec("UTF-8");
|
||||||
|
QString id, voice;
|
||||||
bool emptyfile = true;
|
bool idfound = false;
|
||||||
|
bool voicefound=false;
|
||||||
while (!in.atEnd())
|
while (!in.atEnd())
|
||||||
|
{
|
||||||
|
QString line = in.readLine();
|
||||||
|
if(line.contains("id:")) //ID found
|
||||||
|
{
|
||||||
|
id = line.remove("id:").remove('"').trimmed();
|
||||||
|
idfound = true;
|
||||||
|
}
|
||||||
|
else if(line.contains("voice:")) // voice found
|
||||||
|
{
|
||||||
|
voice = line.remove("voice:").remove('"').trimmed();
|
||||||
|
voicefound=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(idfound && voicefound)
|
||||||
|
{
|
||||||
|
voicepairs.append(QPair<QString,QString>(id,voice));
|
||||||
|
idfound=false;
|
||||||
|
voicefound=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
genlang.close();
|
||||||
|
|
||||||
|
// check for empty list
|
||||||
|
if(voicepairs.size() == 0)
|
||||||
|
{
|
||||||
|
m_logger->addItem(tr("The downloaded file was empty!"),LOGERROR);
|
||||||
|
m_logger->abort();
|
||||||
|
m_tts->stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_logger->setProgressMax(voicepairs.size());
|
||||||
|
m_logger->setProgressValue(0);
|
||||||
|
|
||||||
|
// create voice clips
|
||||||
|
QStringList mp3files;
|
||||||
|
for(int i=0; i< voicepairs.size(); i++)
|
||||||
{
|
{
|
||||||
if(m_abort)
|
if(m_abort)
|
||||||
{
|
{
|
||||||
m_logger->addItem("aborted.",LOGERROR);
|
m_logger->addItem("aborted.",LOGERROR);
|
||||||
break;
|
m_logger->abort();
|
||||||
|
m_tts->stop();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString comment = in.readLine();
|
m_logger->setProgressValue(i);
|
||||||
QString id = in.readLine();
|
|
||||||
QString voice = in.readLine();
|
|
||||||
|
|
||||||
id = id.remove("id:").remove('"').trimmed();
|
QString wavname = m_path + "/" + voicepairs.at(i).first + ".wav";
|
||||||
voice = voice.remove("voice:").remove('"').trimmed();
|
QString toSpeak = voicepairs.at(i).second;
|
||||||
|
QString encodedname = m_path + "/" + voicepairs.at(i).first +".mp3";
|
||||||
QString wavname = m_path + "/" + id + ".wav";
|
|
||||||
QString toSpeak = voice;
|
|
||||||
QString encodedname = m_path + "/" + id +".mp3";
|
|
||||||
|
|
||||||
// todo PAUSE
|
// todo PAUSE
|
||||||
if(id == "VOICE_PAUSE")
|
if(voicepairs.at(i).first == "VOICE_PAUSE")
|
||||||
{
|
{
|
||||||
QFile::copy(":/builtin/builtin/VOICE_PAUSE.wav",m_path + "/VOICE_PAUSE.wav");
|
QFile::copy(":/builtin/builtin/VOICE_PAUSE.wav",m_path + "/VOICE_PAUSE.wav");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(voice == "") continue;
|
if(toSpeak == "") continue;
|
||||||
|
|
||||||
m_logger->addItem(tr("creating ")+toSpeak,LOGINFO);
|
m_logger->addItem(tr("creating ")+toSpeak,LOGINFO);
|
||||||
QApplication::processEvents();
|
QApplication::processEvents();
|
||||||
|
|
@ -223,24 +257,14 @@ void VoiceFileCreator::downloadDone(bool error)
|
||||||
QFile::remove(wavname);
|
QFile::remove(wavname);
|
||||||
// remember the mp3 file for later removing
|
// remember the mp3 file for later removing
|
||||||
mp3files << encodedname;
|
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
|
//make voicefile
|
||||||
FILE* ids2 = fopen(filename.toUtf8(), "r");
|
FILE* ids2 = fopen(filename.toUtf8(), "r");
|
||||||
if (ids2 == NULL)
|
if (ids2 == NULL)
|
||||||
{
|
{
|
||||||
m_logger->addItem("Error opening downloaded file",LOGERROR);
|
m_logger->addItem(tr("Error opening downloaded file"),LOGERROR);
|
||||||
m_logger->abort();
|
m_logger->abort();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -248,7 +272,7 @@ void VoiceFileCreator::downloadDone(bool error)
|
||||||
FILE* output = fopen(QString(m_mountpoint + "/.rockbox/langs/" + m_lang + ".voice").toUtf8(), "wb");
|
FILE* output = fopen(QString(m_mountpoint + "/.rockbox/langs/" + m_lang + ".voice").toUtf8(), "wb");
|
||||||
if (output == NULL)
|
if (output == NULL)
|
||||||
{
|
{
|
||||||
m_logger->addItem("Error opening output file",LOGERROR);
|
m_logger->addItem(tr("Error opening output file"),LOGERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -262,7 +286,7 @@ void VoiceFileCreator::downloadDone(bool error)
|
||||||
|
|
||||||
m_logger->setProgressMax(100);
|
m_logger->setProgressMax(100);
|
||||||
m_logger->setProgressValue(100);
|
m_logger->setProgressValue(100);
|
||||||
m_logger->addItem("successfully created.",LOGOK);
|
m_logger->addItem(tr("successfully created."),LOGOK);
|
||||||
m_logger->abort();
|
m_logger->abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue