How to make dialogue system with voice

Hello I’m a beginner in unity and I’m trying to make a dialogue system, taking base from the brackeys system, however, I wanted to be able to have an audio play at the same time the text is displayed and to play the next line when you change the text, I tried to do something basically creating a system of a string that changes the name every time you change the text(it’s basically the same as the normal system) and then at the end implement the audioManager.play(String); visual studios gives no errors however when I go into the game no audio is played. I will send my dialogue scripts down below (if you know about the brackeys system I have 3 scripts so I don’t really know which one may be causing the problem)

DialogueManager Script:

public class DialogueManager : MonoBehaviour
{
    public Door1Animation doorAnimation;

    public Text nameText;
    public Text dialogueText;
    public Text changeText;

    public AudioManager Sound;

    public Animator textBoxAnimation;

    public Queue<string> sentences;

    public Queue<string> voiceLines;

    void Start()
    {
        sentences = new Queue<string>();
        voiceLines = new Queue<string>();
    }

    public void StartDialogue (Dialogue dialogue)
    {
        textBoxAnimation.SetBool("Open", true);
        
        changeText.text = ("Aperte R para continuar");

        nameText.text = dialogue.name;

        sentences.Clear();

        voiceLines.Clear();



        foreach (string sentence in dialogue.sentences)
        {
            sentences.Enqueue(sentence);
        }

        DisplayNextSentence();

        foreach (string voiceLine in dialogue.voiceLines)
        {
            voiceLines.Enqueue(voiceLine);
        }

        PlayNextLine();

    }

    public void DisplayNextSentence()
    {
        if (sentences.Count == 1)
        {
            changeText.text = ("Aperte R para fechar");
        }

        if (sentences.Count == 0)
        {
            EndDialogue();
            return;
        }

        string sentence = sentences.Dequeue();
        dialogueText.text = sentence;
    }

    public void PlayNextLine()
    {
        string voiceLine = voiceLines.Dequeue();
        Sound.Play(voiceLine);
    }

    public void EndDialogue()
    {
        Debug.Log("End of conversation");
        doorAnimation.openDoor = true;
        textBoxAnimation.SetBool("Open", false);
    }
}

Dialogue Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

[System.Serializable]
public class Dialogue
{
public string name;

public Sprite Face;

[TextArea(3, 10)]
public string[] sentences;

public string[] voiceLines;

}

DialogueTrigger Script;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DialogueTrigger : MonoBehaviour
{
public Dialogue dialogue;

public Image faceChange;

public void TriggerDialogue()
{
    faceChange.sprite = dialogue.Face;

    Debug.Log("Talk");
    FindObjectOfType<DialogueManager>().StartDialogue(dialogue); 
}

}

If you’re looking for a node editor that integrates C# scripting I suggest Speech#. It also has audio files built into it’s localization system.

In my experience, it saved me a ton of time just buying a Dialogue asset off the asset store. The more time I spend developing, the more I find that for a lot of things that aren’t custom to your game (dialogue systems, save systems, audio systems), simply buying an asset is better than spending days implementing it, then even more maintaining it.