From bae3a11d405e4a077dcfd7e62a403dbfdc949ac5 Mon Sep 17 00:00:00 2001 From: Stephen Hodgson Date: Mon, 13 Mar 2023 01:16:07 -0400 Subject: [PATCH] ElevenLabs-DotNet 1.0.3 (#6) - Updated `DownloadHistoryItemsAsync` to download all items if no ids are specified - Updated docs --- ElevenLabs-DotNet/ElevenLabs-DotNet.csproj | 9 +- ElevenLabs-DotNet/History/HistoryEndpoint.cs | 13 +- README.md | 165 ++++++++++++++++++- 3 files changed, 174 insertions(+), 13 deletions(-) diff --git a/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj b/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj index 299860f..74216cf 100644 --- a/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj +++ b/ElevenLabs-DotNet/ElevenLabs-DotNet.csproj @@ -13,15 +13,18 @@ Stephen Hodgson ElevenLabs-DotNet RageAgainstThePixel - 1.0.2 + 1.0.3 2023 ElevenLabs, AI, ML, Voice, TTS - Release 1.0.2 + Release 1.0.3 +- Updated DownloadHistoryItemsAsync to download all items if no ids are specified +- Updated docs +Release 1.0.2 - Added VoiceGenerationEndpoint - Added unit tests for voice design and instant voice cloning - Updated docs Release 1.0.1 -- Updated Docs +- Updated docs Release 1.0.0 - Initial Release! LICENSE diff --git a/ElevenLabs-DotNet/History/HistoryEndpoint.cs b/ElevenLabs-DotNet/History/HistoryEndpoint.cs index ab812f1..1e84b0c 100644 --- a/ElevenLabs-DotNet/History/HistoryEndpoint.cs +++ b/ElevenLabs-DotNet/History/HistoryEndpoint.cs @@ -103,19 +103,18 @@ public async Task DeleteHistoryItemAsync(string historyId, CancellationTok } /// - /// Download one or more history items. If one history item ID is provided, we will return a single audio file. - /// If more than one history item IDs are provided multiple audio files will be downloaded. + /// Download one or more history items.
+ /// If no ids are specified, then all history items are downloaded.
+ /// If one history item id is provided, we will return a single audio file.
+ /// If more than one history item ids are provided multiple audio files will be downloaded. ///
/// One or more history item ids queued for download. /// Optional, The directory path to save the history in. /// Optional, . /// A path to the downloaded zip file, or audio file. - public async Task> DownloadHistoryItemsAsync(List historyItemIds, string saveDirectory = null, CancellationToken cancellationToken = default) + public async Task> DownloadHistoryItemsAsync(List historyItemIds = null, string saveDirectory = null, CancellationToken cancellationToken = default) { - if (historyItemIds is not { Count: not 0 }) - { - throw new ArgumentOutOfRangeException(nameof(historyItemIds)); - } + historyItemIds ??= (await GetHistoryAsync(cancellationToken)).Select(item => item.Id).ToList(); var audioClips = new List(); diff --git a/README.md b/README.md index 33e551a..8b2b510 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,24 @@ Install-Package ElevenLabs-DotNet - [Text to Speech](#text-to-speech) - [Voices](#voices) + - [Get All Voices](#get-all-voices) + - [Get Default Voice Settings](#get-default-voice-settings) + - [Get Voice](#get-voice) + - [Edit Voice Settings](#edit-voice-settings) + - [Add Voice](#add-voice) + - [Edit Voice](#edit-voice) + - [Delete Voice](#delete-voice) - [Samples](#samples) + - [Get Voice Sample](#get-voice-sample) + - [Delete Voice Sample](#delete-voice-sample) - [History](#history) + - [Get History](#get-history) + - [Get History Audio](#get-history-audio) + - [Download All History](#download-all-history) + - [Delete History Item](#delete-history-item) - [User](#user) + - [Get User Info](#get-user-info) + - [Get Subscription Info](#get-subscription-info) ### [Text to Speech](https://api.elevenlabs.io/docs#/text-to-speech) @@ -45,22 +60,166 @@ var api = new ElevenLabsClient(); var text = "The quick brown fox jumps over the lazy dog."; var voice = (await api.VoicesEndpoint.GetAllVoicesAsync()).FirstOrDefault(); var defaultVoiceSettings = await api.VoicesEndpoint.GetDefaultVoiceSettingsAsync(); -var (clipPath, audioClip) = await api.TextToSpeechEndpoint.TextToSpeechAsync(text, voice, defaultVoiceSettings); -Debug.Log(clipPath); +var clipPath = await api.TextToSpeechEndpoint.TextToSpeechAsync(text, voice, defaultVoiceSettings); +Console.WriteLine(clipPath); ``` ### [Voices](https://api.elevenlabs.io/docs#/voices) -Access to voices created either by the user or eleven labs. +Access to voices created either by the user or ElevenLabs. + +#### Get All Voices + +Gets a list of all available voices. + +```csharp +var api = new ElevenLabsClient(); +var allVoices = await api.VoicesEndpoint.GetAllVoicesAsync(); + +foreach (var voice in allVoices) +{ + Console.WriteLine($"{voice.Id} | {voice.Name} | similarity boost: {voice.Settings?.SimilarityBoost} | stability: {voice.Settings?.Stability}"); +} +``` + +#### Get Default Voice Settings + +Gets the global default voice settings. + +```csharp +var api = new ElevenLabsClient(); +var result = await api.VoicesEndpoint.GetDefaultVoiceSettingsAsync(); +Console.WriteLine($"stability: {result.Stability} | similarity boost: {result.SimilarityBoost}"); +``` + +#### Get Voice + +```csharp +var api = new ElevenLabsClient(); +var voice = await api.VoicesEndpoint.GetVoiceAsync("voiceId"); +Console.WriteLine($"{voice.Id} | {voice.Name} | {voice.PreviewUrl}"); +``` + +#### Edit Voice Settings + +Edit the settings for a specific voice. + +```csharp +var api = new ElevenLabsClient(); +var success = await api.VoicesEndpoint.EditVoiceSettingsAsync(voice, new VoiceSettings(0.7f, 0.7f)); +Console.WriteLine($"Was successful? {success}"); +``` + +#### Add Voice + +```csharp +var api = new ElevenLabsClient(); +var labels = new Dictionary +{ + { "accent", "american" } +}; +var audioSamplePaths = new List(); +var voice = await api.VoicesEndpoint.AddVoiceAsync("Voice Name", audioSamplePaths, labels); +``` + +#### Edit Voice + +```csharp +var api = new ElevenLabsClient(); +var labels = new Dictionary +{ + { "age", "young" } +}; +var audioSamplePaths = new List(); +var success = await api.VoicesEndpoint.EditVoiceAsync(voice, audioSamplePaths, labels); +Console.WriteLine($"Was successful? {success}"); +``` + +#### Delete Voice + +```csharp +var api = new ElevenLabsClient(); +var success = await api.VoicesEndpoint.DeleteVoiceAsync(voiceId); +Console.WriteLine($"Was successful? {success}"); +``` #### [Samples](https://api.elevenlabs.io/docs#/samples) Access to your samples, created by you when cloning voices. +##### Get Voice Sample + +```csharp +var api = new ElevenLabsClient(); +var clipPath = await api.VoicesEndpoint.GetVoiceSampleAsync(voiceId, sampleId); +Console.WriteLine(clipPath); +``` + +##### Delete Voice Sample + +```csharp +var api = new ElevenLabsClient(); +var success = await api.VoicesEndpoint.DeleteVoiceSampleAsync(voiceId, sampleId); +Console.WriteLine($"Was successful? {success}"); +``` + ### [History](https://api.elevenlabs.io/docs#/history) Access to your previously synthesized audio clips including its metadata. +#### Get History + +```csharp +var api = new ElevenLabsClient(); +var historyItems = await api.HistoryEndpoint.GetHistoryAsync(); + +foreach (var historyItem in historyItems.OrderBy(historyItem => historyItem.Date)) +{ + Console.WriteLine($"{historyItem.State} {historyItem.Date} | {historyItem.Id} | {historyItem.Text.Length} | {historyItem.Text}"); +} +``` + +#### Get History Audio + +```csharp +var api = new ElevenLabsClient(); +var clipPath = await api.HistoryEndpoint.GetHistoryAudioAsync(historyItem); +Console.WriteLine(clipPath); +``` + +#### Download All History + +```csharp +var api = new ElevenLabsClient(); +var success = await api.HistoryEndpoint.DownloadHistoryItemsAsync(); +``` + +#### Delete History Item + +```csharp +var api = new ElevenLabsClient(); +var result = await api.HistoryEndpoint.DeleteHistoryItemAsync(historyItem); +Console.WriteLine($"Was successful? {success}"); +``` + ### [User](https://api.elevenlabs.io/docs#/user) Access to your user Information and subscription status. + +#### Get User Info + +Gets information about your user account with ElevenLabs. + +```csharp +var api = new ElevenLabsClient(); +var userInfo = await api.UserEndpoint.GetUserInfoAsync(); +``` + +#### Get Subscription Info + +Gets information about your subscription with ElevenLabs. + +```csharp +var api = new ElevenLabsClient(); +var subscriptionInfo = await api.UserEndpoint.GetSubscriptionInfoAsync(); +```