gpt4 book ai didi

speech-recognition - Microsoft.Speech.Synthesis 不适用于文本转语音但 System.Speech.Synthesis 有效。为什么?

转载 作者:行者123 更新时间:2023-12-04 02:51:25 41 4
gpt4 key购买 nike

我只是尝试使用 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) 语音。

enter image description here

当我使用 Microsoft 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);
}
}
}

enter image description here

不久

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 语音。查看讨论 here .

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

关于speech-recognition - Microsoft.Speech.Synthesis 不适用于文本转语音但 System.Speech.Synthesis 有效。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17577866/

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