Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error getting AudioClip after TextToSpeechAsync request #111

Open
maxivallejos opened this issue Dec 2, 2024 · 1 comment
Open

Error getting AudioClip after TextToSpeechAsync request #111

maxivallejos opened this issue Dec 2, 2024 · 1 comment
Assignees
Labels

Comments

@maxivallejos
Copy link

maxivallejos commented Dec 2, 2024

@maxivallejos did you try loading it like it suggested on line 78?

Originally posted by @StephenHodgson in #110

I think there is a typo in the GeneratedClip.cs file
You have 2 ReadOnlyMemory

  • audioData
  • ClipData

Only ClipData is initialized in the constructor but then this code try to read audioData an is always empty.

public AudioClip AudioClip
{
    get
    {
        if (audioClip == null && !audioData.IsEmpty)
        {
            var pcmData = PCMEncoder.Decode(audioData.ToArray());
            audioClip = AudioClip.Create(Id, pcmData.Length, 1, SampleRate, false);
            audioClip.SetData(pcmData, 0);
        }

        if (audioClip == null)
        {
            Debug.LogError($"{nameof(audioClip)} is null, try loading it with LoadCachedAudioClipAsync");
        }

        return audioClip;
    }
}

I think it should be

if (audioClip == null && !ClipData.IsEmpty)
{
    var pcmData = PCMEncoder.Decode(ClipData.ToArray());
    audioClip = AudioClip.Create(Id, pcmData.Length, 1, SampleRate, false);
    audioClip.SetData(pcmData, 0);
}
@StephenHodgson
Copy link
Member

I'll take a look

@StephenHodgson StephenHodgson self-assigned this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants