SpVoice 和 SpeechSynthesizer 之间有什么区别
使用语音 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有什么区别?
What is the difference between these two methods in C# using the speech API or SAPI?
using SpeechLib;
SpVoice speech = new SpVoice();
speech.Speak(text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
returns the Apacela voices, and
SpeechSynthesizer ss = new SpeechSynthesizer();
ss.SpeakAsync ("Hello, world");
Does not work with Apacela voices.
The first one return all voices but the second one only return few voices. Is this something related to SAPI 5.1 and SAPI 5.3?
The behavior is same on Vista and XP, on both SpVoice was able to detect the Apacela voice but using SpeechSynthesizer, the voices does not detected on both XP and Vista.
I guess XP uses SAPI 5.1, and Vista uses SAPI 5.3 then why the same behavior on all OS, but different behavior with the API?
Also which API is more powerful and what are the difference between the two ways/API?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SpeechLib 是一个 Interop DLL,它在幕后利用了经典的基于 COM 的 SAPI。 System.Speech 由 Microsoft 开发,用于直接在托管代码中与文本转语音(和语音识别)进行交互。
一般来说,在编写托管应用程序时,坚持使用托管库 (System.Speech) 会更干净。
这绝对与 SAPI 版本无关——这里最可能的问题是语音供应商(在本例中为 Acapela)必须显式实现对某些 System.Speech 功能的支持。 您所拥有的阿卡佩拉声音可能支持所需的一切,但也有可能不支持。 您最好的选择是直接询问 Acapela Group。
语音在 HKLM\SOFTWARE\Microsoft\Speech\Tokens 中注册,您应该会看到 Windows 内置语音以及您已添加的 Acapela 语音列在那里。 如果您发现它们的注册方式有任何明显的差异,您也许可以通过使 Acapela 声音的注册与 MS-Anna 等的注册相匹配来使它们正常工作。
但我想说最有可能的可能性是 Acapela 语音尚未更新以支持 System.Speech 所需的所有接口。
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.
SpeechLib 是一个互操作 DLL,因此映射到为其创建的 SpeechLib 的任何版本(您可以检查它的属性)。
System.Speech.* 是 .NET 框架中对语音的“官方”支持。 SpeechSynthesizer 选择在运行时使用哪个语音库(很像 System.Web.Mail 类所做的)。
我不确定为什么他们返回不同数量的声音,但这可能与所使用的 SAPI 版本有关。
SpeechLib is an interop DLL and so maps to whatever version of SpeechLib it was created for (you can check it's properties).
System.Speech.* is the "official" support for speech in the .NET framework. SpeechSynthesizer chooses which speech library to use at runtime (much like the System.Web.Mail classes did).
I'm not sure why they return a different number of voices but it is likely to be related to the SAPI version being used.