diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2013-11-03 11:08:18 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2013-11-04 23:32:52 +0100 |
commit | 4d2ce949b3b41f8bf0af446fa20205ddd229e579 (patch) | |
tree | 01fa19471d9831b296bea5d7049f765e38b30bbb /rbutil/rbutilqt/base/ttsfestival.cpp | |
parent | 335ec75d60bba82f23fc47b20f9390e0cba9c9c5 (diff) | |
download | rockbox-4d2ce949b3b41f8bf0af446fa20205ddd229e579.tar.gz rockbox-4d2ce949b3b41f8bf0af446fa20205ddd229e579.zip |
Use cutelogger for Rockbox Utility internal trace.
Change tracing from qDebug() to use cutelogger, which is available under the
LGPL2.1. This allows to automatically add filename and line number to the log,
and also provides multiple log levels.
Change-Id: I5dbdaf902ba54ea99f07ae10a07467c52fdac910
Diffstat (limited to 'rbutil/rbutilqt/base/ttsfestival.cpp')
-rw-r--r-- | rbutil/rbutilqt/base/ttsfestival.cpp | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/rbutil/rbutilqt/base/ttsfestival.cpp b/rbutil/rbutilqt/base/ttsfestival.cpp index cbf24a3f03..41358ba488 100644 --- a/rbutil/rbutilqt/base/ttsfestival.cpp +++ b/rbutil/rbutilqt/base/ttsfestival.cpp | |||
@@ -22,10 +22,11 @@ | |||
22 | #include "ttsfestival.h" | 22 | #include "ttsfestival.h" |
23 | #include "utils.h" | 23 | #include "utils.h" |
24 | #include "rbsettings.h" | 24 | #include "rbsettings.h" |
25 | #include "Logger.h" | ||
25 | 26 | ||
26 | TTSFestival::~TTSFestival() | 27 | TTSFestival::~TTSFestival() |
27 | { | 28 | { |
28 | qDebug() << "[Festival] Destroying instance"; | 29 | LOG_INFO() << "Destroying instance"; |
29 | stop(); | 30 | stop(); |
30 | } | 31 | } |
31 | 32 | ||
@@ -87,7 +88,7 @@ void TTSFestival::updateVoiceDescription() | |||
87 | currentPath = getSetting(eSERVERPATH)->current().toString(); | 88 | currentPath = getSetting(eSERVERPATH)->current().toString(); |
88 | QString info = getVoiceInfo(getSetting(eVOICE)->current().toString()); | 89 | QString info = getVoiceInfo(getSetting(eVOICE)->current().toString()); |
89 | currentPath = ""; | 90 | currentPath = ""; |
90 | 91 | ||
91 | getSetting(eVOICEDESC)->setCurrent(info); | 92 | getSetting(eVOICEDESC)->setCurrent(info); |
92 | } | 93 | } |
93 | 94 | ||
@@ -101,7 +102,7 @@ void TTSFestival::updateVoiceList() | |||
101 | currentPath = getSetting(eSERVERPATH)->current().toString(); | 102 | currentPath = getSetting(eSERVERPATH)->current().toString(); |
102 | QStringList voiceList = getVoiceList(); | 103 | QStringList voiceList = getVoiceList(); |
103 | currentPath = ""; | 104 | currentPath = ""; |
104 | 105 | ||
105 | getSetting(eVOICE)->setList(voiceList); | 106 | getSetting(eVOICE)->setList(voiceList); |
106 | if(voiceList.size() > 0) getSetting(eVOICE)->setCurrent(voiceList.at(0)); | 107 | if(voiceList.size() > 0) getSetting(eVOICE)->setCurrent(voiceList.at(0)); |
107 | else getSetting(eVOICE)->setCurrent(""); | 108 | else getSetting(eVOICE)->setCurrent(""); |
@@ -130,9 +131,10 @@ void TTSFestival::startServer() | |||
130 | QCoreApplication::processEvents(QEventLoop::AllEvents, 50); | 131 | QCoreApplication::processEvents(QEventLoop::AllEvents, 50); |
131 | 132 | ||
132 | if(serverProcess.state() == QProcess::Running) | 133 | if(serverProcess.state() == QProcess::Running) |
133 | qDebug() << "[Festival] Server is up and running"; | 134 | LOG_INFO() << "Server is up and running"; |
134 | else | 135 | else |
135 | qDebug() << "[Festival] Server failed to start, state: " << serverProcess.state(); | 136 | LOG_ERROR() << "Server failed to start, state:" |
137 | << serverProcess.state(); | ||
136 | } | 138 | } |
137 | } | 139 | } |
138 | 140 | ||
@@ -147,8 +149,9 @@ bool TTSFestival::ensureServerRunning() | |||
147 | 149 | ||
148 | bool TTSFestival::start(QString* errStr) | 150 | bool TTSFestival::start(QString* errStr) |
149 | { | 151 | { |
150 | qDebug() << "[Festival] Starting server with voice " << RbSettings::subValue("festival", RbSettings::TtsVoice).toString(); | 152 | LOG_INFO() << "Starting server with voice" |
151 | 153 | << RbSettings::subValue("festival", RbSettings::TtsVoice).toString(); | |
154 | |||
152 | bool running = ensureServerRunning(); | 155 | bool running = ensureServerRunning(); |
153 | if (!RbSettings::subValue("festival",RbSettings::TtsVoice).toString().isEmpty()) | 156 | if (!RbSettings::subValue("festival",RbSettings::TtsVoice).toString().isEmpty()) |
154 | { | 157 | { |
@@ -156,17 +159,17 @@ bool TTSFestival::start(QString* errStr) | |||
156 | QString voiceSelect = QString("(voice.select '%1)\n") | 159 | QString voiceSelect = QString("(voice.select '%1)\n") |
157 | .arg(RbSettings::subValue("festival", RbSettings::TtsVoice).toString()); | 160 | .arg(RbSettings::subValue("festival", RbSettings::TtsVoice).toString()); |
158 | queryServer(voiceSelect, 3000); | 161 | queryServer(voiceSelect, 3000); |
159 | 162 | ||
160 | if(prologFile.open()) | 163 | if(prologFile.open()) |
161 | { | 164 | { |
162 | prologFile.write(voiceSelect.toLatin1()); | 165 | prologFile.write(voiceSelect.toLatin1()); |
163 | prologFile.close(); | 166 | prologFile.close(); |
164 | prologPath = QFileInfo(prologFile).absoluteFilePath(); | 167 | prologPath = QFileInfo(prologFile).absoluteFilePath(); |
165 | qDebug() << "[Festival] Prolog created at " << prologPath; | 168 | LOG_INFO() << "Prolog created at" << prologPath; |
166 | } | 169 | } |
167 | 170 | ||
168 | } | 171 | } |
169 | 172 | ||
170 | if (!running) | 173 | if (!running) |
171 | (*errStr) = "Festival could not be started"; | 174 | (*errStr) = "Festival could not be started"; |
172 | return running; | 175 | return running; |
@@ -182,13 +185,13 @@ bool TTSFestival::stop() | |||
182 | 185 | ||
183 | TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr) | 186 | TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr) |
184 | { | 187 | { |
185 | qDebug() << "[Festival] Voicing " << text << "->" << wavfile; | 188 | LOG_INFO() << "Voicing" << text << "->" << wavfile; |
186 | 189 | ||
187 | QString path = RbSettings::subValue("festival-client", | 190 | QString path = RbSettings::subValue("festival-client", |
188 | RbSettings::TtsPath).toString(); | 191 | RbSettings::TtsPath).toString(); |
189 | QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp" | 192 | QString cmd = QString("%1 --server localhost --otype riff --ttw --withlisp" |
190 | " --output \"%2\" --prolog \"%3\" - ").arg(path).arg(wavfile).arg(prologPath); | 193 | " --output \"%2\" --prolog \"%3\" - ").arg(path).arg(wavfile).arg(prologPath); |
191 | qDebug() << "[Festival] Client cmd: " << cmd; | 194 | LOG_INFO() << "Client cmd:" << cmd; |
192 | 195 | ||
193 | QProcess clientProcess; | 196 | QProcess clientProcess; |
194 | clientProcess.start(cmd); | 197 | clientProcess.start(cmd); |
@@ -200,7 +203,7 @@ TTSStatus TTSFestival::voice(QString text, QString wavfile, QString* errStr) | |||
200 | response = response.trimmed(); | 203 | response = response.trimmed(); |
201 | if(!response.contains("Utterance")) | 204 | if(!response.contains("Utterance")) |
202 | { | 205 | { |
203 | qDebug() << "[Festival] Could not voice string: " << response; | 206 | LOG_WARNING() << "Could not voice string: " << response; |
204 | *errStr = tr("engine could not voice string"); | 207 | *errStr = tr("engine could not voice string"); |
205 | return Warning; | 208 | return Warning; |
206 | /* do not stop the voicing process because of a single string | 209 | /* do not stop the voicing process because of a single string |
@@ -231,10 +234,10 @@ bool TTSFestival::configOk() | |||
231 | ret = ret && (voices.indexOf(RbSettings::subValue("festival", | 234 | ret = ret && (voices.indexOf(RbSettings::subValue("festival", |
232 | RbSettings::TtsVoice).toString()) != -1); | 235 | RbSettings::TtsVoice).toString()) != -1); |
233 | } | 236 | } |
234 | else /* If we're currently configuring the server, we need to know that | 237 | else /* If we're currently configuring the server, we need to know that |
235 | the entered path is valid */ | 238 | the entered path is valid */ |
236 | ret = QFileInfo(currentPath).isExecutable(); | 239 | ret = QFileInfo(currentPath).isExecutable(); |
237 | 240 | ||
238 | return ret; | 241 | return ret; |
239 | } | 242 | } |
240 | 243 | ||
@@ -245,7 +248,7 @@ QStringList TTSFestival::getVoiceList() | |||
245 | 248 | ||
246 | if(voices.size() > 0) | 249 | if(voices.size() > 0) |
247 | { | 250 | { |
248 | qDebug() << "[Festival] Using voice cache"; | 251 | LOG_INFO() << "Using voice cache"; |
249 | return voices; | 252 | return voices; |
250 | } | 253 | } |
251 | 254 | ||
@@ -261,9 +264,9 @@ QStringList TTSFestival::getVoiceList() | |||
261 | if (voices.size() == 1 && voices[0].size() == 0) | 264 | if (voices.size() == 1 && voices[0].size() == 0) |
262 | voices.removeAt(0); | 265 | voices.removeAt(0); |
263 | if (voices.size() > 0) | 266 | if (voices.size() > 0) |
264 | qDebug() << "[Festival] Voices: " << voices; | 267 | LOG_INFO() << "Voices:" << voices; |
265 | else | 268 | else |
266 | qDebug() << "[Festival] No voices. Response was: " << response; | 269 | LOG_WARNING() << "No voices. Response was:" << response; |
267 | 270 | ||
268 | return voices; | 271 | return voices; |
269 | } | 272 | } |
@@ -290,7 +293,7 @@ QString TTSFestival::getVoiceInfo(QString voice) | |||
290 | { | 293 | { |
291 | response = response.remove(QRegExp("(description \"*\")", | 294 | response = response.remove(QRegExp("(description \"*\")", |
292 | Qt::CaseInsensitive, QRegExp::Wildcard)); | 295 | Qt::CaseInsensitive, QRegExp::Wildcard)); |
293 | qDebug() << "[Festival] voiceInfo w/o descr: " << response; | 296 | LOG_INFO() << "voiceInfo w/o descr:" << response; |
294 | response = response.remove(')'); | 297 | response = response.remove(')'); |
295 | QStringList responseLines = response.split('(', QString::SkipEmptyParts); | 298 | QStringList responseLines = response.split('(', QString::SkipEmptyParts); |
296 | responseLines.removeAt(0); // the voice name itself | 299 | responseLines.removeAt(0); // the voice name itself |
@@ -327,12 +330,12 @@ QString TTSFestival::queryServer(QString query, int timeout) | |||
327 | 330 | ||
328 | // this operation could take some time | 331 | // this operation could take some time |
329 | emit busy(); | 332 | emit busy(); |
330 | 333 | ||
331 | qDebug() << "[Festival] queryServer with " << query; | 334 | LOG_INFO() << "queryServer with" << query; |
332 | 335 | ||
333 | if (!ensureServerRunning()) | 336 | if (!ensureServerRunning()) |
334 | { | 337 | { |
335 | qDebug() << "[Festival] queryServer: ensureServerRunning failed"; | 338 | LOG_ERROR() << "queryServer: ensureServerRunning failed"; |
336 | emit busyEnd(); | 339 | emit busyEnd(); |
337 | return ""; | 340 | return ""; |
338 | } | 341 | } |
@@ -393,7 +396,7 @@ QString TTSFestival::queryServer(QString query, int timeout) | |||
393 | lines.removeLast(); /* should be ft_StUfF_keyOK */ | 396 | lines.removeLast(); /* should be ft_StUfF_keyOK */ |
394 | } | 397 | } |
395 | else | 398 | else |
396 | qDebug() << "[Festival] Response too short: " << response; | 399 | LOG_ERROR() << "Response too short:" << response; |
397 | 400 | ||
398 | emit busyEnd(); | 401 | emit busyEnd(); |
399 | return lines.join("\n"); | 402 | return lines.join("\n"); |