首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >System.Speech.Synthesis和Microsoft.Speech.Synthesis有什么区别?

System.Speech.Synthesis和Microsoft.Speech.Synthesis有什么区别?
EN

Stack Overflow用户
提问于 2019-02-06 13:05:31
回答 1查看 1.7K关注 0票数 2

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

  • System.Speech.Synthesis
  • Microsoft.Speech.Synthesis

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

代码语言:javascript
复制
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);
    }
  }
}

有人能解释一下他们俩的区别吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-08 18:46:02

真正的区别就像链接答案中概述的那样;System.Speech.SpeechSynthesis使用桌面TTS引擎,而Microsoft.Speech.SpeechSynthesis使用服务器TTS引擎。从编程的角度来看,差别相对较小,但与许可的角度有很大的不同;服务器TTS引擎是单独授权的。

然而,System.Speech.SpeechSynthesisMicrosoft.Speech.SpeechSynthesis都是不推荐的API,新的开发应该基于Windows.Media.SpeechSynthesis API。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54554350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档