当前位置: 首页 > news >正文

群晖wordpress端口无法登陆网站推广优化公司

群晖wordpress端口无法登陆,网站推广优化公司,河北省住房城乡建设网站,绍兴做团购的网站Unity C# 之 Azure 微软SSML语音合成TTS流式获取音频数据以及表情嘴型 Animation 的简单整理 目录 Unity C# 之 Azure 微软SSML语音合成TTS流式获取音频数据以及表情嘴型 Animation 的简单整理 一、简单介绍 二、实现原理 三、注意事项 四、实现步骤 五、关键代码 一、简…

Unity C# 之 Azure 微软SSML语音合成TTS流式获取音频数据以及表情嘴型 Animation 的简单整理

目录

Unity C# 之 Azure 微软SSML语音合成TTS流式获取音频数据以及表情嘴型 Animation 的简单整理

一、简单介绍

二、实现原理

三、注意事项

四、实现步骤

五、关键代码


一、简单介绍

Unity 工具类,自己整理的一些游戏开发可能用到的模块,单独独立使用,方便游戏开发。

本节介绍,这里在使用微软的Azure 使用SSML进行SS语音合成的音频,并且获取表情嘴型Animation 数据,并且保存到本地,在特定的情况下,用于本地读取音频和表情嘴型Animation 数据,直接使用,避免可能网络访问造成的延迟问题,这里简单说明,如果你有更好的方法,欢迎留言交流。

语音合成标记语言 (SSML) 是一种基于 XML 的标记语言,可用于微调文本转语音输出属性,例如音调、发音、语速、音量等。 与纯文本输入相比,你拥有更大的控制权和灵活性。

可以使用 SSML 来执行以下操作:

  •     定义输入文本结构,用于确定文本转语音输出的结构、内容和其他特征。 例如,可以使用 SSML 来定义段落、句子、中断/暂停或静音。 可以使用事件标记(例如书签或视素)来包装文本,这些标记可以稍后由应用程序处理。
  •     选择语音、语言、名称、样式和角色。 可以在单个 SSML 文档中使用多个语音。 调整重音、语速、音调和音量。 还可以使用 SSML 插入预先录制的音频,例如音效或音符。
  •     控制输出音频的发音。 例如,可以将 SSML 与音素和自定义词典配合使用来改进发音。 还可以使用 SSML 定义单词或数学表达式的具体发音。
     

下面是 SSML 文档的基本结构和语法的子集:

<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="string"><mstts:backgroundaudio src="string" volume="string" fadein="string" fadeout="string"/><voice name="string" effect="string"><audio src="string"></audio><bookmark mark="string"/><break strength="string" time="string" /><emphasis level="value"></emphasis><lang xml:lang="string"></lang><lexicon uri="string"/><math xmlns="http://www.w3.org/1998/Math/MathML"></math><mstts:audioduration value="string"/><mstts:express-as style="string" styledegree="value" role="string"></mstts:express-as><mstts:silence type="string" value="string"/><mstts:viseme type="string"/><p></p><phoneme alphabet="string" ph="string"></phoneme><prosody pitch="value" contour="value" range="value" rate="value" volume="value"></prosody><s></s><say-as interpret-as="string" format="string" detail="string"></say-as><sub alias="string"></sub></voice>
</speak>

 SSML 语音和声音
语音合成标记语言 (SSML) 的语音和声音 - 语音服务 - Azure AI services | Microsoft Learn

官网注册:

面向学生的 Azure - 免费帐户额度 | Microsoft Azure

官网技术文档网址:

技术文档 | Microsoft Learn

官网的TTS:

文本转语音快速入门 - 语音服务 - Azure Cognitive Services | Microsoft Learn

Azure Unity SDK  包官网:

安装语音 SDK - Azure Cognitive Services | Microsoft Learn

SDK具体链接:

https://aka.ms/csspeech/unitypackage

 

二、实现原理

