Skip to content

fysh711426/EdgeTTS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EdgeTTS

This repo is C# implementation of edge-tts.

EdgeTTS allows you to use Microsoft Edge's online text-to-speech service from C#.


Nuget install

PM> Install-Package EdgeTTS

Example

var OUTPUT_FILE = "hello.mp3";
var communicate = new Communicate(
    "hello world", "zh-CN-YunxiNeural");
await communicate.Save(OUTPUT_FILE);

Stream example

var communicate = new Communicate(TEXT, "zh-CN-YunxiNeural");

using (var stream = File.Create(OUTPUT_FILE))
{
    await communicate.Stream((result) =>
    {
        if (result.Type == "audio")
            result.Data?.CopyTo(stream);

        if (result.Type == "WordBoundary")
            Console.WriteLine(JsonConvert.SerializeObject(result));
    });
}

VoicesManager example

// List voices
var list = await VoicesManager.ListVoices();

// Finds all matching voices
var manager = await VoicesManager.Create();
var voices = manager.Find(gender: "Male", language: "es");

// Also supports Locales
// var voices = manager.Find(gender: "Female", locale: "es-AR");

var communicate = new Communicate(TEXT, voices[0].Name);
await communicate.Save(OUTPUT_FILE);

SubMaker example

var submaker = new SubMaker();
var communicate = new Communicate(TEXT, "zh-CN-YunxiNeural");

using (var stream = File.Create(OUTPUT_FILE))
{
    await communicate.Stream((result) =>
    {
        if (result.Type == "audio")
            result.Data?.CopyTo(stream);

        if (result.Type == "WordBoundary")
            submaker.CreateSub(
                (result.Offset, result.Duration), result.Text);
    });
}

using (var writer = File.CreateText(WEBVTT_FILE))
{
    await writer.WriteAsync(submaker.GenerateSubs());
}

Declare

This repo is not an official edge-tts product.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages