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.")); } }