Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Unity 2020.3.25f1, creating audioclip seems to freeze code

Discussion in 'Scripting' started by JelleBelly, Jan 12, 2022.

  1. JelleBelly

    JelleBelly

    Joined:
    Sep 26, 2021
    Posts:
    7
    I'm currently working on a VR project in Unity 2020.3.25f1, which is the latest LTS version at the moment. My project is about virtual humans that you can speak to. You speak into your microphone and speaking of the human is done by Azure TTS: An in-memory stream is generated, transformed into a Unity audioclip and played onto a Unity audiosource. Whenever I try to create the audioclip, the code seems to stop executing further without any errors in the console.
    For further context, even if I just make a general audioclip in the function (commenting everything else), the code doesn't execute after the creation of the audioclip. To show this, the code is pasted below, with the output of the Unity console.

    This code is executed when the user speaks into the microphone and an utterance is detected.

    Code (CSharp):
    1.     public async Task GenerateAnswerAsync(string input)
    2.     {
    3.         Debug.LogFormat("generating answer... ");
    4.         await speechGenerator.Talk("testing 1 2 3");
    5.         Debug.LogFormat("generated answer");
    6.     }
    This is the testing code in speechGenerator for creating the audioclip.

    Code (CSharp):
    1.     Task Talk(string response)
    2.     {
    3.         UnityEngine.Debug.LogFormat("before creating audioclip");
    4.         AudioClip audioClip = AudioClip.Create("test", 32000, 1, 16000, false);
    5.         UnityEngine.Debug.LogFormat("created audioclip");
    6.     }
    As seen in the console output, the code never reaches the creation of the audioclip. This doesn't happen if I create the audioclip in the Start method for example.



    Does somebody know what the issue might be?
     
    Last edited: Jan 12, 2022
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,947
  3. JelleBelly

    JelleBelly

    Joined:
    Sep 26, 2021
    Posts:
    7
    Thank you!
    This was indeed the problem.
     
    Kurt-Dekker likes this.