How to get Layered Character's OnStartedSpeaking and OnFinishedSpeaking to work?

Posted: 21 Aug 2021 16:52
by ville.helin

Hi!

I'm adding custom objects + code that basically run lip sync animations and analyses the currently playing audio sample to a project that is built using Naninovel. Currently I've added OnStartedSpeaking and OnFinishedSpeaking callbacks to a LayeredCharacterBehaviour, but what happens in that when a character starts to speak OnFinishedSpeaking is called right away and that's it.

What do I need to do / where to look to make both OnStartedSpeaking and OnFinishedSpeaking to work properly? :)


Re: How to get Layered Character's OnStartedSpeaking and OnFinishedSpeaking to work?

Posted: 22 Aug 2021 13:09
by ville.helin

Problem solved! The reason why OnStartedSpeaking was not called was that the LayeredCharacter wasn't set as author.

This didn't work:

@print "Hello World" wait:false

... but what worked was

@print "Hello World" wait:false author:Eve

There still are two problems in our case:

  1. OnFinishedSpeaking is called first, before any OnStartedSpeaking is called - logic error. We could work around this in our custom code...
  2. Naninovel<Runtime>/AudioController has two AudioSources:
    • One for the character's speech
    • One for "text_bleed" sound
      As I attach my script that has OnAudioFilterRead() to that AudioController object, we get this error in the Console:
      "GameObject has multiple AudioSources and/or AudioListeners attached. While built-in filters like lowpass are instantiated separately, the custom script DSP filter components may only be used by either one AudioSource or AudioListener at a time."
      ... Still everything works, but it would be nice if "text_bleeb" had its own GameObject...

Re: How to get Layered Character's OnStartedSpeaking and OnFinishedSpeaking to work?

Posted: 22 Aug 2021 15:06
by idaot

1) I am not getting this error, tested with the latest pre-release. Make sure the callback is set up correctly. I used this script:

Code: Select all

void Start()
    {
        GetComponent<Naninovel.LayeredCharacterBehaviour>().OnIsSpeakingChanged += IsSpeaking;
    }

private void IsSpeaking(bool speaking)
{
    if (speaking)
    {
        Debug.Log(true);
    }
    else
    {
        Debug.Log(false);
    }
}

2) Under the character configuration, there is a field called Voice Source in which you can add an Audio Source object which will be instantiated under the character object during runtime. This object can be accessed via GetConfiguration<CharactersConfiguration>(). More information on accessing configuration objects can be found here: https://naninovel.com/guide/custom-conf ... figuration


Re: How to get Layered Character's OnStartedSpeaking and OnFinishedSpeaking to work?

Posted: 22 Jan 2022 01:42
by AmberRose

I actually have the same problem. I set the animation to start under the finish speaking command, and stop on the start command. Just as a temporary workaround, but hoping to find the source of the issue soon.


Re: How to get Layered Character's OnStartedSpeaking and OnFinishedSpeaking to work?

Posted: 22 Jan 2022 12:12
by idaot

The problem is probably to do with the animation, not Naninovel. The callback works correctly. If you are using Animator, be sure to check tutorials as there are state settings you have to be mindful of when setting them up.