From cdffb56613a2b83b92bcb93bdfe8483a53192953 Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Mon, 29 Feb 2016 21:47:36 +0100 Subject: [PATCH] Redirecting pocketsphinx log to main log --- src/phoneExtraction.cpp | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/phoneExtraction.cpp b/src/phoneExtraction.cpp index 278f68b..425472b 100644 --- a/src/phoneExtraction.cpp +++ b/src/phoneExtraction.cpp @@ -10,6 +10,7 @@ #include #include #include +#include extern "C" { #include @@ -111,8 +112,25 @@ void processAudioStream(AudioStream& audioStream16kHzMono, function(user_data); - if (errorString->size() > 0) *errorString += "\n"; - *errorString += message; + LogLevel logLevel = ConvertSphinxErrorLevel(errorLevel); + LOG(logLevel) << message; } vector recognizeWords(unique_ptr audioStream, ps_decoder_t& recognizer, ProgressSink& progressSink) { @@ -286,9 +302,8 @@ map detectPhones( // Discard Pocketsphinx output err_set_logfp(nullptr); - // Collect all Pocketsphinx error messages in a string - string errorMessage; - err_set_callback(sphinxErrorCallback, &errorMessage); + // Redirect Pocketsphinx output to log + err_set_callback(sphinxLogCallback, nullptr); try { // Create PocketSphinx configuration @@ -315,6 +330,6 @@ map detectPhones( return result; } catch (...) { - std::throw_with_nested(runtime_error("Error performing speech recognition via Pocketsphinx. " + errorMessage)); + std::throw_with_nested(runtime_error("Error performing speech recognition via Pocketsphinx.")); } }