Text box to have Convai say whatever i write

Hey team!

Im curious to know if there is a way we can have a text inputted and then convai will just say what was written

For example → i have a text box…i enter some text in english. And then hit speak [a button] and then convai needs to just speak it out.

Hoping to hear back from yall!

Hello @Dylan_Suaris,

You can use the following method from NarrativeDesignTrigger.cs to make your Convai character speak a specific line of text. Additionally, you can utilize the <speak> tag within the message parameter to ensure the text is spoken exactly as written:

public void InvokeSpeech(string message)
{
    if (convaiNPC != null && !string.IsNullOrEmpty(message))
    {
        ConvaiNPCManager.Instance.SetActiveConvaiNPC(convaiNPC, false);
        onTriggerEvent?.Invoke();
        convaiNPC.TriggerSpeech(message);
    }
}

Example Usage:

InvokeSpeech("<speak> I'll say this exact line! </speak>");

How to Implement:

  1. Pass the desired text (including the <speak> tag if needed) into the InvokeSpeech method.
  2. Trigger this method through a button click or other event in your Unity project.

This ensures precise control over what the character says. Let us know if you have further questions! :blush:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.