Skip to content

Commit ba7af85

Browse files
Add AfterSTT() method
1 parent 3397f5c commit ba7af85

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

unity/Editor/BaseAgentController.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ internal sealed class BaseAgentController : MonoBehaviour, IAgent
3939
/// Action invoked after TTS playback finishes
4040
/// </summary>
4141
[HideInInspector] public Action AfterTTS { get; set; }
42+
/// <summary>
43+
/// Action invoked after STT transcription
44+
/// </summary>
45+
[HideInInspector] public Action AfterSTT { get; set; }
46+
4247
private int _responseCount;
4348

4449
// STT
@@ -185,6 +190,9 @@ private async void OnRecordStop(AudioChunk recordedAudio)
185190
if (res == null) return;
186191

187192
_output = res.Result;
193+
194+
AfterSTT?.Invoke();
195+
188196
await SafeExecutionUtils.SafeExecute("SendMessage", SendMessage, _output);
189197
}
190198
#endregion

unity/Runtime/AgentManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ public static class AgentManager
1515
/// <param name="beh">Behaviour to attach</param>
1616
public static void SetBehaviourToAgent<T>(T agent, AgentBehaviour beh) where T: MonoBehaviour, IAgent
1717
{
18-
agent.AfterTTS += beh.AfterTTS;
1918
agent.BeforeTTS += beh.BeforeTTS;
19+
agent.AfterTTS += beh.AfterTTS;
20+
agent.AfterSTT += beh.AfterSTT;
2021
}
2122
}
2223
}

unity/Runtime/AgentUtils.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public interface IAgent
1212
{
1313
public Action<AgentState> BeforeTTS { get; set; }
1414
public Action AfterTTS { get; set; }
15+
public Action AfterSTT { get; set; }
1516
}
1617

1718
/// <summary>
@@ -35,9 +36,14 @@ public abstract class AgentBehaviour : MonoBehaviour
3536
public abstract void BeforeTTS(AgentState state);
3637

3738
/// <summary>
38-
/// Called after receiving and playing the TTS response
39+
/// Called after receiving and playing the Text-To-Speech response
3940
/// </summary>
4041
public abstract void AfterTTS();
42+
43+
/// <summary>
44+
/// Called after Speech-To-Text transcription
45+
/// </summary>
46+
public abstract void AfterSTT();
4147
}
4248

4349
/// <summary>

0 commit comments

Comments
 (0)