Hi,
In the AI Add-on, using Realtime NPC Chat AI, I'm trying to find a way to intercept the converted text response created from the Player's voice input and then add extra context to it before I send it through as a response to the NPC Chat AI Actor.
What would be the best way to go about this?
[AI-Addon] - How to extract Player's converted text response, add extra context and then send through to AI Chat NPC?
-
- Posts: 7
- Joined: Mon Jun 02, 2025 1:56 pm
-
- Posts: 7
- Joined: Mon Jun 02, 2025 1:56 pm
Re: [AI-Addon] - How to extract Player's converted text response, add extra context and then send through to AI Chat NP
From what I can tell the best way is gonna be through the followinf function in RuntimeAIConversation.cs, but not sure if that's correct:
protected virtual void OnReceivedLine(string line)
{
if (DialogueDebug.logInfo) Debug.Log($"Dialogue System: Received from {ServiceName}: {line}", this);
if (string.IsNullOrEmpty(line))
{
OnClickedGoodbye();
}
else
{
approximateTokenCount += line.Length / ApproximateCharactersPerToken;
line = RemoveConversant(line);
messages.Add(new ChatMessage("user", $"{conversant} says: {line}"));
if (IsVoiceEnabled)
{
GenerateVoice(line);
}
else
{
ShowSubtitle(line, null);
}
}
}
protected virtual void OnReceivedLine(string line)
{
if (DialogueDebug.logInfo) Debug.Log($"Dialogue System: Received from {ServiceName}: {line}", this);
if (string.IsNullOrEmpty(line))
{
OnClickedGoodbye();
}
else
{
approximateTokenCount += line.Length / ApproximateCharactersPerToken;
line = RemoveConversant(line);
messages.Add(new ChatMessage("user", $"{conversant} says: {line}"));
if (IsVoiceEnabled)
{
GenerateVoice(line);
}
else
{
ShowSubtitle(line, null);
}
}
}
Re: [AI-Addon] - How to extract Player's converted text response, add extra context and then send through to AI Chat NP
Hi,
Make and use a subclass of RuntimeAIConversation. (You can replace RuntimeAIConversation with the subclass in-place on a GameObject to retain inspector assignments. See here.)
Override the OnReceivedTranscription(string) method, such as:
Make and use a subclass of RuntimeAIConversation. (You can replace RuntimeAIConversation with the subclass in-place on a GameObject to retain inspector assignments. See here.)
Override the OnReceivedTranscription(string) method, such as:
Code: Select all
protected override void OnReceivedTranscription(string s)
{
s += "Your additional context.";
base.OnReceivedTranscription(s);
}
-
- Posts: 7
- Joined: Mon Jun 02, 2025 1:56 pm
Re: [AI-Addon] - How to extract Player's converted text response, add extra context and then send through to AI Chat NP
Awesome! Perfect, thanks Tony. I thought this would be the best solution, just needed confirmation.