Skip to content

Commit

Permalink
ElevenLabs-DotNet 1.0.3 (#6)
Browse files Browse the repository at this point in the history
- Updated `DownloadHistoryItemsAsync` to download all items if no ids
are specified
- Updated docs
  • Loading branch information
StephenHodgson authored Mar 13, 2023
1 parent 4d4204f commit bae3a11
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 13 deletions.
9 changes: 6 additions & 3 deletions ElevenLabs-DotNet/ElevenLabs-DotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@
<Authors>Stephen Hodgson</Authors>
<Title>ElevenLabs-DotNet</Title>
<Company>RageAgainstThePixel</Company>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<Copyright>2023</Copyright>
<PackageTags>ElevenLabs, AI, ML, Voice, TTS</PackageTags>
<PackageReleaseNotes>Release 1.0.2
<PackageReleaseNotes>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!</PackageReleaseNotes>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
Expand Down
13 changes: 6 additions & 7 deletions ElevenLabs-DotNet/History/HistoryEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,18 @@ public async Task<bool> DeleteHistoryItemAsync(string historyId, CancellationTok
}

/// <summary>
/// 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.<br/>
/// If no ids are specified, then all history items are downloaded.<br/>
/// If one history item id is provided, we will return a single audio file.<br/>
/// If more than one history item ids are provided multiple audio files will be downloaded.
/// </summary>
/// <param name="historyItemIds">One or more history item ids queued for download.</param>
/// <param name="saveDirectory">Optional, The directory path to save the history in.</param>
/// <param name="cancellationToken">Optional, <see cref="CancellationToken"/>.</param>
/// <returns>A path to the downloaded zip file, or audio file.</returns>
public async Task<IReadOnlyList<string>> DownloadHistoryItemsAsync(List<string> historyItemIds, string saveDirectory = null, CancellationToken cancellationToken = default)
public async Task<IReadOnlyList<string>> DownloadHistoryItemsAsync(List<string> 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<string>();

Expand Down
165 changes: 162 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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<string, string>
{
{ "accent", "american" }
};
var audioSamplePaths = new List<string>();
var voice = await api.VoicesEndpoint.AddVoiceAsync("Voice Name", audioSamplePaths, labels);
```

#### Edit Voice

```csharp
var api = new ElevenLabsClient();
var labels = new Dictionary<string, string>
{
{ "age", "young" }
};
var audioSamplePaths = new List<string>();
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();
```

0 comments on commit bae3a11

Please sign in to comment.