EchoTrio
 
Loading...
Searching...
No Matches
EchoTrio.VoiceChat Class Reference
Inheritance diagram for EchoTrio.VoiceChat:
Inheritance graph
Collaboration diagram for EchoTrio.VoiceChat:
Collaboration graph

Classes

class  ActorOutput
 Output of actors to be queued and played by the audio thread. More...
 
class  ActorReferences
 Reference to an actor configuration, and the AudioSource it should play it's output audio from. More...
 

Public Member Functions

void ToggleMicMute ()
 Toggle the director's microphone on or off.
 
void ToggleChatbox ()
 Toggle the chatbox to be active or inactive.
 
void ResetIdleTimer ()
 Reset the idle timer, usually invoked whenever there's any input by the user, such as typing something into the chatbox, or unmuting the microphone.
 
async Awaitable< bool > SubmitUserTextInput (string message)
 Submit the user text input. Used as an alternative to speaking into the microphone, usually for development & debugging purposes.
 
int GetRoundCounter ()
 
int GetFinishRound ()
 

Private Types

enum  State {
  Invalid = -1 , Idle , Prepare , Wait ,
  Listen , FreeTalk , Discuss , Finish ,
  Num
}
 All the possible states of the system. More...
 

Private Member Functions

void Awake ()
 
void OnDestroy ()
 
void OnEnable ()
 
void OnDisable ()
 
void Start ()
 
void Update ()
 
void LateUpdate ()
 
void QueueActorOutput (ActorOutput actorOutput)
 Queue up an actor's output to be played by the audio thread.
 
IEnumerator AudioThread ()
 Launch an audio thread via Coroutine to play any queued audio from the actors.
 
void PropogateActorMessage (Actor speaker, string message)
 Send the message received from one actor, to all the other actors.
 
void PropogateUserMessage (string message)
 Send the message received from the user to all the actors.
 
void BeginQueuingAudio ()
 Flag that audio is being queued.
 
void EndQueuingAudio ()
 Flag that audio is not queued.
 
void OnEnterIdle ()
 
void OnEnterPrepare ()
 
void OnEnterWait ()
 
void OnUpdateWait ()
 
void OnEnterListen ()
 
void OnUpdateListen ()
 
async void RunFreeTalk ()
 
void OnEnterFreeTalk ()
 
async void RunScriptedDiscussion (ScriptedDiscussion discussion)
 
async void RunGeneratedDiscussion (GeneratedDiscussion discussion)
 
void OnEnterDiscuss ()
 
void OnEnterFinish ()
 
void OnGameStart ()
 
void OnGameContinue ()
 
void OnPushToTalkStarted (UnityEngine.InputSystem.InputAction.CallbackContext context)
 
void OnPushToTalkCancelled (UnityEngine.InputSystem.InputAction.CallbackContext context)
 
void OnDirectorResponse (Director.Response response)
 
void Override ()
 

Private Attributes

EchoTrio.UI.Chatbox chatbox = null
 
TMPro.TextMeshProUGUI roundCounterText = null
 
TMPro.TextMeshProUGUI idleTimerText = null
 
DirectorConfig directorConfig = null
 
ActorReferences[] actorReferences = new ActorReferences[0]
 
Discussion[] discussions = new Discussion[0]
 
int finishRound = 10
 
bool enableDebug = true
 
bool showReasoning = true
 
GameInputActions gameInputActions = null
 
FSM.FiniteStateMachine fsm = new FSM.FiniteStateMachine((int)State.Num)
 
Dictionary< string,(Actor, AudioSource)> actors = new Dictionary<string, (Actor, AudioSource)>()
 
Director director = null
 
int roundCounter = 0
 
float idleTimer = 0.0f
 
bool continueChat = false
 
bool isAudioPlaying = false
 
bool isQueueingAudio = false
 
Queue< ActorOutputactorOutputQueue = new Queue<ActorOutput>()
 
Dictionary< AudioClip, bool > audioClipGarbageCollector = new Dictionary<AudioClip, bool>()
 
List< DiscussionuntriggeredDiscussions = null
 
Queue< DiscussiondiscussionQueue = new Queue<Discussion>()
 
Queue< string > speakerQueue = new Queue<string>()
 

Static Private Attributes

const string OverrideFileName = "GameOverrides.ini"
 

Detailed Description

