zoukankan      html  css  js  c++  java
  • 百度语音合成调用DEMO

    百度语音合成,没有粤语,只得放弃。
    讯飞的粤语包太贵,第二年收费2万,只好选择阿里。

    //百度语音合成调用DEMO
    public class BaiduVoice { // 设置APPID/AK/SK public string APP_ID = "<Your App ID>"; public string API_KEY = "<Your API Key>"; public string SECRET_KEY = "<Your Secret Key>"; public void Play(string text) { if (!Directory.Exists(@"d: emp")) { Directory.CreateDirectory(@"d: emp"); } var client = new Baidu.Aip.Speech.Tts(API_KEY, SECRET_KEY); client.Timeout = 60000;  // 修改超时时间 // 可选参数 var option = new Dictionary<string, object>() { {"spd", 4}, // 语速 {"vol", 5}, // 音量 {"per", 2 }  // 发音人,4:情感度丫丫童声 }; //var result = client.Synthesis("请注意,请张三到四号窗口办理业务,谢谢", option); var result = client.Synthesis(text, option); if (result.ErrorCode == 0)  // 或 result.Success { string fileName = $@"d: emp{Guid.NewGuid()}.mp3"; File.WriteAllBytes(fileName, result.Data); Mp3Player mp3Play = new Mp3Player() { FileName = fileName, }; mp3Play.play(); } else { MsgBox.Show(JsonConvert.SerializeObject(result)); } } }
  • 相关阅读:
    work 2
    chapter02
    7.23作业
    第五章
    三层交换机
    基于nginx结合openssl实现https
    chapter10--进程和计划任务管理
    Linux系统管理08--服务器RAID及配置实战
    chapter07-- LVM逻辑卷
    Linux系统管理07--文件系统与LVM
  • 原文地址:https://www.cnblogs.com/ego/p/14162852.html
Copyright © 2011-2022 走看看