Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dubbing access #48

Closed
Binary file not shown.
27 changes: 27 additions & 0 deletions ElevenLabs-DotNet-Tests/Assets/online.dubbed.ja.srt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
1
00:00:00,000 --> 00:00:04,086
イレブンラボは象徴的なボイスコレクションを紹介します。

2
00:00:04,051 --> 00:00:10,553
有名なAIボイスの中から、あの有名なJudy
Garlandを含む、私たちの独占的なセレクションから選んでください。

3
00:00:10,560 --> 00:00:19,291

お気に入りの物語、出版物、アップロードを最も本物に近い方法で読めるようにします。オズの魔法使い含む。

4
00:00:19,781 --> 00:00:25,797

その瞬間、ドロシーはテーブルの上に東の魔女のものだった銀の靴が置かれているのを見ました。だから今日、Eleven

5
00:00:25,797 --> 00:00:28,697
Labs Readerアプリをダウンロードしましょう。

6
00:00:28,683 --> 00:00:32,166
お気に入りの声で、お気に入りの物語を。

Binary file not shown.
56 changes: 56 additions & 0 deletions ElevenLabs-DotNet-Tests/Assets/test_sample_01.ogg.dubbed.es.srt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
1
00:00:00,000 --> 00:00:01,625
Lorem Ipsum.

2
00:00:01,628 --> 00:00:05,664
¿Qué es lorem ipsum preguntas? Bueno,
lorem ipsum es simplemente texto de

3
00:00:05,664 --> 00:00:09,476
relleno de la industria de la impresión y
la composición tipográfica.

4
00:00:09,481 --> 00:00:14,510
Lorem ipsum ha sido el texto de relleno
estándar de la industria desde el siglo

5
00:00:14,510 --> 00:00:19,280
XVI cuando un impresor desconocido tomó
un conjunto de tipos y lo revuelto.

6
00:00:19,250 --> 00:00:21,387
para hacer un libro de muestras de tipos.

7
00:00:21,357 --> 00:00:26,466
Ha sobrevivido no solo cinco siglos, sino
también lo menos.

8
00:00:26,465 --> 00:00:29,112
salto a la composición económica.

9
00:00:29,083 --> 00:00:34,692
permaneciendo esencialmente sin cambios.
Se popularizó en la década de 1960 con el

10
00:00:34,692 --> 00:00:36,699
lanzamiento de hojas LORISET.

11
00:00:36,681 --> 00:00:42,267
contiene pasajes de lorem ipsum, y más
recientemente, el software de autoedición

12
00:00:42,267 --> 00:00:46,155
de Algis Pagemaker, incluyendo versiones
de lorem ipsum.

97 changes: 97 additions & 0 deletions ElevenLabs-DotNet-Tests/Test_Fixture_07_DubbingEndpoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Licensed under the MIT License. See LICENSE in the project root for license information.
namespace ElevenLabs.Tests;

using ElevenLabs.Dubbing;
using NUnit.Framework;
using System;
using System.IO;
using System.Threading.Tasks;

internal class Test_Fixture_07_DubbingEndpoint : AbstractTestFixture
{
[Test]
public async Task Test_01_Dubbing_File()
{
Assert.NotNull(ElevenLabsClient.DubbingEndpoint);

(string FilePath, string MediaType) audio = (Path.GetFullPath("../../../Assets/test_sample_01.ogg"), "audio/mpeg");
DubbingRequest request = new()
{
File = audio,
SourceLanguage = "en",
TargetLanguage = "es",
NumSpeakers = 1,
Watermark = false,
};

DubbingResponse response = await ElevenLabsClient.DubbingEndpoint.StartDubbingAsync(request);
Assert.IsFalse(string.IsNullOrEmpty(response.DubbingId));
Assert.IsTrue(response.ExpectedDurationSeconds > 0);
Console.WriteLine($"Expected Duration: {response.ExpectedDurationSeconds:0.00} seconds");

Assert.IsTrue(await ElevenLabsClient.DubbingEndpoint.WaitForDubbingCompletionAsync(response.DubbingId, progress: new Progress<string>(msg => Console.WriteLine(msg))));

FileInfo srcFile = new(audio.FilePath);
FileInfo dubbedPath = new($"{srcFile.FullName}.dubbed.{request.TargetLanguage}{srcFile.Extension}");
{
await using FileStream fs = File.Open(dubbedPath.FullName, FileMode.Create);
await foreach (byte[] chunk in ElevenLabsClient.DubbingEndpoint.GetDubbedFileAsync(response.DubbingId, request.TargetLanguage))
{
await fs.WriteAsync(chunk);
}
}
Assert.IsTrue(dubbedPath.Exists);
Assert.IsTrue(dubbedPath.Length > 0);

FileInfo transcriptPath = new($"{srcFile.FullName}.dubbed.{request.TargetLanguage}.srt");
{
string transcriptFile = await ElevenLabsClient.DubbingEndpoint.GetTranscriptForDubAsync(response.DubbingId, request.TargetLanguage, "srt");
await File.WriteAllTextAsync(transcriptPath.FullName, transcriptFile);
}
Assert.IsTrue(transcriptPath.Exists);
Assert.IsTrue(transcriptPath.Length > 0);
}

[Test]
public async Task Test_02_Dubbing_Url()
{
Assert.NotNull(ElevenLabsClient.DubbingEndpoint);

Uri uri = new("https://youtu.be/Zo5-rhYOlNk");
DubbingRequest request = new()
{
SourceUrl = uri.AbsoluteUri,
SourceLanguage = "en",
TargetLanguage = "ja",
NumSpeakers = 1,
Watermark = true,
};

DubbingResponse response = await ElevenLabsClient.DubbingEndpoint.StartDubbingAsync(request);
Assert.IsFalse(string.IsNullOrEmpty(response.DubbingId));
Assert.IsTrue(response.ExpectedDurationSeconds > 0);
Console.WriteLine($"Expected Duration: {response.ExpectedDurationSeconds:0.00} seconds");

Assert.IsTrue(await ElevenLabsClient.DubbingEndpoint.WaitForDubbingCompletionAsync(response.DubbingId, progress: new Progress<string>(msg => Console.WriteLine(msg))));

string assetsDir = Path.GetFullPath("../../../Assets");
FileInfo dubbedPath = new(Path.Combine(assetsDir, $"online.dubbed.{request.TargetLanguage}.mp4"));
{
await using FileStream fs = File.Open(dubbedPath.FullName, FileMode.Create);
await foreach (byte[] chunk in ElevenLabsClient.DubbingEndpoint.GetDubbedFileAsync(response.DubbingId, request.TargetLanguage))
{
await fs.WriteAsync(chunk);
}
}
Assert.IsTrue(dubbedPath.Exists);
Assert.IsTrue(dubbedPath.Length > 0);

FileInfo transcriptPath = new(Path.Combine(assetsDir, $"online.dubbed.{request.TargetLanguage}.srt"));
{
string transcriptFile = await ElevenLabsClient.DubbingEndpoint.GetTranscriptForDubAsync(response.DubbingId, request.TargetLanguage, "srt");
await File.WriteAllTextAsync(transcriptPath.FullName, transcriptFile);
}
Assert.IsTrue(transcriptPath.Exists);
Assert.IsTrue(transcriptPath.Length > 0);
}
}
Loading
Loading