Voice chat system that acts as an intermediary between the human user and the AI models. The system works using the concept of rounds. During every round, a few things may happen.

  • A scripted discussion is triggered at the start of the round specified by the designer where the actors speak scripted lines. No user input is allowed in this round. OR
  • A generated discussion is triggered at the start of the round specified by the designer where the actors speak AI generated lines. No user input is allowed in this round. OR
  • User input is accepted and the actors generates a reply. OR
  • User input is accepted and it triggers a scripted or generated discussion as the reply from the actors if the user mentions certain topics. OR
  • User input is allowed by the user does not provide any input. A scripted or generated dicussion is triggered after some time as specified by the designer.

Definition at line 18 of file VoiceChat.cs.

Member Enumeration Documentation

◆ State

All the possible states of the system.

Enumerator
Invalid 
Idle 

Idle while waiting for player to start the game.

Prepare 

Before we start each round, we enter the Prepare stage, and make a decision of which state to enter for the round.

Wait 

If user input is allowed this round, enter the Wait stage to wait for the actors to finish speaking, and ensure that the director has connected to OpenAI's server.

Listen 

Listen for user input.

FreeTalk 

Actors responding to user input as per normal AI conversations.

Discuss 

Actors playing a scripted discussion, or generating a discussion on a topic.

Finish 

The chat has ended.

Num 

Definition at line 22 of file VoiceChat.cs.

Member Function Documentation

◆ AudioThread()

IEnumerator EchoTrio.VoiceChat.AudioThread ( )
inlineprivate

Launch an audio thread via Coroutine to play any queued audio from the actors.

Returns
An IEnumerator for Coroutine.

Definition at line 265 of file VoiceChat.cs.

◆ Awake()

void EchoTrio.VoiceChat.Awake ( )
inlineprivate

Definition at line 141 of file VoiceChat.cs.

◆ BeginQueuingAudio()

void EchoTrio.VoiceChat.BeginQueuingAudio ( )
inlineprivate

Flag that audio is being queued.

Definition at line 349 of file VoiceChat.cs.

◆ EndQueuingAudio()

void EchoTrio.VoiceChat.EndQueuingAudio ( )
inlineprivate

Flag that audio is not queued.

Definition at line 356 of file VoiceChat.cs.

◆ GetFinishRound()

int EchoTrio.VoiceChat.GetFinishRound ( )
inline

Definition at line 138 of file VoiceChat.cs.

◆ GetRoundCounter()

int EchoTrio.VoiceChat.GetRoundCounter ( )
inline

Definition at line 136 of file VoiceChat.cs.

◆ LateUpdate()

void EchoTrio.VoiceChat.LateUpdate ( )
inlineprivate

Definition at line 231 of file VoiceChat.cs.

◆ OnDestroy()

void EchoTrio.VoiceChat.OnDestroy ( )
inlineprivate

Definition at line 173 of file VoiceChat.cs.

◆ OnDirectorResponse()

void EchoTrio.VoiceChat.OnDirectorResponse ( Director::Response  response)
inlineprivate

Callback invoked by the director when it has a response ready.

Parameters
responseThe director's response.

Definition at line 565 of file VoiceChat.cs.

◆ OnDisable()

void EchoTrio.VoiceChat.OnDisable ( )
inlineprivate

Definition at line 194 of file VoiceChat.cs.

◆ OnEnable()

void EchoTrio.VoiceChat.OnEnable ( )
inlineprivate

Definition at line 183 of file VoiceChat.cs.

◆ OnEnterDiscuss()

void EchoTrio.VoiceChat.OnEnterDiscuss ( )
inlineprivate

Definition at line 517 of file VoiceChat.cs.

◆ OnEnterFinish()

void EchoTrio.VoiceChat.OnEnterFinish ( )
inlineprivate

Definition at line 537 of file VoiceChat.cs.

◆ OnEnterFreeTalk()

void EchoTrio.VoiceChat.OnEnterFreeTalk ( )
inlineprivate

Definition at line 471 of file VoiceChat.cs.

◆ OnEnterIdle()

void EchoTrio.VoiceChat.OnEnterIdle ( )
inlineprivate

Definition at line 363 of file VoiceChat.cs.

◆ OnEnterListen()

void EchoTrio.VoiceChat.OnEnterListen ( )
inlineprivate

Definition at line 406 of file VoiceChat.cs.

◆ OnEnterPrepare()

void EchoTrio.VoiceChat.OnEnterPrepare ( )
inlineprivate

Definition at line 366 of file VoiceChat.cs.

◆ OnEnterWait()

void EchoTrio.VoiceChat.OnEnterWait ( )
inlineprivate

Definition at line 390 of file VoiceChat.cs.

◆ OnGameContinue()

void EchoTrio.VoiceChat.OnGameContinue ( )
inlineprivate

Definition at line 551 of file VoiceChat.cs.

◆ OnGameStart()

void EchoTrio.VoiceChat.OnGameStart ( )
inlineprivate

Definition at line 545 of file VoiceChat.cs.

◆ OnPushToTalkCancelled()

void EchoTrio.VoiceChat.OnPushToTalkCancelled ( UnityEngine::InputSystem::InputAction::CallbackContext  context)
inlineprivate

Definition at line 561 of file VoiceChat.cs.

◆ OnPushToTalkStarted()

void EchoTrio.VoiceChat.OnPushToTalkStarted ( UnityEngine::InputSystem::InputAction::CallbackContext  context)
inlineprivate

Definition at line 559 of file VoiceChat.cs.

◆ OnUpdateListen()

void EchoTrio.VoiceChat.OnUpdateListen ( )
inlineprivate

Definition at line 425 of file VoiceChat.cs.

◆ OnUpdateWait()

void EchoTrio.VoiceChat.OnUpdateWait ( )
inlineprivate

Definition at line 392 of file VoiceChat.cs.

◆ Override()

void EchoTrio.VoiceChat.Override ( )
inlineprivate

Definition at line 606 of file VoiceChat.cs.

◆ PropogateActorMessage()

void EchoTrio.VoiceChat.PropogateActorMessage ( Actor  speaker,
string  message 
)
inlineprivate

Send the message received from one actor, to all the other actors.

Parameters
speakerThe actor that the message was received from.
messageThe actor's message.

Definition at line 329 of file VoiceChat.cs.

◆ PropogateUserMessage()

void EchoTrio.VoiceChat.PropogateUserMessage ( string  message)
inlineprivate

Send the message received from the user to all the actors.

Parameters
messageThe user's message.

Definition at line 341 of file VoiceChat.cs.

◆ QueueActorOutput()

void EchoTrio.VoiceChat.QueueActorOutput ( ActorOutput  actorOutput)
inlineprivate

Queue up an actor's output to be played by the audio thread.

Parameters
actorOutputThe actor output to queue.

Definition at line 240 of file VoiceChat.cs.

◆ ResetIdleTimer()

void EchoTrio.VoiceChat.ResetIdleTimer ( )
inline

Reset the idle timer, usually invoked whenever there's any input by the user, such as typing something into the chatbox, or unmuting the microphone.

Definition at line 125 of file VoiceChat.cs.

◆ RunFreeTalk()

async void EchoTrio.VoiceChat.RunFreeTalk ( )
inlineprivate

Definition at line 451 of file VoiceChat.cs.

◆ RunGeneratedDiscussion()

async void EchoTrio.VoiceChat.RunGeneratedDiscussion ( GeneratedDiscussion  discussion)
inlineprivate

Definition at line 496 of file VoiceChat.cs.

◆ RunScriptedDiscussion()

async void EchoTrio.VoiceChat.RunScriptedDiscussion ( ScriptedDiscussion  discussion)
inlineprivate

Definition at line 477 of file VoiceChat.cs.

◆ Start()

void EchoTrio.VoiceChat.Start ( )
inlineprivate

Definition at line 205 of file VoiceChat.cs.

◆ SubmitUserTextInput()

async Awaitable< bool > EchoTrio.VoiceChat.SubmitUserTextInput ( string  message)
inline

Submit the user text input. Used as an alternative to speaking into the microphone, usually for development & debugging purposes.

Parameters
messageThe user text input.
Returns
Returns true if the voice chat system is currently accepting user input. Else, returns false.

Definition at line 132 of file VoiceChat.cs.

◆ ToggleChatbox()

void EchoTrio.VoiceChat.ToggleChatbox ( )
inline

Toggle the chatbox to be active or inactive.

Definition at line 119 of file VoiceChat.cs.

◆ ToggleMicMute()

void EchoTrio.VoiceChat.ToggleMicMute ( )
inline