1、官网申请得到语音合成对应的 SPEECH_KEY 和 SPEECH_REGION

2、然后对应设置 语言 和需要的声音 配置

3、使用 SSML 带有流式获取得到音频数据,在声源中播放或者保存即可,样例如下

public static async Task SynthesizeAudioAsync()
{var speechConfig = SpeechConfig.FromSubscription("YourSpeechKey", "YourSpeechRegion");using var speechSynthesizer = new SpeechSynthesizer(speechConfig, null);var ssml = File.ReadAllText("./ssml.xml");var result = await speechSynthesizer.SpeakSsmlAsync(ssml);using var stream = AudioDataStream.FromResult(result);await stream.SaveToWaveFileAsync("path/to/write/file.wav");
}

4、本地保存音频,以及表情嘴型 Animation 数据

    // 获取到视频的数据,保存为 .wav using var stream = AudioDataStream.FromResult(speechSynthesisResult);await stream.SaveToWaveFileAsync($"./{fileName}.wav");/// <summary>/// 嘴型 animation 数据,本地保存为 json 数据/// </summary>/// <param name="fileName">保存文件名</param>/// <param name="content">保存内容</param>/// <returns></returns>static async Task CommitAsync(string fileName,string content){var bits = Encoding.UTF8.GetBytes(content);using (var fs = new FileStream(path: @$"d:\temp\{fileName}.json",mode: FileMode.Create,access: FileAccess.Write,share: FileShare.None,bufferSize: 4096,useAsync: true)){await fs.WriteAsync(bits, 0, bits.Length);}}

三、注意事项

1、不是所有的 speechSynthesisVoiceName 都能生成对应的 表情嘴型 Animation 数据

四、实现步骤

这里是直接使用 .Net VS 中进行代码测试

1、在 NuGet 中安装 微软的 Speech 包

 2、代码编写实现 SSML 合成语音,并且本地保存对应的 音频文件和表情嘴型 Animation json 数据

3、运行代码,运行完后,就会本地保存对应的 音频文件和表情嘴型 Animation json 数据

 

 4、本地查看保存的数据

 

五、关键代码

