10

在 C# 中使用语音 API 或SAPI的这两种方法有什么区别?

using SpeechLib;
SpVoice speech = new SpVoice();
speech.Speak(text, SpeechVoiceSpeakFlags.SVSFlagsAsync);

返回Apacela 的声音,和

SpeechSynthesizer ss = new SpeechSynthesizer();
ss.SpeakAsync ("Hello, world");

不适用于Apacela 声音

第一个返回所有声音,但第二个只返回几个声音。这与 SAPI 5.1 和 SAPI 5.3 有关吗?

Vista 和 XP 上的行为相同,SpVoice 都能够检测到 Apacela 语音,但使用 SpeechSynthesizer,在 XP 和 Vista 上均未检测到语音。

我猜 XP 使用 SAPI 5.1,而 Vista 使用 SAPI 5.3 那么为什么所有操作系统上的行为相同,但 API 的行为不同?

还有哪个API更强大,两种方式/API有什么区别?

4

2 回答 2

6

SpeechLib is an Interop DLL that makes use of classic COM-based SAPI under the covers. System.Speech was developed by Microsoft to interact with Text-to-speech (and voice recognition) directly from within managed code.

In general, it's cleaner to stick with the managed library (System.Speech) when you're writing a managed application.

It's definitely not related to SAPI version--the most likely problem here is that a voice vendor (in this case Acapela) has to explicitly implement support for certain System.Speech features. It's possible that the Acapela voices that you have support everything that is required, but it's also possible that they don't. Your best bet would be to ask the Acapela Group directly.

Voices are registered in HKLM\SOFTWARE\Microsoft\Speech\Tokens, and you should see the Windows built-in voices, as well as the Acapela voices that you have added listed there. If you spot any obvious differences in how they're registered, you might be able to make the Acapela voices work by making their registration match that of, for example, MS-Anna.

But I'd say the most likely possibility is that the Acapela voices have not been updated to support all of the interfaces required by System.Speech.

于 2009-02-26T03:27:38.370 回答
3

SpeechLib 是一个互操作 DLL,因此映射到它创建的任何版本的 SpeechLib(您可以检查它的属性)。

System.Speech.* 是 .NET 框架中对语音的“官方”支持。SpeechSynthesizer 选择在运行时使用哪个语音库(很像 System.Web.Mail 类所做的)。

我不确定他们为什么返回不同数量的声音,但这可能与所使用的 SAPI 版本有关。

于 2009-02-12T09:39:02.143 回答