diff --git a/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj b/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj
index a22cdd6..831b40f 100644
--- a/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj
+++ b/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj
@@ -14,8 +14,10 @@
RageAgainstThePixel
2023
ElevenLabs, AI, ML, Voice, TTS
- 2.1.0
- Version 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
- 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();
}
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.