-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added ModelsEndpoint - Updated TextToSpeech.TextToSpeechAsync with optional Model parameter. Defaults to eleven_monolingual_v1 - Added default voices
- Loading branch information
1 parent
57cd367
commit 5f7f729
Showing
9 changed files
with
190 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using NUnit.Framework; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace ElevenLabs.Tests | ||
{ | ||
internal class Test_Fixture_06_Models : AbstractTestFixture | ||
{ | ||
[Test] | ||
public async Task Test_01_GetModels() | ||
{ | ||
Assert.NotNull(ElevenLabsClient.ModelsEndpoint); | ||
var models = await ElevenLabsClient.ModelsEndpoint.GetModelsAsync(); | ||
Assert.NotNull(models); | ||
Assert.IsNotEmpty(models); | ||
|
||
foreach (var model in models) | ||
{ | ||
Console.WriteLine($"{model.Id} | {model.Name} | {model.Description}"); | ||
|
||
foreach (var language in model.Languages) | ||
{ | ||
Console.WriteLine($" {language.Id} | {language.Name}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using System.Text.Json.Serialization; | ||
|
||
namespace ElevenLabs.Models | ||
{ | ||
public sealed class Language | ||
{ | ||
[JsonInclude] | ||
[JsonPropertyName("language_id")] | ||
public string Id { get; private set; } | ||
|
||
[JsonInclude] | ||
[JsonPropertyName("name")] | ||
public string Name { get; private set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ElevenLabs.Models | ||
{ | ||
public sealed class Model | ||
{ | ||
public Model(string id) | ||
{ | ||
Id = id; | ||
} | ||
|
||
[JsonInclude] | ||
[JsonPropertyName("model_id")] | ||
public string Id { get; private set; } | ||
|
||
[JsonInclude] | ||
[JsonPropertyName("name")] | ||
public string Name { get; private set; } | ||
|
||
[JsonInclude] | ||
[JsonPropertyName("can_be_finetuned")] | ||
public bool CanBeFineTuned { get; private set; } | ||
|
||
[JsonInclude] | ||
[JsonPropertyName("can_do_text_to_speech")] | ||
public bool CanDoTextToSpeech { get; private set; } | ||
|
||
[JsonInclude] | ||
[JsonPropertyName("can_do_voice_conversion")] | ||
public bool CanDoVoiceConversion { get; private set; } | ||
|
||
[JsonInclude] | ||
[JsonPropertyName("token_cost_factor")] | ||
public double TokenCostFactor { get; private set; } | ||
|
||
[JsonInclude] | ||
[JsonPropertyName("description")] | ||
public string Description { get; private set; } | ||
|
||
[JsonInclude] | ||
[JsonPropertyName("languages")] | ||
public IReadOnlyList<Language> Languages { get; private set; } | ||
|
||
public static implicit operator string(Model model) => model.ToString(); | ||
|
||
public override string ToString() => Id; | ||
|
||
#region Predefined Models | ||
|
||
[JsonIgnore] | ||
public static Model MonoLingualV1 { get; } = new Model("eleven_monolingual_v1"); | ||
|
||
[JsonIgnore] | ||
public static Model MultiLingualV1 { get; } = new Model("eleven_multilingual_v1"); | ||
|
||
#endregion Predefined Models | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using ElevenLabs.Extensions; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
|
||
namespace ElevenLabs.Models | ||
{ | ||
public sealed class ModelsEndpoint : BaseEndPoint | ||
{ | ||
public ModelsEndpoint(ElevenLabsClient api) : base(api) { } | ||
|
||
protected override string Root => "models"; | ||
|
||
/// <summary> | ||
/// Access the different models available to the platform. | ||
/// </summary> | ||
/// <returns>A list of <see cref="Model"/>s you can use.</returns> | ||
public async Task<IReadOnlyList<Model>> GetModelsAsync() | ||
{ | ||
var response = await Api.Client.GetAsync(GetUrl()); | ||
var responseAsString = await response.ReadAsStringAsync(); | ||
return JsonSerializer.Deserialize<IReadOnlyList<Model>>(responseAsString, Api.JsonSerializationOptions); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters