How to play a sound effect for every letter typed out in dialogue?

Right now I have a dialogue system that will print each letter for a dialogue with a frames worth of wait time in between each letter. I want to play a sound effect after each letter is printed out to create a cool dialogue effect. This is how it looks now:

IEnumerator TypeSentence (string sentence)
        dialogueText.text = "";
        foreach(char letter in sentence.ToCharArray())
            dialogueText.text += letter;
            yield return null;

This plays the sound effect put only when all the letters are done being typed. Any suggestions? is there a different way to do this? Thank you!

I think that may be because the sound effect that you are using has a small pause at the beginning of the clip, and when you call Play() it overwrites the currently playing sound on that audio source. (So it is being called multiple times, but you only hear it at the end) I could suggest that you make a loop which checks multiple audio sources to see if they are playing and if they are not, then to play the sound.

However, I think if you just set the Audio Source to loop, then at the first line of the IEnumerator to Play() you may achieve the effect that you are going for. It won’t be perfect, but it will have a typing sound for the duration of the dialogue, then at the end of the coroutine just .Stop();