Skip to content

Commit

Permalink
speechAnalyzer:3.5.1 - Allows for full disabling of Opensmile compone…
Browse files Browse the repository at this point in the history
…nts using --disable_opensmile (#25)

* Fixed bug when calling Mosquitto::max_seconds_without_messages with max long value, and refactored initialization of JsonBuilder

* Refactored Initialization/Shutdown pipeline to resolve edge cases

* Resolved bug when using non-thread-safe std::cout

* Updated a few static value to fix edge cases

* Implementing updated speech model and adaption words

* Testing both versions of Google speech api

* Updated googleapis version to support adaption boost in api v1

* Implemented ipmroved 'video' model and speech adaption for domain words and phrases

* Switching imports back to v1 from v1p1beta1

* Updated error handling to catch Google Speech video model

* Removed two src files commited by accident

* Updated version number

* Improved info message for failing to connect to Mosquitto broker

* More detailed error messages when exceeding Google Cloud Speech limits

* Replacing some couts+endls with BOOST_LOG_TRIVIAL in OpensmileSession.cpp

* Switching some couts in speechAnalyzer.cpp to BOOST_LOG_TRIVIAL

* Switching to BOOST_LOG_TRIVIAL in DBWrapper.cpp

* Replacing remaining cout/cerr << .. << endl calls with BOOST_LOG_TRIVIAL

* Formatting changes to SpeechWrapper.cpp

* Updated error handling logic for parsing Google repeated fields

* Formatting changes

* Updating Dockerfile and tools/install_opensmile_from_source script so that the number of parallel make jobs is limited to the number of cores available to Docker (nproc)

* Fully implemented the disabling of Opensmile components using --disable_opensmile command line options

Co-authored-by: Vincent Raymond <[email protected]>
Co-authored-by: Adarsh Pyarelal <[email protected]>
  • Loading branch information
3 people authored Mar 17, 2022
1 parent 1ff4808 commit 69df9f5
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions src/JsonBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ void JsonBuilder::Initialize() {
boost::posix_time::microsec_clock::universal_time();

// Initialize postgres connection
this->postgres.initialize();
this->postgres.trial_id = GLOBAL_LISTENER.trial_id;
this->postgres.participant_id = this->participant_id;
if(!args.disable_opensmile){
this->postgres.initialize();
this->postgres.trial_id = GLOBAL_LISTENER.trial_id;
this->postgres.participant_id = this->participant_id;
}
}

void JsonBuilder::Shutdown() {
Expand All @@ -72,7 +74,9 @@ void JsonBuilder::Shutdown() {
this->listener_client_thread.join();

// Close postgres connection
this->postgres.shutdown();
if(!args.disable_opensmile){
this->postgres.shutdown();
}
}

void JsonBuilder::process_message(string message) {
Expand Down Expand Up @@ -205,13 +209,19 @@ void JsonBuilder::process_asr_message(StreamingRecognizeResponse response,
boost::posix_time::to_iso_extended_string(end_timestamp) + "Z";

// Add sentiment data
string features = this->process_alignment_message(response, id);
string mmc = this->process_mmc_message(features);
message["data"]["sentiment"] = nlohmann::json::parse(mmc);
this->strip_mmc_message(message);
message["data"]["features"] = nlohmann::json::parse(features)["data"];
this->strip_features_message(message);

if(!args.disable_opensmile){
try{
string features = this->process_alignment_message(response, id);
string mmc = this->process_mmc_message(features);
message["data"]["sentiment"] = nlohmann::json::parse(mmc);
this->strip_mmc_message(message);
message["data"]["features"] = nlohmann::json::parse(features)["data"];
this->strip_features_message(message);
}
catch(std::exception e){
BOOST_LOG_TRIVIAL(info) << "Failure processing sentiment analysis";
}
}
// Publish message
this->mosquitto_client.publish("agent/asr/final", message.dump());

Expand Down Expand Up @@ -295,15 +305,16 @@ void JsonBuilder::process_asr_message_vosk(std::string response) {
message["data"]["alternatives"] = alternatives;

// Add vocalic features and sentiment
string features = this->process_alignment_message_vosk(
response_message, message["data"]["id"]);
string mmc = this->process_mmc_message(features);
message["data"]["sentiment"] = nlohmann::json::parse(mmc);
this->strip_mmc_message(message);
message["data"]["features"] =
nlohmann::json::parse(features)["data"];
this->strip_features_message(message);

if(!args.disable_opensmile){
string features = this->process_alignment_message_vosk(
response_message, message["data"]["id"]);
string mmc = this->process_mmc_message(features);
message["data"]["sentiment"] = nlohmann::json::parse(mmc);
this->strip_mmc_message(message);
message["data"]["features"] =
nlohmann::json::parse(features)["data"];
this->strip_features_message(message);
}
// Publish message
this->mosquitto_client.publish("agent/asr/final", message.dump());
// Set is_initial to true
Expand Down Expand Up @@ -573,7 +584,7 @@ nlohmann::json JsonBuilder::create_common_msg(std::string sub_type) {
message["timestamp"] = timestamp;
message["experiment_id"] = GLOBAL_LISTENER.experiment_id;
message["trial_id"] = GLOBAL_LISTENER.trial_id;
message["version"] = "3.5.0";
message["version"] = "3.5.1";
message["source"] = "tomcat_speech_analyzer";
message["sub_type"] = sub_type;

Expand Down

0 comments on commit 69df9f5

Please sign in to comment.