This repo is C# implementation of edge-tts.
EdgeTTS allows you to use Microsoft Edge's online text-to-speech service from C#.
PM> Install-Package EdgeTTS
var OUTPUT_FILE = "hello.mp3";
var communicate = new Communicate(
"hello world", "zh-CN-YunxiNeural");
await communicate.Save(OUTPUT_FILE);
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));
});
}
// 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);
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());
}
This repo is not an official edge-tts product.