Toggle the director's microphone on or off.

Definition at line 113 of file VoiceChat.cs.

◆ Update()

void EchoTrio.VoiceChat.Update ( )
inlineprivate

Definition at line 211 of file VoiceChat.cs.

Member Data Documentation

◆ actorOutputQueue

Queue<ActorOutput> EchoTrio.VoiceChat.actorOutputQueue = new Queue<ActorOutput>()
private

Definition at line 101 of file VoiceChat.cs.

◆ actorReferences

ActorReferences [] EchoTrio.VoiceChat.actorReferences = new ActorReferences[0]
private

Definition at line 77 of file VoiceChat.cs.

◆ actors

Dictionary<string, (Actor, AudioSource)> EchoTrio.VoiceChat.actors = new Dictionary<string, (Actor, AudioSource)>()
private

Definition at line 92 of file VoiceChat.cs.

◆ audioClipGarbageCollector

Dictionary<AudioClip, bool> EchoTrio.VoiceChat.audioClipGarbageCollector = new Dictionary<AudioClip, bool>()
private

Definition at line 102 of file VoiceChat.cs.

◆ chatbox

EchoTrio.UI.Chatbox EchoTrio.VoiceChat.chatbox = null
private

Definition at line 71 of file VoiceChat.cs.

◆ continueChat

bool EchoTrio.VoiceChat.continueChat = false
private

Definition at line 96 of file VoiceChat.cs.

◆ director

Director EchoTrio.VoiceChat.director = null
private

Definition at line 93 of file VoiceChat.cs.

◆ directorConfig

DirectorConfig EchoTrio.VoiceChat.directorConfig = null
private

Definition at line 76 of file VoiceChat.cs.

◆ discussionQueue

Queue<Discussion> EchoTrio.VoiceChat.discussionQueue = new Queue<Discussion>()
private

Definition at line 106 of file VoiceChat.cs.

◆ discussions

Discussion [] EchoTrio.VoiceChat.discussions = new Discussion[0]
private

Definition at line 80 of file VoiceChat.cs.

◆ enableDebug

bool EchoTrio.VoiceChat.enableDebug = true
private

Definition at line 86 of file VoiceChat.cs.

◆ finishRound

int EchoTrio.VoiceChat.finishRound = 10
private

Definition at line 83 of file VoiceChat.cs.

◆ fsm

FSM.FiniteStateMachine EchoTrio.VoiceChat.fsm = new FSM.FiniteStateMachine((int)State.Num)
private

Definition at line 91 of file VoiceChat.cs.

◆ gameInputActions

GameInputActions EchoTrio.VoiceChat.gameInputActions = null
private

Definition at line 90 of file VoiceChat.cs.

◆ idleTimer

float EchoTrio.VoiceChat.idleTimer = 0.0f
private

Definition at line 95 of file VoiceChat.cs.

◆ idleTimerText

TMPro.TextMeshProUGUI EchoTrio.VoiceChat.idleTimerText = null
private

Definition at line 73 of file VoiceChat.cs.

◆ isAudioPlaying

bool EchoTrio.VoiceChat.isAudioPlaying = false
private

Definition at line 99 of file VoiceChat.cs.

◆ isQueueingAudio

bool EchoTrio.VoiceChat.isQueueingAudio = false
private

Definition at line 100 of file VoiceChat.cs.

◆ OverrideFileName

const string EchoTrio.VoiceChat.OverrideFileName = "GameOverrides.ini"
staticprivate

Definition at line 19 of file VoiceChat.cs.

◆ roundCounter

int EchoTrio.VoiceChat.roundCounter = 0
private

Definition at line 94 of file VoiceChat.cs.

◆ roundCounterText

TMPro.TextMeshProUGUI EchoTrio.VoiceChat.roundCounterText = null
private

Definition at line 72 of file VoiceChat.cs.

◆ showReasoning

bool EchoTrio.VoiceChat.showReasoning = true
private

Definition at line 87 of file VoiceChat.cs.

◆ speakerQueue

Queue<string> EchoTrio.VoiceChat.speakerQueue = new Queue<string>()
private

Definition at line 109 of file VoiceChat.cs.

◆ untriggeredDiscussions

List<Discussion> EchoTrio.VoiceChat.untriggeredDiscussions = null
private

Definition at line 105 of file VoiceChat.cs.


The documentation for this class was generated from the following file: