Application freezes on first voice request #67
-
I think this is more of a question than a bug but we're seeing large spikes when processing text. We're using the latest version of the SDK & Unity 2021.3.21f1. Pretty much all requests we make after the first one are absolutely fine but the first one freezes the application for a second or two. I've taken a look at the samples but it has the same results. Below is the code we've been using for a while. public void ExecuteTask(string answer)
{
if (_isReady)
Execute(answer);
}
private async void Execute(string answer)
{
_isReady = false;
var api = new ElevenLabsClient();
var voice = await api.VoicesEndpoint.GetVoiceAsync(voiceData.DefaultVoice.ID);
var voiceClip = await api.TextToSpeechEndpoint.TextToSpeechAsync(answer, voice, model: Model.EnglishTurboV2);
if (_audioSource.isPlaying)
{
_audioSource.Stop();
}
onAudioProcessed?.Invoke();
_audioSource.clip = voiceClip.AudioClip;
_audioSource.Play();
StartCoroutine(CheckAudio());
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
the freeze you're likely seeing is the voice clip being loaded into memory. you might see better performance with the streaming endpoint. |
Beta Was this translation helpful? Give feedback.
-
By the way you can await this coroutine:
|
Beta Was this translation helpful? Give feedback.
-
Duplicate of #69 |
Beta Was this translation helpful? Give feedback.
See API proxy instructions.
And to get around the performance impact create the auth and settings objects before constructing your client.