Git Product home page Git Product logo

edge_tts_sharp's Introduction

Edge_tts_sharp

Edge_tts_sharp,是一个免费的C#库,调用Microsoft Edge Text to Speech接口生成音频。

install

NuGet\Install-Package Edge_tts_sharp -Version 1.0.3

文字转语言

using Edge_tts_sharp;

string msg = string.Empty;
Console.WriteLine("请输入文本内容.");
msg = Console.ReadLine();
// 1.0
//Edge_tts.PlayText(msg, "zh-CN", "Microsoft Server Speech Text to Speech Voice (zh-CN, XiaoxiaoNeural)", "webm-24khz-16bit-mono-opus");
var voice = Edge_tts.GetVoice().FirstOrDefault(i=> i.Name == "Microsoft Server Speech Text to Speech Voice (zh-CN, XiaoxiaoNeural)");
Edge_tts.PlayText(msg, voice);
Console.ReadLine();

设置语速

// 文字转语音,并且设置语速
Edge_tts.PlayText("你好微软!", "Microsoft Server Speech Text to Speech Voice (zh-CN, XiaoxiaoNeural)", -25);

保存到本地

// 文字转语音,并且设置语速
Edge_tts.PlayText("你好微软!", "Microsoft Server Speech Text to Speech Voice (zh-CN, XiaoxiaoNeural)", -25, "c:\\audio\\xxx.mp3");
// 只保存,不播放
Edge_tts.SaveAudio("你好微软!", "Microsoft Server Speech Text to Speech Voice (zh-CN, XiaoxiaoNeural)", -25, "c:\\audio\\xxx.mp3");

自定义操作

// 回调函数的第一个参数是binary数据
Edge_tts.Invoke(msg, voice, rate, (_binary) =>
{
    //...
    
});

获取音频列表

using Edge_tts_sharp;

var voices = Edge_tts.GetVoice();
foreach(var item in voices){
    Console.WriteLine($"voice name is{item.Name}, locale(语言) is {item.Locale}, SuggestedCodec(音频类型) is {item.SuggestedCodec}");
}

更新内容

  • 2023.10.28
    • 第一次上传。
  • 2023.10.30
    • 更新调用接口的方式

edge_tts_sharp's People

Contributors

entity-now avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.