Skip to content

Latest commit

 

History

History
225 lines (164 loc) · 6.51 KB

README.md

File metadata and controls

225 lines (164 loc) · 6.51 KB

ElevenLabs-DotNet

Discord NuGet version (ElevenLabs-DotNet) Nuget Publish

A non-official Eleven Labs voice synthesis RESTful client.

I am not affiliated with Eleven Labs and an account with api access is required.

All copyrights, trademarks, logos, and assets are the property of their respective owners.

Getting started

Install from NuGet

Install package ElevenLabs from Nuget. Here's how via command line:

Install-Package ElevenLabs-DotNet

Looking to use ElevenLabs in the Unity Game Engine? Check out our unity package on OpenUPM:

openupm


Documentation

Table of Contents

Convert text to speech.

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 = await api.TextToSpeechEndpoint.TextToSpeechAsync(text, voice, defaultVoiceSettings);
Console.WriteLine(clipPath);

Access to voices created either by the user or ElevenLabs.

Get All Voices

Gets a list of all available voices.

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.

var api = new ElevenLabsClient();
var result = await api.VoicesEndpoint.GetDefaultVoiceSettingsAsync();
Console.WriteLine($"stability: {result.Stability} | similarity boost: {result.SimilarityBoost}");

Get Voice

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.

var api = new ElevenLabsClient();
var success = await api.VoicesEndpoint.EditVoiceSettingsAsync(voice, new VoiceSettings(0.7f, 0.7f));
Console.WriteLine($"Was successful? {success}");

Add Voice

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

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

var api = new ElevenLabsClient();
var success = await api.VoicesEndpoint.DeleteVoiceAsync(voiceId);
Console.WriteLine($"Was successful? {success}");

Access to your samples, created by you when cloning voices.

Get Voice Sample
var api = new ElevenLabsClient();
var clipPath = await api.VoicesEndpoint.GetVoiceSampleAsync(voiceId, sampleId);
Console.WriteLine(clipPath);
Delete Voice Sample
var api = new ElevenLabsClient();
var success = await api.VoicesEndpoint.DeleteVoiceSampleAsync(voiceId, sampleId);
Console.WriteLine($"Was successful? {success}");

Access to your previously synthesized audio clips including its metadata.

Get History

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

var api = new ElevenLabsClient();
var clipPath = await api.HistoryEndpoint.GetHistoryAudioAsync(historyItem);
Console.WriteLine(clipPath);

Download All History

var api = new ElevenLabsClient();
var success = await api.HistoryEndpoint.DownloadHistoryItemsAsync();

Delete History Item

var api = new ElevenLabsClient();
var result = await api.HistoryEndpoint.DeleteHistoryItemAsync(historyItem);
Console.WriteLine($"Was successful? {success}");

Access to your user Information and subscription status.

Get User Info

Gets information about your user account with ElevenLabs.

var api = new ElevenLabsClient();
var userInfo = await api.UserEndpoint.GetUserInfoAsync();

Get Subscription Info

Gets information about your subscription with ElevenLabs.

var api = new ElevenLabsClient();
var subscriptionInfo = await api.UserEndpoint.GetSubscriptionInfoAsync();