我只是尝试使用Microsoft.Speech.dll;运行简单的microsoft文本到语音示例。
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)语音。

当我使用微软的System.Speech.dll,然后,我可以听到声音。所以没有声音问题。
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?我应该做些额外的配置吗?
发布于 2013-07-12 20:45:32
因为你用的是两个不同的TTS引擎。Microsoft.Speech使用服务器TTS语音;System.Speech使用桌面TTS语音。请参阅讨论这里。
默认情况下,Windows及以上版本的桌面TTS声音已注册,但没有服务器TTS语音。当您安装服务器语音平台运行时 (我认为您必须这样做,以便首先加载Microsoft.Speech.dll )时,您应该可以选择安装一些服务器TTS语音。
发布于 2013-11-07 05:03:27
在上,选择Add,然后选择System.Speech旁边的复选框
在您的程序中,也要使用system.speech。
对我来说很好。
发布于 2019-02-01 15:11:25
为了回答你的问题,你问:
为什么我不能听到任何声音或做文本语音(TTS)与微软语音平台使用Microsoft.Speech?
您在代码中遗漏了一件重要的事情。您无法听到声音,因为缺少了下面一行:
synth.SetOutputToDefaultAudioDevice();这样你就能听到声音了。我也有同样的问题。我修改了您的代码,插入了上面的代码示例:
using System;
using System.Speech.Synthesis;
using Microsoft.Speech.Synthesis;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Testing TTS!");
// Initialize a new instance of the SpeechSynthesizer.
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
// Configure the synthesizer to send output to the default audio device.
synth.SetOutputToDefaultAudioDevice();
// 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)");
// Speak.
synth.Speak("That is a big pizza!");
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}注意,在使用SetOutputToDefaultAudioDevice时,不必使用System.Speech.dll。下面是有关该方法的文档的链接。
https://stackoverflow.com/questions/17577866
复制相似问题