[HOWTO] How To: Vary Character Mumble Speak With Typewriter Effect

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Vary Character Mumble Speak With Typewriter Effect

Post by Tony Li »

Here are two ways to play character-specific "mumble speak" audio for characters as their subtitle text types out:

1. Make a copy of the subtitle panel for each character, and assign them to the Standard Dialogue UI's list of subtitle panels. Add a Dialogue Actor component to each character, and select the subtitle panel number to use (e.g., 0 for male, 2 for female, etc.). Then customize that subtitle panel's typewriter effect.

2. Or, if you want to use one subtitle panel, assign a C# method to the typewriter effect's OnBegin() method. In this method, set the typewriter effect's audio clip. If you put the audio clips in a Resources folder, you can add a custom field to each actor that specifies the audio clip name. In your C# method, look up that field, load the corresponding audio clip, and assign it. Something like:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class SetTypewriterForActor : MonoBehaviour
{
    public void OnBeginTypewriter() // Assign to typewriter's OnBegin() event.
    {
        // Look up character's audio clip:
        var actorName = DialogueManager.currentConversationState.subtitle.speakerInfo.nameInDatabase;
        var clipName = DialogueManager.masterDatabase.GetActor(actorName).LookupValue("AudioClip");
        var clip = Resources.Load<AudioClip>(clipName);

        // Assign to typewriter:
        var typewriter = GetComponent<AbstractTypewriterEffect>();
        typewriter.audioClip = clip;
        typewriter.audioSource.clip = clip;
    }
}
Example scene:

ModifyTypewriterExample_2019-09-11.unitypackage
(Exported from Unity 2019.1.)

Let's say you have an audio clip for each actor. Put them in a folder named Resources:

Image

The Resources folder can be anywhere in your project, and you can have as many Resources folders in your project as you want.

Inspect each actor in the Dialogue Editor. Add a custom field named AudioClip, and set its value to the name of the audio clip:

Image

The field name "AudioClip" is arbitrary; it's just what I chose to use in the script.

Add the script above (named SetTypewriterForActor.cs) to the subtitle text GameObject. Also add an Audio Source so you can configure it exactly the way you want it to sound (e.g., volume, etc.). Assign them both to the typewriter effect as shown below:

Image

When the typewriter effect begins, it will run SetTypewriterForActor's OnBeginTypewriter method. This method looks up the current speaker's AudioClip field and assigns the corresponding audio clip to the typewriter.
farazk86
Posts: 26
Joined: Sun Feb 26, 2023 9:13 am

Re: [HOWTO] How To: Vary Character Mumble Speak With Typewriter Effect

Post by farazk86 »

Thanks a lot Tony,

This is exactly what I was looking for, but the sound does not loop properly for me when using my own typewriter sound effects.

I am using the dialogue sound pack from here: https://alan-dalcastagne.itch.io/dialog ... nd-effects

On the same page, the author also has a video demonstrating each sound.

But when I use the sounds with Dialogue System for Unity and following the howto outlined above, they dont sound right, its just repetitive., not at all like the demo. As can be seen from the below video:



I also tried checking the tick box "interrupt audio clip", but that makes it worse.

It works with the sound effect you have added in the demo, long loopable clip, but with the typewriter effect sounds like above it does not.

Can you please advise how I would fix this?

Many thanks
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HOWTO] How To: Vary Character Mumble Speak With Typewriter Effect

Post by Tony Li »

Try assigning one clip to the typewriter effect's Audio Clip field and the rest of the ones that you want to use to the Alternate Audio Clips list. Keep Interrupt Audio Clip, Stop Audio On Silent Character, and Stop Audio On Pause Codes UNticked. You can also add an Audio Source to the subtitle text GameObject. This will let you customize its settings. Otherwise the typewriter effect will add a default Audio Source at runtime.
farazk86
Posts: 26
Joined: Sun Feb 26, 2023 9:13 am

Re: [HOWTO] How To: Vary Character Mumble Speak With Typewriter Effect

Post by farazk86 »

Tony Li wrote: Sun Apr 02, 2023 2:42 pm Try assigning one clip to the typewriter effect's Audio Clip field and the rest of the ones that you want to use to the Alternate Audio Clips list. Keep Interrupt Audio Clip, Stop Audio On Silent Character, and Stop Audio On Pause Codes UNticked. You can also add an Audio Source to the subtitle text GameObject. This will let you customize its settings. Otherwise the typewriter effect will add a default Audio Source at runtime.
Thanks, I did that, but it still sounds the same as the video.

I was using the script given in the HOWTO above and also had the sound clips in resources folder. So by adding them directly to the audio clip field, I assume I wont be using the script.

Here is the way I have setup the typewriter component as advised, but still sounds the same as before:
image_2023-04-02_205723238.png
image_2023-04-02_205723238.png (53.98 KiB) Viewed 1559 times
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HOWTO] How To: Vary Character Mumble Speak With Typewriter Effect

Post by Tony Li »

Try it without the script first, to make sure that a single set of sound effects works in your setup.

Once you get that working, you can add the script back in to assign different sets of sounds for each character.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HOWTO] How To: Vary Character Mumble Speak With Typewriter Effect

Post by Tony Li »

Here's an example scene using some of the mumble sounds:

DS_MumbleExample_2023-04-02.unitypackage

I didn't use the script. The purpose of the scene is to demonstrate working mumble speak. It'll work the same regardless of which sounds you assign (e.g., via script).
farazk86
Posts: 26
Joined: Sun Feb 26, 2023 9:13 am

Re: [HOWTO] How To: Vary Character Mumble Speak With Typewriter Effect

Post by farazk86 »

Many thanks.

That seems to work for the voices, but I'm not using the voices. I am using the typewriter sound or the pen stroke sound.

But I wanted to report, that what seems to work for me and have the sound similar to a scrolling text sound without sounding like a looping audio clip, I added the pen_v3 sound or the typewriter sound. And then enabled "Stop audio on silent characters" and then added a single space in the silent character field.

This is not ideal, but does sound like scrolling text without a clear repetitive audio clip.

So Im gonna stick with this I guess.

P.S. Can you please mention from where you got the Adam mumble sound in your demo or did you create it yourself?

Thank you
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HOWTO] How To: Vary Character Mumble Speak With Typewriter Effect

Post by Tony Li »

Hi,

Got it. Yes, that sounds more like an audio design thing than something specific to the typewriter effect.

Regarding the Adam and Barb sounds, I don't remember exactly. I'm pretty sure I just recorded myself in Audacity and put applied some effects.
danosono
Posts: 16
Joined: Sun Jun 21, 2020 7:17 pm

Re: [HOWTO] How To: Vary Character Mumble Speak With Typewriter Effect

Post by danosono »

SIDE NOTE:
The latest version of Audacity (for Windows) makes everything sound noticeably better out of the box. I recently upgraded from a super old version though.
Jesus is the answer to every problem.
https://www.gotquestions.org/know-Jesus.html
https://store.steampowered.com/app/2151420/Word/ Longest typing game on Steam OO
Post Reply