Microsoft.Speech.Synthesis 不适用于 Text To Speech 但 System.Speech.Synthesis 有效.为什么? [英] Microsoft.Speech.Synthesis does not work for Text To Speech BUT System.Speech.Synthesis works.Why?

查看:54
本文介绍了Microsoft.Speech.Synthesis 不适用于 Text To Speech 但 System.Speech.Synthesis 有效.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是尝试使用 Microsoft.Speech.dll;

using System;
using Microsoft.Speech.Synthesis;

namespace TTS
{
    class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Testing TTS!");

            // Initialize a new instance of the SpeechSynthesizer.
            using (SpeechSynthesizer synth = new SpeechSynthesizer())
            {

                // Output information about all of the installed voices.
                Console.WriteLine("Installed voices -");
                foreach (InstalledVoice voice in synth.GetInstalledVoices())
                {
                    VoiceInfo info = voice.VoiceInfo;
                    Console.WriteLine(" Voice Name: " + info.Name);
                }

                // Select the US English voice.
                synth.SelectVoice("Microsoft Server Speech Text to Speech Voice (en-GB, Hazel)");

                // Build a prompt.
                PromptBuilder builder = new PromptBuilder();
                builder.AppendText("That is a big pizza!");

                // Speak the prompt.
                synth.Speak(builder);
            }

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

虽然我有正确的声音,它没有任何声音.没有文字转语音 (TTS) 语音.

Although I have the right voices, it does not make any sound. No Text To Speech(TTS) voice.

当我使用 Microsoft System.Speech.dll 时,我可以听到声音.所以没有声音问题.

When I use Microsoft System.Speech.dll then I can hear voice. So there is no sound problem.

using System;
using System.Speech.Synthesis;

namespace TTS
{
    class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Testing TTS!");

            // Initialize a new instance of the SpeechSynthesizer.
            using (SpeechSynthesizer synth = new SpeechSynthesizer())
            {

                // Output information about all of the installed voices.
                Console.WriteLine("Installed voices -");
                foreach (InstalledVoice voice in synth.GetInstalledVoices())
                {
                    VoiceInfo info = voice.VoiceInfo;
                    Console.WriteLine(" Voice Name: " + info.Name);
                }

                // Build a prompt.
                PromptBuilder builder = new PromptBuilder();
                builder.AppendText("That is a big pizza!");

                // Speak the prompt.
                synth.Speak(builder);
            }

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

不久

为什么我听不到任何声音或使用文字转语音(TTS)微软语音平台使用 Microsoft.Speech?我应该做一些吗额外的配置?

Why I can not hear any voice or make Text To Speech(TTS) with Microsoft Speech Platform using Microsoft.Speech? Should I do some extra config?

推荐答案

因为您使用了两种不同的 TTS 引擎.Microsoft.Speech 使用服务器 TTS 语音;System.Speech 使用桌面 TTS 语音.请参阅此处的讨论.

Because you're using two different TTS engines. Microsoft.Speech uses the server TTS voices; System.Speech uses the desktop TTS voices. See the discussion here.

Windows Vista 及更高版本默认注册了桌面 TTS 语音,但没有服务器 TTS 语音.当您安装 Server Speech Platform Runtime 时,我相信您必须首先加载 Microsoft.Speech.dll,您还应该可以选择安装一些服务器 TTS 语音.

Windows Vista and above have desktop TTS voices registered by default, but no server TTS voices. When you install the Server Speech Platform Runtime, which I believe you have to do in order to get the Microsoft.Speech.dll loaded in the first place, you should have the option to install some server TTS voices as well.

这篇关于Microsoft.Speech.Synthesis 不适用于 Text To Speech 但 System.Speech.Synthesis 有效.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