Forum rules - please read before posting.

Expressions for Narrator

Hey Chris,

I currently try to use [expression:X] tags not for visual expressions but for text-to-speech synthesis.

But I realized that the expression tags are not removed from the dialog text if the speaker is the narrator, which means that my approach would not work for all narratives.

I looked into the code and could find a possible solution.

I wrote this small patch:

--- a/Assets/AdventureCreator/Scripts/Speech/Speech.cs
+++ b/Assets/AdventureCreator/Scripts/Speech/Speech.cs
@@ -1100,13 +1100,19 @@
                        i = -1;
                        continue;
                    }
-                   else if (textPortion2.StartsWith ("[expression:") && speaker)
+                   else if (textPortion2.StartsWith ("[expression:"))
                    {
-                       // Expression change
+                       // Expression change - process for all speakers (including narrator for TTS)
                        int endIndex = textPortion2.IndexOf ("]");
                        string expressionText = textPortion2.Substring (12, endIndex - 12);
-                       int expressionID = speaker.GetExpressionID (expressionText);

-                       speechGaps.Add (new SpeechGap (i, expressionID));
+                       // Only add speechGap for visual expression if speaker exists
+                       if (speaker)
+                       {
+                           int expressionID = speaker.GetExpressionID (expressionText);
+                           speechGaps.Add (new SpeechGap (i, expressionID));
+                       }
+
+                       // Always remove the tag from text (for UI display and TTS)
                        _text = textPortion1 + textPortion2.Substring (endIndex + 1);

                        i = -1;

I hope it will make it into the next release.

Best regards, André

PS: I am working on my game (on and off) for nearly 8 years now. I am so happy that the Adventure Creator plugin is still supported and that Unity also still exists. I know that not finishing a project for that long time is at high risk, but I want to thank you for this very stable and helpful tool that saved me so much time.

Comments

  • Thanks, I'll take a look.

    Though you've already solved this yourself, for the benefit of future users: it's possible to use custom speech text tokens to insert custom code / data into speech lines. The Manual's "Speech event tokens" chapter has the details.

  • That's interesting... so I could simply replace `[expression` by `[emo` and have to register `emo` as Speech Event Token. I don't have to implement `OnSpeechToken` because there is not action needed.

    I will try that. I hope this is independent from character / narrator. If that's so, I would follow the argumentation that a narrator does not have an avatar and so it does not have facial expressions, which would make my bugfix obsolete. On the other hand it's maybe fine to remove these tags independently from current (non-)character.

    Nevertheless, the Speech Event Tokens are a very powerful feature. You can simplify the Action Lists a lot if you use them in a clever way.

    Thanks.
  • On the other hand it's maybe fine to remove these tags independently from current (non-)character.

    Indeed - I'll be applying this change to v1.85.1

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.