[RavenclawDev 357] [2027] trunk/Agents/Apollo: Agents replaces Sensors and Effectors
antoine@edam.speech.cs.cmu.edu
antoine at edam.speech.cs.cmu.edu
Mon Sep 10 17:46:29 EDT 2007
An HTML attachment was scrubbed...
URL: http://mailman.srv.cs.cmu.edu/pipermail/ravenclaw-developers/attachments/20070910/b4ca983d/attachment-0001.html
-------------- next part --------------
Added: trunk/Agents/Apollo/Agents/AllAgents.cpp
===================================================================
--- trunk/Agents/Apollo/Agents/AllAgents.cpp (rev 0)
+++ trunk/Agents/Apollo/Agents/AllAgents.cpp 2007-09-10 21:46:27 UTC (rev 2027)
@@ -0,0 +1,64 @@
+//=============================================================================
+//
+// Copyright (c) 2005, Carnegie Mellon University.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in
+// the documentation and/or other materials provided with the
+// distribution.
+//
+// This work was supported in part by funding from the National Science
+// Foundation of the United States of America, and the CMU Sphinx Speech
+// Consortium.
+//
+// THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+// ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
+// NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+//
+// ALLAGENTS.H - Global declaration of all the agents.
+//
+// ----------------------------------------------------------------------------
+//
+// BEFORE MAKING CHANGES TO THIS CODE, please read the appropriate
+// documentation, available in the Documentation folder.
+//
+// ANY SIGNIFICANT CHANGES made should be reflected back in the documentation
+// file(s)
+//
+// ANY CHANGES made (even small bug fixed, should be reflected in the history
+// below, in reverse chronological order
+//
+// HISTORY --------------------------------------------------------------------
+//
+// [2007-01-26] (antoine): started working on this (Agents replace both
+// Sensors and Effectors)
+
+#include "AllAgents.h"
+
+// ListenerAgent: the "ear" of the system, providing an interface to the external
+// vad/asr/nlu components
+CListenerAgent laListenerAgent;
+
+// SpeakerAgent: the "mouth" of the system, providing an interface to the external
+// nlg/tts components
+CSpeakerAgent saSpeakerAgent;
Added: trunk/Agents/Apollo/Agents/AllAgents.h
===================================================================
--- trunk/Agents/Apollo/Agents/AllAgents.h (rev 0)
+++ trunk/Agents/Apollo/Agents/AllAgents.h 2007-09-10 21:46:27 UTC (rev 2027)
@@ -0,0 +1,70 @@
+//=============================================================================
+//
+// Copyright (c) 2005, Carnegie Mellon University.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in
+// the documentation and/or other materials provided with the
+// distribution.
+//
+// This work was supported in part by funding from the National Science
+// Foundation of the United States of America, and the CMU Sphinx Speech
+// Consortium.
+//
+// THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+// ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
+// NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+//
+// ALLAGENTS.H - Global declaration of all the agents.
+//
+// ----------------------------------------------------------------------------
+//
+// BEFORE MAKING CHANGES TO THIS CODE, please read the appropriate
+// documentation, available in the Documentation folder.
+//
+// ANY SIGNIFICANT CHANGES made should be reflected back in the documentation
+// file(s)
+//
+// ANY CHANGES made (even small bug fixed, should be reflected in the history
+// below, in reverse chronological order
+//
+// HISTORY --------------------------------------------------------------------
+//
+// [2007-01-26] (antoine): started working on this (Agents replace both
+// Sensors and Effectors)
+
+#ifndef __ALLAGENTS_H__
+#define __ALLAGENTS_H__
+
+#include "SpeakerAgent.h"
+#include "ListenerAgent.h"
+
+// ListenerAgent: the "ear" of the system, providing an interface to the external
+// vad/asr/nlu components
+extern CListenerAgent laListenerAgent;
+
+// SpeakerAgent: the "mouth" of the system, providing an interface to the external
+// nlg/tts components
+extern CSpeakerAgent saSpeakerAgent;
+
+#endif // __ALLAGENTS_H__
Added: trunk/Agents/Apollo/Agents/InteractionAgent.cpp
===================================================================
--- trunk/Agents/Apollo/Agents/InteractionAgent.cpp (rev 0)
+++ trunk/Agents/Apollo/Agents/InteractionAgent.cpp 2007-09-10 21:46:27 UTC (rev 2027)
@@ -0,0 +1,82 @@
+//=============================================================================
+//
+// Copyright (c) 2005, Carnegie Mellon University.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in
+// the documentation and/or other materials provided with the
+// distribution.
+//
+// This work was supported in part by funding from the National Science
+// Foundation of the United States of America, and the CMU Sphinx Speech
+// Consortium.
+//
+// THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+// ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
+// NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+//
+// INTERACTIONAGENT.CPP - An abstract agent that can handle events and actions.
+//
+// ----------------------------------------------------------------------------
+//
+// BEFORE MAKING CHANGES TO THIS CODE, please read the appropriate
+// documentation, available in the Documentation folder.
+//
+// ANY SIGNIFICANT CHANGES made should be reflected back in the documentation
+// file(s)
+//
+// ANY CHANGES made (even small bug fixed, should be reflected in the history
+// below, in reverse chronological order
+//
+// HISTORY --------------------------------------------------------------------
+//
+// [2007-01-26] (antoine): started working on this
+
+#include "InteractionAgent.h"
+
+
+//---------------------------------------------------------------------
+// Constructors and destructors
+//---------------------------------------------------------------------
+//
+
+CInteractionAgent::CInteractionAgent() {}
+CInteractionAgent::~CInteractionAgent() {}
+
+
+//---------------------------------------------------------------------
+// Methods for accessing private fields
+//---------------------------------------------------------------------
+//
+
+void CInteractionAgent::SetName(string sAName) {sName = sAName;}
+string CInteractionAgent::GetName() {return sName;}
+
+//---------------------------------------------------------------------
+// Methods for manipulating events and actions
+//---------------------------------------------------------------------
+//
+
+void CInteractionAgent::ProcessEvent(CEvent &eEvent) {}
+
+void CInteractionAgent::ProcessAction(CAction &aAction) {}
Added: trunk/Agents/Apollo/Agents/InteractionAgent.h
===================================================================
--- trunk/Agents/Apollo/Agents/InteractionAgent.h (rev 0)
+++ trunk/Agents/Apollo/Agents/InteractionAgent.h 2007-09-10 21:46:27 UTC (rev 2027)
@@ -0,0 +1,102 @@
+//=============================================================================
+//
+// Copyright (c) 2005, Carnegie Mellon University.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in
+// the documentation and/or other materials provided with the
+// distribution.
+//
+// This work was supported in part by funding from the National Science
+// Foundation of the United States of America, and the CMU Sphinx Speech
+// Consortium.
+//
+// THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+// ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
+// NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+//
+// INTERACTIONAGENT.H - An abstract agent that can handle events and actions.
+//
+// ----------------------------------------------------------------------------
+//
+// BEFORE MAKING CHANGES TO THIS CODE, please read the appropriate
+// documentation, available in the Documentation folder.
+//
+// ANY SIGNIFICANT CHANGES made should be reflected back in the documentation
+// file(s)
+//
+// ANY CHANGES made (even small bug fixed, should be reflected in the history
+// below, in reverse chronological order
+//
+// HISTORY --------------------------------------------------------------------
+//
+// [2007-01-26] (antoine): started working on this
+
+#ifndef __INTERACTIONAGENT_H__
+#define __INTERACTIONAGENT_H__
+
+#ifdef GALAXY
+#include "Interfaces/GalaxyInterface.h"
+#endif
+#include "Events/Event.h"
+#include "Actions/Action.h"
+#include "Utils/Utils.h"
+#include "Utils/Log.h"
+
+class CInteractionAgent {
+
+protected:
+ string sName;
+
+public:
+
+ //---------------------------------------------------------------------
+ // Constructors and destructors
+ //---------------------------------------------------------------------
+ //
+
+ CInteractionAgent();
+ virtual ~CInteractionAgent();
+
+
+ //---------------------------------------------------------------------
+ // Methods for accessing private fields
+ //---------------------------------------------------------------------
+ //
+
+ void SetName(string sAName);
+ string GetName();
+
+ //---------------------------------------------------------------------
+ // Methods for manipulating events and actions
+ //---------------------------------------------------------------------
+ //
+
+ virtual void ProcessEvent(CEvent &eEvent);
+
+ virtual void ProcessAction(CAction &aAction);
+
+
+};
+
+#endif // __INTERACTIONAGENT_H__
\ No newline at end of file
Added: trunk/Agents/Apollo/Agents/ListenerAgent.cpp
===================================================================
--- trunk/Agents/Apollo/Agents/ListenerAgent.cpp (rev 0)
+++ trunk/Agents/Apollo/Agents/ListenerAgent.cpp 2007-09-10 21:46:27 UTC (rev 2027)
@@ -0,0 +1,344 @@
+//=============================================================================
+//
+// Copyright (c) 2005, Carnegie Mellon University.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in
+// the documentation and/or other materials provided with the
+// distribution.
+//
+// This work was supported in part by funding from the National Science
+// Foundation of the United States of America, and the CMU Sphinx Speech
+// Consortium.
+//
+// THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+// ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
+// NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+//
+// LISTENERAGENT.CPP - An agent that controls and monitors the speech recognition
+// component of the system.
+//
+// ----------------------------------------------------------------------------
+//
+// BEFORE MAKING CHANGES TO THIS CODE, please read the appropriate
+// documentation, available in the Documentation folder.
+//
+// ANY SIGNIFICANT CHANGES made should be reflected back in the documentation
+// file(s)
+//
+// ANY CHANGES made (even small bug fixed, should be reflected in the history
+// below, in reverse chronological order
+//
+// HISTORY --------------------------------------------------------------------
+//
+// [2007-01-26] (antoine): started working on this
+
+#include "ListenerAgent.h"
+
+#include "Core/IMCore.h"
+
+//---------------------------------------------------------------------
+// Constructors and destructors
+//---------------------------------------------------------------------
+//
+
+CListenerAgent::CListenerAgent(): CInteractionAgent() {
+ iMaxUttDuration = 60000;
+ iUttFinalPauseDurationThreshold = 500;
+}
+
+CListenerAgent::~CListenerAgent() {}
+
+
+//---------------------------------------------------------------------
+// Methods for accessing private fields
+//---------------------------------------------------------------------
+//
+
+void CListenerAgent::SetMaxUttDuration(int iADuration) {
+ iMaxUttDuration = iADuration;
+}
+
+int CListenerAgent::GetMaxUttDuration() {
+ return iMaxUttDuration;
+}
+
+void CListenerAgent::SetUttFinalPauseDurationThreshold(int iAThreshold) {
+ iUttFinalPauseDurationThreshold = iAThreshold;
+}
+
+int CListenerAgent::GetUttFinalPauseDurationThreshold() {
+ return iUttFinalPauseDurationThreshold;
+}
+
+//---------------------------------------------------------------------
+// Methods for manipulating input events
+//---------------------------------------------------------------------
+//
+
+void CListenerAgent::ProcessEvent(CEvent &eEvent) {
+
+ int iTimestamp = eEvent.GetTimestamp();
+
+ if (eEvent.GetType() != "pulse")
+ Log(AGENTS_STREAM, "%s event in ListenerAgent: %d",
+ eEvent.GetType().c_str(), eEvent.GetTimestamp());
+
+ //////////////////////////////////////////////////
+ // Event-dependent processing
+
+ if (eEvent.GetType() == "begin_session") {
+ initialize();
+ } else if (eEvent.GetType() == "vad") {
+
+ // there was a change in acoustic state (e.g. speech->pause)
+ if (eEvent.GetFeatureValue("state") == "pause") {
+
+ Log(AGENTS_STREAM, "User stopped speaking at %d (%d) [User:%s]",
+ eEvent.GetTimestamp(), s2sState["asr.in_utt"] == "true", s2sState["dialog.last_turn_id"].c_str());
+
+ // lock the state before accessing it
+ EnterCriticalSection(&csInteractionState);
+
+ s2sState["user.speaking"] = "false";
+
+ } else {
+
+ bool bUserSpeechAllowed = false;
+ if ((atoi(s2sState["system.non_interruptable_prompts"].c_str()) == 0) &&
+ (s2sState["asr.in_utt"] != "true")) {
+ bUserSpeechAllowed = true;
+ }
+
+ Log(AGENTS_STREAM, "User started speaking at %d (%d) [User:%s]",
+ eEvent.GetTimestamp(), bUserSpeechAllowed, s2sState["dialog.last_turn_id"].c_str());
+
+ // lock the state before accessing it
+ EnterCriticalSection(&csInteractionState);
+
+ s2sState["user.speaking"] = "true";
+
+ // if the vad detected speech and we do not have a non-interruptable
+ // prompt to say, start a new user utterance
+ if (bUserSpeechAllowed) {
+
+ // Start a new user turn
+ int t = atoi(s2sState["dialog.last_turn_id"].c_str());
+ t++;
+ string sId = FormatString("%.3d", t);
+ s2sState["dialog.last_turn_id"] = sId;
+ s2sState["asr.in_utt"] = "true";
+ s2sState["asr.last_utt_start_timestamp"] = FormatString("%d",
+ eEvent.GetTimestamp());
+
+ Log(AGENTS_STREAM, "Starting new user turn at %d [User:%s]",
+ eEvent.GetTimestamp(), s2sState["dialog.last_turn_id"].c_str());
+
+ // Signals the beginning of an utterance to the audio server
+ TGIGalaxyCall gcUserUtt;
+
+ // fill in the Galaxy call properties
+ gcUserUtt.s2sInputs["timestamp"] =
+ FormatString("%d", eEvent.GetTimestamp()-UTTERANCE_INITIAL_PAD);
+ gcUserUtt.s2sInputs["id"] = sId;
+ gcUserUtt.bBlockingCall = false;
+ gcUserUtt.sModuleFunction = "audio_server.start_utt";
+ CallGalaxyModuleFunction(&gcUserUtt);
+
+ // Also tells the hub of the new turn (for logging purposes)
+ NotifyHubOfNewUserTurn();
+
+ }
+ }
+
+ s2sState["user.last_acoustic_state_change_timestamp"] =
+ FormatString( "%d", eEvent.GetTimestamp());
+
+ // unlock the state
+ LeaveCriticalSection(&csInteractionState);
+
+ } else if (eEvent.GetType() == "asr") {
+
+ // if this is a full utterance's recognition result
+ if (eEvent.IsComplete()) {
+
+ Log(AGENTS_STREAM, "Received final recognition hypothesis [User:%s]",
+ eEvent.GetFeatureValue("h4_uttid").c_str());
+
+ if (eEvent.GetFeatureValue("h4_hypothesis") != "") {
+ // Send event to the Dialog Manager
+ eEvent.SetType("user_utterance_end");
+ eEvent.AddFeature("floor_status", "free");
+ SendEventToDM(eEvent);
+
+ // Broadcast a "user takes turn" event to the other agents
+ // NB: WE NEED A BETTER MODEL OF INTERRUPTIONS!!
+ CEvent eTTEvent("turn_taking", iTimestamp);
+ eTTEvent.AddFeature("user_takes_floor", "true");
+ DispatchEvent(eTTEvent);
+
+ // send a request to play a beep through Galaxy
+ TGIGalaxyCall gcBeep;
+ gcBeep.bBlockingCall = false;
+ gcBeep.sModuleFunction = "kalliope.beep";
+ CallGalaxyModuleFunction(&gcBeep);
+
+ }
+
+ // if this is a partial result
+ } else {
+ Log(AGENTS_STREAM, "Received partial recognition hypothesis [User:%s]",
+ eEvent.GetFeatureValue("h4_uttid").c_str());
+ }
+
+ } else if (eEvent.GetType() == "dialog") {
+ // New dialog state, inform the input line (ASR/NLU)
+ if (eEvent.HasFeature("state")) {
+ sendInputLineConfiguration(eEvent.GetTimestamp(), eEvent.GetFeatureValue("state"));
+ }
+ }
+
+ //////////////////////////////////////////////////
+ // Event-independent processing
+
+ // lock the state before accessing it
+ EnterCriticalSection(&csInteractionState);
+
+ // Detect the end of a user utterance
+ if (s2sState["asr.in_utt"] == "true") {
+
+ if (atoi(s2sState["system.non_interruptable_prompts"].c_str()) != 0) {
+
+
+ Log(AGENTS_STREAM, "Starting a non-interruptable prompt, canceling current utt [User:%s]",
+ s2sState["dialog.last_turn_id"].c_str());
+
+ // we started an uninterruptable prompt, cancels the current utterance
+ s2sState["asr.in_utt"] = "false";
+
+ // Signals the end of an utterance to the audio server
+ TGIGalaxyCall gcUserUtt;
+
+ // fill in the Galaxy call properties
+ gcUserUtt.bBlockingCall = false;
+ gcUserUtt.sModuleFunction = "audio_server.cancel_utt";
+
+ CallGalaxyModuleFunction(&gcUserUtt);
+
+ } else {
+
+ Log(AGENTS_STREAM, "DEBUG: %s", s2sState["system.non_interruptable_prompts"].c_str());
+
+ int iInUttSince = atoi(s2sState["asr.last_utt_start_timestamp"].c_str());
+
+ if ((iTimestamp - iInUttSince > iMaxUttDuration) || (s2sState["user.speaking"] != "true")) {
+ int iInPauseSince = atoi(s2sState["user.last_acoustic_state_change_timestamp"].c_str());
+
+ if ((iTimestamp - iInUttSince > iMaxUttDuration) ||
+ ((iInPauseSince > 0) &&
+ (iTimestamp - iInPauseSince > iUttFinalPauseDurationThreshold))) {
+
+ if (iTimestamp - iInUttSince > iMaxUttDuration) {
+ Log(WARNING_STREAM, "User utterance reached maximum duration (%d>%d),"
+ "endpointing here, regardless of VAD.", iTimestamp-iInUttSince,
+ iMaxUttDuration);
+ }
+
+ Log(AGENTS_STREAM, "End of utterance detected at %d [User:%s]",
+ iTimestamp, s2sState["dialog.last_turn_id"].c_str());
+
+ // Been below for more than the threshold, endpoint
+ s2sState["asr.in_utt"] = "false";
+
+ // Signals the end of an utterance to the audio server
+ TGIGalaxyCall gcUserUtt;
+
+ // fill in the Galaxy call properties
+ gcUserUtt.s2sInputs["timestamp"] = FormatString("%d", iInPauseSince);
+ gcUserUtt.bBlockingCall = false;
+ gcUserUtt.sModuleFunction = "audio_server.end_utt";
+
+ CallGalaxyModuleFunction(&gcUserUtt);
+
+ }
+ }
+ }
+ }
+
+ // unlock the state
+ LeaveCriticalSection(&csInteractionState);
+}
+
+
+//---------------------------------------------------------------------
+// Private methods
+//---------------------------------------------------------------------
+//
+
+// A: (re-)initializes the agent at the beginning of a session
+void CListenerAgent::initialize() {
+ s2sState["dialog.last_turn_id"] = "-1";
+}
+
+// A: updates the configuration of the ASR/NLU given a new dialog state
+void CListenerAgent::sendInputLineConfiguration(int iTimestamp, string sState) {
+
+ Log(AGENTS_STREAM, "Updating input line configuration:\n%s", sState.c_str());
+
+ // signal the change in state (LM, DTMF, etc) to AudioServer
+ TGIGalaxyCall gcInputLineConfig;
+
+ // fill in the Galaxy call properties
+ gcInputLineConfig.s2sInputs["timestamp"] = FormatString("%d", iTimestamp);
+
+ // parse the dialog state string
+ TStringVector vsLines = PartitionString(sState, "\n");
+ unsigned int i = 0;
+ while (i < vsLines.size()) {
+ if (vsLines[i] == "input_line_config = {") {
+ i++;
+
+ Log(AGENTS_STREAM, "New config: %s", vsLines[i].c_str());
+
+ // now parse the input configuration string and fill in the
+ // GalaxyCall with the slot/value pairs
+ TStringVector vsConfig = PartitionString(vsLines[i], ",");
+ unsigned int j = 0;
+ while (j < vsConfig.size()) {
+ string sSlot, sValue;
+ if (SplitOnFirst(Trim(vsConfig[j]), "=", sSlot, sValue)) {
+ gcInputLineConfig.s2sInputs[Trim(sSlot)] = Trim(sValue);
+ }
+ j++;
+ }
+ break;
+ }
+ i++;
+ }
+
+ gcInputLineConfig.bBlockingCall = false;
+
+ // send the new configuration info to audio_server
+ gcInputLineConfig.sModuleFunction = "audio_server.set_config";
+ CallGalaxyModuleFunction(&gcInputLineConfig);
+}
Added: trunk/Agents/Apollo/Agents/ListenerAgent.h
===================================================================
--- trunk/Agents/Apollo/Agents/ListenerAgent.h (rev 0)
+++ trunk/Agents/Apollo/Agents/ListenerAgent.h 2007-09-10 21:46:27 UTC (rev 2027)
@@ -0,0 +1,105 @@
+//=============================================================================
+//
+// Copyright (c) 2005, Carnegie Mellon University.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in
+// the documentation and/or other materials provided with the
+// distribution.
+//
+// This work was supported in part by funding from the National Science
+// Foundation of the United States of America, and the CMU Sphinx Speech
+// Consortium.
+//
+// THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+// ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
+// NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+//
+// LISTENERAGENT.H - An agent that controls and monitors the speech recognition
+// component of the system.
+//
+// ----------------------------------------------------------------------------
+//
+// BEFORE MAKING CHANGES TO THIS CODE, please read the appropriate
+// documentation, available in the Documentation folder.
+//
+// ANY SIGNIFICANT CHANGES made should be reflected back in the documentation
+// file(s)
+//
+// ANY CHANGES made (even small bug fixed, should be reflected in the history
+// below, in reverse chronological order
+//
+// HISTORY --------------------------------------------------------------------
+//
+// [2007-01-26] (antoine): started working on this
+
+#ifndef __LISTENERAGENT_H__
+#define __LISTENERAGENT_H__
+
+#include "InteractionAgent.h"
+
+#define UTTERANCE_INITIAL_PAD 200
+
+class CListenerAgent: public CInteractionAgent {
+
+public:
+
+ //---------------------------------------------------------------------
+ // Constructors and destructors
+ //---------------------------------------------------------------------
+ //
+
+ CListenerAgent();
+ virtual ~CListenerAgent();
+
+
+ //---------------------------------------------------------------------
+ // Methods for accessing private fields
+ //---------------------------------------------------------------------
+ //
+
+ void SetMaxUttDuration(int iADuration);
+ int GetMaxUttDuration();
+
+ void SetUttFinalPauseDurationThreshold(int iAThreshold);
+ int GetUttFinalPauseDurationThreshold();
+
+ //---------------------------------------------------------------------
+ // Methods for manipulating input events
+ //---------------------------------------------------------------------
+ //
+
+ void ProcessEvent(CEvent &eEvent);
+
+private:
+
+ // Parameters of the endpointer
+ int iMaxUttDuration;
+ int iUttFinalPauseDurationThreshold;
+
+ void initialize();
+
+ void sendInputLineConfiguration(int iTimestamp, string sState);
+};
+
+#endif // __LISTENERAGENT_H__
Added: trunk/Agents/Apollo/Agents/SpeakerAgent.cpp
===================================================================
--- trunk/Agents/Apollo/Agents/SpeakerAgent.cpp (rev 0)
+++ trunk/Agents/Apollo/Agents/SpeakerAgent.cpp 2007-09-10 21:46:27 UTC (rev 2027)
@@ -0,0 +1,377 @@
+//=============================================================================
+//
+// Copyright (c) 2005, Carnegie Mellon University.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in
+// the documentation and/or other materials provided with the
+// distribution.
+//
+// This work was supported in part by funding from the National Science
+// Foundation of the United States of America, and the CMU Sphinx Speech
+// Consortium.
+//
+// THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+// ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
+// NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+//
+// SPEAKERAGENT.H - An agent that controls the speech synthesis component of the
+// system.
+//
+// ----------------------------------------------------------------------------
+//
+// BEFORE MAKING CHANGES TO THIS CODE, please read the appropriate
+// documentation, available in the Documentation folder.
+//
+// ANY SIGNIFICANT CHANGES made should be reflected back in the documentation
+// file(s)
+//
+// ANY CHANGES made (even small bug fixed, should be reflected in the history
+// below, in reverse chronological order
+//
+// HISTORY --------------------------------------------------------------------
+//
+// [2007-03-05] (antoine): fixed a bug in ProcessEvent for
+// system_interrupts_speaking (it didn't get the
+// tagged_prompt, bargein_pos and conveyance values
+// from the right place).
+// [2007-01-26] (antoine): started working on this
+
+#include "SpeakerAgent.h"
+
+#include "Core/IMCore.h"
+
+//---------------------------------------------------------------------
+// Constructors and destructors
+//---------------------------------------------------------------------
+//
+
+CSpeakerAgent::CSpeakerAgent(): CInteractionAgent() {}
+
+CSpeakerAgent::~CSpeakerAgent() {}
+
+
+//---------------------------------------------------------------------
+// Methods for accessing private fields
+//---------------------------------------------------------------------
+//
+
+//---------------------------------------------------------------------
+// Methods for manipulating events and actions
+//---------------------------------------------------------------------
+//
+
+void CSpeakerAgent::ProcessEvent(CEvent &eEvent) {
+
+ int iTimestamp = eEvent.GetTimestamp();
+
+ if (eEvent.GetType() != "pulse")
+ Log(AGENTS_STREAM, "%s event in SpeakerAgent: %d",
+ eEvent.GetType().c_str(), eEvent.GetTimestamp());
+
+ //////////////////////////////////////////////////
+ // Event-dependent processing
+
+ if (eEvent.GetType() == "begin_session") {
+ initialize();
+ } else if (eEvent.GetType() == "tts") {
+
+ if (eEvent.GetFeatureValue("id") == "beep") {
+ Log(AGENTS_STREAM, "Ignoring beep notification.");
+ return;
+ }
+
+ // Retrieve the utterance in question
+ vector<CUtteranceAction>::iterator puaUtt;
+ for (puaUtt = vuaUtterances.begin(); puaUtt != vuaUtterances.end(); puaUtt++) {
+ string tmp = puaUtt->GetFeatureValue("id");
+ if (puaUtt->GetFeatureValue("id") == eEvent.GetFeatureValue("id"))
+ break;
+ }
+
+ if (puaUtt == vuaUtterances.end()) {
+ Log(ERROR_STREAM, "Could not find utterance %s referenced in tts event",
+ eEvent.GetFeatureValue("id").c_str());
+ return;
+ }
+
+ // The system just started to speak the utterance
+ if (eEvent.HasFeature("system_starts_speaking")) {
+
+ Log(AGENTS_STREAM, "System started speaking at %d [%s]",
+ eEvent.GetTimestamp(), puaUtt->GetFeatureValue("id").c_str());
+
+ // Sends the notification to the DM through the hub
+ CEvent eDMStartNotification("system_utterance_start", iTimestamp);
+ eDMStartNotification.AddFeature("id", puaUtt->GetFeatureValue("id"));
+ eDMStartNotification.AddFeature("utt_count", puaUtt->GetFeatureValue("utt_count"));
+ eDMStartNotification.AddFeature("tagged_prompt", eEvent.GetFeatureValue("tagged_prompt"));
+ eDMStartNotification.AddFeature("conveyance", eEvent.GetFeatureValue("conveyance"));
+ SendEventToDM(eDMStartNotification);
+
+ // lock the state before accessing it
+ EnterCriticalSection(&csInteractionState);
+
+ // Updates interactionstate
+ s2sState["system.speaking"] = "true";
+ s2sState["system.current_prompt"] = puaUtt->GetFeatureValue("id");
+ s2sState["system.last_utterance_start_timestamp"] =
+ FormatString("%d", iTimestamp);
+ s2sState["system.utterance_scheduled"] = "";
+ s2sState["system.last_utt_state_transition_done"] = "false";
+
+ // unlock the state
+ LeaveCriticalSection(&csInteractionState);
+
+ // The system just finished speaking the utterance
+ } else if (eEvent.HasFeature("system_stops_speaking")) {
+
+ Log(AGENTS_STREAM, "System finished speaking at %d [%s]",
+ eEvent.GetTimestamp(), puaUtt->GetFeatureValue("id").c_str());
+
+ // lock the state before accessing it
+ EnterCriticalSection(&csInteractionState);
+
+ s2sState["system.speaking"] = "false";
+ if (puaUtt->GetFeatureValue("non-listening") == "true")
+ s2sState["system.non_interruptable_prompts"] = FormatString("%d",
+ atoi(s2sState["system.non_interruptable_prompts"].c_str())-1);
+ s2sState["system.last_utterance_end_timestamp"] =
+ FormatString("%d", iTimestamp);
+
+ string tmp = eEvent.GetFeatureValue("tagged_prompt");
+ // Sends the notification to the DM through the hub
+ CEvent eDMStopNotification("system_utterance_end", iTimestamp);
+ eDMStopNotification.AddFeature("id", puaUtt->GetFeatureValue("id"));
+ eDMStopNotification.AddFeature("utt_count", puaUtt->GetFeatureValue("utt_count"));
+ eDMStopNotification.AddFeature("tagged_prompt", eEvent.GetFeatureValue("tagged_prompt"));
+ eDMStopNotification.AddFeature("conveyance", eEvent.GetFeatureValue("conveyance"));
+ eDMStopNotification.AddFeature("bargein_pos", "-1");
+
+ // if the system finishes speaking an utterance that we just
+ // canceled, stop waiting for the interruption notification
+ if ((s2sState["system.waiting_for_interruption_notification"] == "true") &&
+ (s2sState["system.last_prompt_to_cancel"] == puaUtt->GetID())) {
+
+ s2sState["system.waiting_for_interruption_notification"] = "false";
+ s2sState["system.last_prompt_to_cancel"] = "";
+ } else {
+ // otherwise include the floor status implied by the utterance
+ eDMStopNotification.AddFeature("floor_status", puaUtt->GetFeatureValue("final_floor_status"));
+ }
+
+ SendEventToDM(eDMStopNotification);
+
+ vuaUtterances.erase(puaUtt);
+
+ // unlock the state
+ LeaveCriticalSection(&csInteractionState);
+
+ // The system just interrupted itself in the middle of the utterance
+ } else if (eEvent.HasFeature("system_interrupts_speaking")) {
+
+ Log(AGENTS_STREAM, "System interrupted speaking at %d [%s]",
+ eEvent.GetTimestamp(), puaUtt->GetFeatureValue("id").c_str());
+
+ // lock the state before accessing it
+ EnterCriticalSection(&csInteractionState);
+
+ s2sState["system.speaking"] = "false";
+ s2sState["system.last_utterance_end_timestamp"] =
+ FormatString("%d", iTimestamp);
+
+ // if this utterance was marked as scheduled (but not started yet),
+ // "unschedule" it
+ if (s2sState["system.utterance_scheduled"] == puaUtt->GetFeatureValue("id"))
+ s2sState["system.utterance_scheduled"] = "";
+
+ // Notifies the DM of the barged-in utterance
+ Log(AGENTS_STREAM, "Notifying DM of barge-in during utterance %s", puaUtt->GetFeatureValue("id").c_str());
+ CEvent eDMNotification("system_utterance_end", iTimestamp);
+ eDMNotification.AddFeature("id", puaUtt->GetFeatureValue("id"));
+ eDMNotification.AddFeature("utt_count", puaUtt->GetFeatureValue("utt_count"));
+ eDMNotification.AddFeature("bargein_pos", eEvent.GetFeatureValue("bargein_pos"));
+ eDMNotification.AddFeature("conveyance", eEvent.GetFeatureValue("conveyance"));
+ eDMNotification.AddFeature("tagged_prompt", eEvent.GetFeatureValue("tagged_prompt"));
+ SendEventToDM(eDMNotification);
+
+ // Notifies the DM of the canceled pending utterances
+ vector<CUtteranceAction>::iterator puaCanceledUtt;
+ Log(AGENTS_STREAM, "Next utt: %s, last to cancel: %s", puaUtt->GetID().c_str(), s2sState["system.last_prompt_to_cancel"].c_str());
+ for (puaCanceledUtt = puaUtt+1;
+ (puaCanceledUtt != vuaUtterances.end()) && (puaCanceledUtt->GetID() != s2sState["system.last_prompt_to_cancel"]);
+ puaCanceledUtt++) {
+
+
+ // if this utterance was marked as scheduled (but not started yet),
+ // "unschedule" it
+ if (s2sState["system.utterance_scheduled"] == puaCanceledUtt->GetFeatureValue("id:"))
+ s2sState["system.utterance_scheduled"] = "";
+
+ // Sends the notification to the DM through the hub
+ Log(AGENTS_STREAM, "Notifying DM of cancelation of utterance [%s]",
+ puaCanceledUtt->GetFeatureValue("id").c_str());
+ CEvent eDMCancelUtt("system_utterance_canceled", iTimestamp);
+ eDMCancelUtt.AddFeature("id", puaCanceledUtt->GetFeatureValue("id"));
+ eDMCancelUtt.AddFeature("utt_count", puaCanceledUtt->GetFeatureValue("utt_count"));
+ SendEventToDM(eDMCancelUtt);
+ }
+
+ if (puaCanceledUtt != vuaUtterances.end()) {
+ // if this utterance was marked as scheduled (but not started yet),
+ // "unschedule" it
+ if (s2sState["system.utterance_scheduled"] == puaCanceledUtt->GetFeatureValue("id"))
+ s2sState["system.utterance_scheduled"] = "";
+
+ // Sends the notification to the DM through the hub
+ Log(AGENTS_STREAM, "Notifying DM of cancelation of utterance [%s]",
+ puaCanceledUtt->GetFeatureValue("id").c_str());
+ CEvent eDMCancelUtt("system_utterance_canceled", iTimestamp);
+ eDMCancelUtt.AddFeature("id", puaCanceledUtt->GetFeatureValue("id"));
+ eDMCancelUtt.AddFeature("utt_count", puaCanceledUtt->GetFeatureValue("utt_count"));
+ SendEventToDM(eDMCancelUtt);
+ puaCanceledUtt++;
+ }
+
+ // Now actually dequeue the barged-in utterances
+ vuaUtterances.erase(puaUtt, puaCanceledUtt);
+ //vuaUtterances.erase(vuaUtterances.begin(), vuaUtterances.end());
+
+ s2sState["system.waiting_for_interruption_notification"] = "false";
+ s2sState["system.last_prompt_to_cancel"] = "";
+
+ // unlock the state
+ LeaveCriticalSection(&csInteractionState);
+
+ }
+ } else if (eEvent.GetType() == "turn_taking") {
+ if ((eEvent.GetFeatureValue("user_takes_floor") == "true") &&
+ ((s2sState["system.speaking"] == "true") ||
+ (s2sState["system.utterance_scheduled"] != ""))) {
+ Log(AGENTS_STREAM, "User barge-in detected [%s]", s2sState["system.current_prompt"].c_str());
+
+ // Tells the audio server to interrupt the current utterance
+ TGIGalaxyCall gcReset;
+ gcReset.bBlockingCall = false;
+ gcReset.sModuleFunction = "kalliope.reset";
+ CallGalaxyModuleFunction(&gcReset);
+
+ s2sState["system.speaking"] = "false";
+ s2sState["system.waiting_for_interruption_notification"] = "true";
+ s2sState["system.last_prompt_to_cancel"] = vuaUtterances.back().GetID();
+ }
+ }
+
+ //////////////////////////////////////////////////
+ // Event-independent processing
+
+ // lock the state before accessing it
+ EnterCriticalSection(&csInteractionState);
+
+ // Starts a new system utterance
+ if ((s2sState["system.speaking"] != "true") &&
+ (s2sState["system.utterance_scheduled"] == "") &&
+ (s2sState["system.waiting_for_interruption_notification"] != "true")) {
+
+ if (!vuaUtterances.empty()) {
+
+ CUtteranceAction uaUtt = vuaUtterances[0];
+
+ Log(AGENTS_STREAM, "Requesting to start speaking utterance [%s]", uaUtt.GetFeatureValue("id").c_str());
+
+ // Asks Kalliope to start speaking the next utterance
+ TGIGalaxyCall gcSystemUtt;
+ gcSystemUtt.s2sInputs["id"] = uaUtt.GetFeatureValue("id");
+ gcSystemUtt.bBlockingCall = false;
+ gcSystemUtt.sModuleFunction = "kalliope.speak";
+ CallGalaxyModuleFunction(&gcSystemUtt);
+
+ s2sState["system.utterance_scheduled"] = uaUtt.GetFeatureValue("id");
+ }
+ }
+
+ // Detects a change of dialog state during a system utterance
+ if ((s2sState["system.speaking"] == "true") &&
+ (s2sState["system.last_utt_state_transition_done"] != "true")) {
+
+ int iUttStartTimestamp = atoi(s2sState["system.last_utterance_start_timestamp"].c_str());
+
+ Log(AGENTS_STREAM, "State transition... %d-%d = %d <> 200",
+ iTimestamp, iUttStartTimestamp, iTimestamp-iUttStartTimestamp);
+
+ if (iTimestamp-iUttStartTimestamp > 200) {
+
+ Log(AGENTS_STREAM, "Notifying DM of dialog state change [%s]",
+ s2sState["system.current_prompt"].c_str());
+ CEvent eDMState("dialog_state_change", iTimestamp);
+ eDMState.AddFeature("id", s2sState["system.current_prompt"]);
+ SendEventToDM(eDMState);
+
+ s2sState["system.last_utt_state_transition_done"] = "true";
+ }
+ }
+
+ // unlock the state
+ LeaveCriticalSection(&csInteractionState);
+}
+
+void CSpeakerAgent::ProcessAction(CAction &aAction) {
+
+ // Checks if the Action is actually an UtteranceAction
+ CUtteranceAction *puaUtt = dynamic_cast<CUtteranceAction*>(&aAction);
+ if (puaUtt) {
+
+ Log(AGENTS_STREAM, "Received new system utterance action. Sending to the nlg. [%s]", puaUtt->GetFeatureValue("id").c_str());
+
+ EnterCriticalSection(&csInteractionState);
+ if (puaUtt->GetFeatureValue("non-listening") == "true")
+ s2sState["system.non_interruptable_prompts"] = FormatString("%d",
+ atoi(s2sState["system.non_interruptable_prompts"].c_str())+1);
+ vuaUtterances.push_back(*puaUtt);
+ LeaveCriticalSection(&csInteractionState);
+
+ // if so, sends it to the nlg/tts to prepare the synthesized speech asap
+ TGIGalaxyCall gcUtt;
+
+ // fill in the Galaxy call properties
+ gcUtt.s2sInputs = STRING2STRING(puaUtt->GetFeatures());
+ gcUtt.s2sInputs["action_id"] = puaUtt->GetID();
+ gcUtt.s2sInputs["action_type"] = puaUtt->GetType();
+ gcUtt.bBlockingCall = false;
+ gcUtt.sModuleFunction = "nlg.launch_query";
+
+ CallGalaxyModuleFunction(&gcUtt);
+
+ }
+}
+
+//---------------------------------------------------------------------
+// Private methods
+//---------------------------------------------------------------------
+//
+
+// (re-)initializes the agent at the beginning of a session
+void CSpeakerAgent::initialize() {
+ // Empties the utterance queue
+ vuaUtterances.clear();
+}
Added: trunk/Agents/Apollo/Agents/SpeakerAgent.h
===================================================================
--- trunk/Agents/Apollo/Agents/SpeakerAgent.h (rev 0)
+++ trunk/Agents/Apollo/Agents/SpeakerAgent.h 2007-09-10 21:46:27 UTC (rev 2027)
@@ -0,0 +1,97 @@
+//=============================================================================
+//
+// Copyright (c) 2005, Carnegie Mellon University.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in
+// the documentation and/or other materials provided with the
+// distribution.
+//
+// This work was supported in part by funding from the National Science
+// Foundation of the United States of America, and the CMU Sphinx Speech
+// Consortium.
+//
+// THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
+// ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
+// NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+//
+// SPEAKERAGENT.H - An agent that controls the speech synthesis component of the
+// system.
+//
+// ----------------------------------------------------------------------------
+//
+// BEFORE MAKING CHANGES TO THIS CODE, please read the appropriate
+// documentation, available in the Documentation folder.
+//
+// ANY SIGNIFICANT CHANGES made should be reflected back in the documentation
+// file(s)
+//
+// ANY CHANGES made (even small bug fixed, should be reflected in the history
+// below, in reverse chronological order
+//
+// HISTORY --------------------------------------------------------------------
+//
+// [2007-01-26] (antoine): started working on this
+
+#ifndef __SPEAKERAGENT_H__
+#define __SPEAKERAGENT_H__
+
+#include "Agents/InteractionAgent.h"
+#include "Actions/UtteranceAction.h"
+
+class CSpeakerAgent: public CInteractionAgent {
+
+public:
+
+ //---------------------------------------------------------------------
+ // Constructors and destructors
+ //---------------------------------------------------------------------
+ //
+
+ CSpeakerAgent();
+ virtual ~CSpeakerAgent();
+
+
+ //---------------------------------------------------------------------
+ // Methods for accessing private fields
+ //---------------------------------------------------------------------
+ //
+
+ //---------------------------------------------------------------------
+ // Methods for manipulating events and actions
+ //---------------------------------------------------------------------
+ //
+
+ void ProcessEvent(CEvent &eEvent);
+
+ void ProcessAction(CAction &aAction);
+
+private:
+
+ vector<CUtteranceAction> vuaUtterances;
+
+ void initialize();
+};
+
+#endif // __SPEAKERAGENT_H__
+
More information about the Ravenclaw-developers
mailing list