gpt4 book ai didi

c# - System.Speech.Synthesis 和 Microsoft.Speech.Synthesis 有什么区别?

转载 作者:行者123 更新时间:2023-11-30 22:56:14 25 4
gpt4 key购买 nike

我目前正在用 C# 开发一个实现文本转语音的小程序。但是,我发现可以使用两个命名空间:

  • 系统.语音.合成
  • Microsoft.Speech.Synthesis

我用谷歌搜索了差异并找到了 this关于语音识别的帖子。它并没有真正回答我的问题。我也在他们两个之间切换,没有区别。它适用于代码中的所有语言(如下)。

using System;
using System.Speech.Synthesis;
//using Microsoft.Speech.Synthesis;

namespace TTS_TEST
{
class Program
{

static void Main(string[] args)
{
SpeechSynthesizer synth = new SpeechSynthesizer();

int num;
string userChoice;

do
{
Console.WriteLine("1 - " + "Microsoft Server Speech Text to Speech Voice (en-US, ZiraPro)");
Console.WriteLine("2 - " + "Microsoft Server Speech Text to Speech Voice (en-GB, Hazel)");
Console.WriteLine("3 - " + "Microsoft Server Speech Text to Speech Voice (es-ES, Helena)");
Console.WriteLine("4 - " + "Microsoft Server Speech Text to Speech Voice (fr-FR, Hortense)");
Console.WriteLine("5 - " + "Exit");
Console.Write("Enter the number of your choice: "); //the user chooses a number
userChoice = Console.ReadLine();

if (!Int32.TryParse(userChoice, out num)) continue;

Console.WriteLine("Choice = " + userChoice);

if (userChoice == "1") //Option 1 will use the voice en-US, ZiraPro
{
synth.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-US, ZiraPro)");
}

if (userChoice == "2") //Option 2 will use the voice en-GB, Hazel
{
synth.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-GB, Hazel)");
}

if (userChoice == "3") //Option 3 will use the voice es-ES, Helena
{
synth.SelectVoice("Microsoft Server Speech Text to Speech Voice (es-ES, Helena)");
}

if (userChoice == "4") //Option 4 will use the voice fr-FR, Hortense
{
synth.SelectVoice("Microsoft Server Speech Text to Speech Voice (fr-FR, Hortense)");
}

if (userChoice == "5") //Option 5 will exit application
{
Environment.Exit(0);
}

synth.SetOutputToDefaultAudioDevice(); //set the default audio output

foreach (InstalledVoice voice in synth.GetInstalledVoices()) //list the installed voices details
{
VoiceInfo info = voice.VoiceInfo;

Console.WriteLine(" Name: " + info.Name);
synth.Speak("Name: " + info.Name);
Console.WriteLine(" Culture: " + info.Culture);
synth.Speak("Culture: " + info.Culture);
Console.WriteLine(" Age: " + info.Age);
synth.Speak("Age: " + info.Age);
Console.WriteLine(" Gender: " + info.Gender);
synth.Speak("Gender: " + info.Gender);
Console.WriteLine(" Description: " + info.Description);
Console.WriteLine(" ID: " + info.Id + "\n");
synth.Speak("ID: " + info.Id);
}

Console.ReadKey();

}
while (true);
}
}
}

有人能给我解释一下他们两者之间的区别吗?

最佳答案

差异实际上与链接答案中概述的差不多; System.Speech.SpeechSynthesis 使用桌面 TTS 引擎,而 Microsoft.Speech.SpeechSynthesis 使用服务器 TTS 引擎。从编程的角度来看,差异相对较小,但从许可的角度来看,差异很大;服务器 TTS 引擎是单独许可的。

但是,System.Speech.SpeechSynthesisMicrosoft.Speech.SpeechSynthesis 都是废弃的API,新的开发应该基于Windows.Media.SpeechSynthesis API。

关于c# - System.Speech.Synthesis 和 Microsoft.Speech.Synthesis 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54554350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com