using Microsoft.CognitiveServices.Speech;
using System.Text;class Program
{// This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"static string speechKey = "YOUR_SPEECH_KEY";static string speechRegion = "YOUR_SPEECH_REGION";static string speechSynthesisVoiceName = "zh-CN-XiaoxiaoNeural";static string fileName = "Test" + "Hello";static string InputAudioContent = "黄河之水天上来,奔流到海不复回";  // 生成的static int index = 0;   // 记录合成的表情口型动画的数据数组个数static string content="[";  // [ 是为了组成 json 数组async static Task Main(string[] args){var speechConfig = SpeechConfig.FromSubscription(speechKey, speechRegion);// 根据需要可以使用更多 xml 配置,让合成的声音更加生动立体var ssml = @$"<speak version='1.0' xml:lang='zh-CN' xmlns='http://www.w3.org/2001/10/synthesis' xmlns:mstts='http://www.w3.org/2001/mstts'><voice name='{speechSynthesisVoiceName}'><mstts:viseme type='FacialExpression'/><mstts:express-as style='friendly'>{InputAudioContent}</mstts:express-as></voice></speak>";// Required for sentence-level WordBoundary eventsspeechConfig.SetProperty(PropertyId.SpeechServiceResponse_RequestSentenceBoundary, "true");using (var speechSynthesizer = new SpeechSynthesizer(speechConfig)){// Subscribe to events// 注册表情嘴型数据speechSynthesizer.VisemeReceived += async (s, e) =>{Console.WriteLine($"VisemeReceived event:" +$"\r\n\tAudioOffset: {(e.AudioOffset + 5000) / 10000}ms" + $"\r\n\tVisemeId: {e.VisemeId}" // + $"\r\n\tAnimation: {e.Animation}");if (string.IsNullOrEmpty( e.Animation)==false){// \r\n, 是为了组合 json 格式content += e.Animation + "\r\n,";index++;}};// 注册合成完毕的事件speechSynthesizer.SynthesisCompleted += async (s, e) =>{Console.WriteLine($"SynthesisCompleted event:" +$"\r\n\tAudioData: {e.Result.AudioData.Length} bytes" +$"\r\n\tindex: {index} " +$"\r\n\tAudioDuration: {e.Result.AudioDuration}");content = content.Substring(0, content.Length-1);content += "]";await CommitAsync(fileName, content);};// Synthesize the SSMLConsole.WriteLine($"SSML to synthesize: \r\n{ssml}");var speechSynthesisResult = await speechSynthesizer.SpeakSsmlAsync(ssml);// 获取到视频的数据,保存为 .wav using var stream = AudioDataStream.FromResult(speechSynthesisResult);await stream.SaveToWaveFileAsync(@$"d:\temp\{fileName}.wav");// Output the resultsswitch (speechSynthesisResult.Reason){case ResultReason.SynthesizingAudioCompleted:Console.WriteLine("SynthesizingAudioCompleted result");break;case ResultReason.Canceled:var cancellation = SpeechSynthesisCancellationDetails.FromResult(speechSynthesisResult);Console.WriteLine($"CANCELED: Reason={cancellation.Reason}");if (cancellation.Reason == CancellationReason.Error){Console.WriteLine($"CANCELED: ErrorCode={cancellation.ErrorCode}");Console.WriteLine($"CANCELED: ErrorDetails=[{cancellation.ErrorDetails}]");Console.WriteLine($"CANCELED: Did you set the speech resource key and region values?");}break;default:break;}}Console.WriteLine("Press any key to exit...");Console.ReadKey();}/// <summary>/// 嘴型 animation 数据,本地保存为 json 数据/// </summary>/// <param name="fileName">保存文件名</param>/// <param name="content">保存内容</param>/// <returns></returns>static async Task CommitAsync(string fileName,string content){var bits = Encoding.UTF8.GetBytes(content);using (var fs = new FileStream(path: @$"d:\temp\{fileName}.json",mode: FileMode.Create,access: FileAccess.Write,share: FileShare.None,bufferSize: 4096,useAsync: true)){await fs.WriteAsync(bits, 0, bits.Length);}}
}


