From 7ea80dae82b065eafc505829fcea7de3b56dff75 Mon Sep 17 00:00:00 2001 From: IS4 Date: Thu, 15 Feb 2024 18:24:40 +0100 Subject: [PATCH 1/3] ElevenLabs-DotNet 2.1.1 (#34) - Added VoicesEndpoint.GetAllVoicesAsync overload that allows skipping downloading the voice settings --- ElevenLabs-DotNet/ElevenLabs-DotNet.csproj | 4 ++- ElevenLabs-DotNet/Voices/VoicesEndpoint.cs | 30 +++++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj b/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj index a22cdd6..cc0e2dc 100644 --- a/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj +++ b/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj @@ -15,7 +15,9 @@ 2023 ElevenLabs, AI, ML, Voice, TTS 2.1.0 - Version 2.1.0 + Version 2.1.1 +- Added VoicesEndpoint.GetAllVoicesAsync overload that allows skipping downloading the voice settings +Version 2.1.0 - Added ElevenLabsClient.EnableDebug option to enable and disable for all endpoints - Synced changes from unity package - Updated unit test diff --git a/ElevenLabs-DotNet/Voices/VoicesEndpoint.cs b/ElevenLabs-DotNet/Voices/VoicesEndpoint.cs index d4134ff..cdbeaad 100644 --- a/ElevenLabs-DotNet/Voices/VoicesEndpoint.cs +++ b/ElevenLabs-DotNet/Voices/VoicesEndpoint.cs @@ -36,29 +36,45 @@ public VoicesEndpoint(ElevenLabsClient client) : base(client) { } protected override string Root => "voices"; + /// + /// Gets a list of all available voices for a user, and downloads all their settings. + /// + /// + /// of s. + public Task> GetAllVoicesAsync(CancellationToken cancellationToken = default) + { + return GetAllVoicesAsync(true, cancellationToken); + } + /// /// Gets a list of all available voices for a user. /// + /// Whether to download all settings for the voices. /// /// of s. - public async Task> GetAllVoicesAsync(CancellationToken cancellationToken = default) + public async Task> GetAllVoicesAsync(bool downloadSettings, CancellationToken cancellationToken = default) { var response = await client.Client.GetAsync(GetUrl(), cancellationToken).ConfigureAwait(false); var responseAsString = await response.ReadAsStringAsync(EnableDebug, cancellationToken).ConfigureAwait(false); var voices = JsonSerializer.Deserialize(responseAsString, ElevenLabsClient.JsonSerializationOptions).Voices; - var voiceSettingsTasks = new List(); - foreach (var voice in voices) + if (downloadSettings) { - voiceSettingsTasks.Add(Task.Run(LocalGetVoiceSettings, cancellationToken)); + var voiceSettingsTasks = new List(); - async Task LocalGetVoiceSettings() + foreach (var voice in voices) { - voice.Settings = await GetVoiceSettingsAsync(voice, cancellationToken).ConfigureAwait(false); + voiceSettingsTasks.Add(Task.Run(LocalGetVoiceSettingsAsync, cancellationToken)); + + async Task LocalGetVoiceSettingsAsync() + { + voice.Settings = await GetVoiceSettingsAsync(voice, cancellationToken).ConfigureAwait(false); + } } + + await Task.WhenAll(voiceSettingsTasks).ConfigureAwait(false); } - await Task.WhenAll(voiceSettingsTasks).ConfigureAwait(false); return voices.ToList(); } From 0036cd33a3cc02a82d3a67b99cdda577f7bccddf Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Thu, 15 Feb 2024 13:20:15 -0500 Subject: [PATCH 2/3] bump version --- ElevenLabs-DotNet/ElevenLabs-DotNet.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj b/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj index cc0e2dc..831b40f 100644 --- a/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj +++ b/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj @@ -14,7 +14,7 @@ RageAgainstThePixel 2023 ElevenLabs, AI, ML, Voice, TTS - 2.1.0 + 2.1.1 Version 2.1.1 - Added VoicesEndpoint.GetAllVoicesAsync overload that allows skipping downloading the voice settings Version 2.1.0 From dd1a3e58babfba810bf21ef9a3e946cd8924b2ec Mon Sep 17 00:00:00 2001 From: Alizer <86959368+AlizerUncaged@users.noreply.github.com> Date: Fri, 16 Feb 2024 02:25:02 +0800 Subject: [PATCH 3/3] fix code in readme (#33) typo in readme, ``TextToSpeechAsync`` is not being completely qualified in the path which causes confusion Co-authored-by: Stephen Hodgson --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ef2ffb..f70299e 100644 --- a/README.md +++ b/README.md @@ -197,7 +197,7 @@ var text = "The quick brown fox jumps over the lazy dog."; var voice = (await api.VoicesEndpoint.GetAllVoicesAsync()).FirstOrDefault(); string fileName = "myfile.mp3"; using var outputFileStream = File.OpenWrite(fileName); -var voiceClip = await TextToSpeechAsync(text, voice, +var voiceClip = await api.TextToSpeechEndpoint.TextToSpeechAsync(text, voice, partialClipCallback: async (partialClip) => { // Write the incoming data to the output file stream.