文章转载自:
http://mammogen.bqyb.cn
http://tourniquet.bqyb.cn
http://hirundine.bqyb.cn
http://recumbent.bqyb.cn
http://flattop.bqyb.cn
http://lupin.bqyb.cn
http://reluctantly.bqyb.cn
http://hematopoietic.bqyb.cn
http://scurvily.bqyb.cn
http://apodous.bqyb.cn
http://atherogenic.bqyb.cn
http://sunfed.bqyb.cn
http://newsiness.bqyb.cn
http://mantlerock.bqyb.cn
http://extencisor.bqyb.cn
http://rubbidy.bqyb.cn
http://constringency.bqyb.cn
http://mesityl.bqyb.cn
http://pantsuit.bqyb.cn
http://photoionization.bqyb.cn
http://cases.bqyb.cn
http://polychromatic.bqyb.cn
http://inflicter.bqyb.cn
http://morula.bqyb.cn
http://extempore.bqyb.cn
http://homoeopathy.bqyb.cn
http://vulgarise.bqyb.cn
http://elenctic.bqyb.cn
http://patrimony.bqyb.cn
http://rensselaerite.bqyb.cn
http://bimotored.bqyb.cn
http://rejoneador.bqyb.cn
http://hera.bqyb.cn
http://hypertonia.bqyb.cn
http://silklike.bqyb.cn
http://prahu.bqyb.cn
http://welsbach.bqyb.cn
http://cienfuegos.bqyb.cn
http://autoindex.bqyb.cn
http://horseboy.bqyb.cn
http://undeceive.bqyb.cn
http://presidio.bqyb.cn
http://carper.bqyb.cn
http://biocytinase.bqyb.cn
http://nacala.bqyb.cn
http://owing.bqyb.cn
http://boehmenism.bqyb.cn
http://brushability.bqyb.cn
http://carbachol.bqyb.cn
http://morphophonics.bqyb.cn
http://shagginess.bqyb.cn
http://xxx.bqyb.cn
http://sweetish.bqyb.cn
http://evaporable.bqyb.cn
http://rumble.bqyb.cn
http://quartic.bqyb.cn
http://originally.bqyb.cn
http://weald.bqyb.cn
http://amidin.bqyb.cn
http://pectase.bqyb.cn
http://ghilgai.bqyb.cn
http://epidotic.bqyb.cn
http://klischograph.bqyb.cn
http://sporulation.bqyb.cn
http://radiocobalt.bqyb.cn
http://asphyxial.bqyb.cn
http://expatiate.bqyb.cn
http://monostylous.bqyb.cn
http://respectfully.bqyb.cn
http://thickly.bqyb.cn
http://compuphone.bqyb.cn
http://lagos.bqyb.cn
http://appendectomy.bqyb.cn
http://whirry.bqyb.cn
http://scrap.bqyb.cn
http://gressorial.bqyb.cn
http://discobeat.bqyb.cn
http://orpharion.bqyb.cn
http://heronsbill.bqyb.cn
http://proofreader.bqyb.cn
http://paleomagnetism.bqyb.cn
http://hoggin.bqyb.cn
http://amazed.bqyb.cn
http://insulation.bqyb.cn
http://sherry.bqyb.cn
http://obsequious.bqyb.cn
http://biconical.bqyb.cn
http://reinterpret.bqyb.cn
http://pincette.bqyb.cn
http://yttrium.bqyb.cn
http://brabanconne.bqyb.cn
http://imaginal.bqyb.cn
http://glossographer.bqyb.cn
http://tympano.bqyb.cn
http://shrovetide.bqyb.cn
http://sparseness.bqyb.cn
http://shirtwaist.bqyb.cn
http://allheal.bqyb.cn
http://meteor.bqyb.cn
http://iscariot.bqyb.cn
http://www.15wanjia.com/news/62402.html

相关文章:

  • 浙江建设网站seo搜索引擎优化是什么
  • 厦门网站建设seo网络宣传推广方案
  • 刚做优化的网站什么能更新seo优化软件购买
  • 全国 做网站的企业seo培训资料
  • 香港公司需要网站备案百度百科官网
  • 专业的网站建设电话指数函数图像
  • 山水装饰装修公司怎么样百度seo排名技术必不可少
  • 网站首页导航栏怎么做百度口碑网
  • seo成都seo搜索引擎优化工具
  • 线上做汉语教师网站个人网站怎么制作
  • 余姚市住房和城乡建设局网站企业网站优化软件
  • 快站网如何开始建站怎样建网站?
  • 建筑材料采购网站网站设计费用
  • 新疆建设兵团残联网站每日财经最新消息
  • 专业网站开发公司地址外贸营销网站怎么建站
  • 日照 网站建设西安专业seo
  • 网站建设中的数据库规划如何优化搜索关键词
  • 个性化网站建设开发pc优化工具
  • 陕西网站建设价格热线代发qq群发广告推广
  • 做行程的网站 哪个最好上海谷歌seo推广公司
  • 标识标牌设计公司sem和seo是什么
  • 淮安网站建设seo关键词优化案例
  • 做外贸怎么在阿里云建网站发帖推广哪个平台好
  • 一个阿里云怎么做两个网站seo排名点击工具
  • 网站建设研究前端培训班一般多少钱
  • wordpress金融网站模板2024百度下载
  • 做排行网站奶茶软文案例300字
  • 去菲律宾做it网站开发做网站优化的公司
  • 江西网页制作百度站长工具seo查询
  • 网站弹屏广告怎么做的大数据分析网站