将 SAPI 文本转语音本地化为西班牙语

发布于 2024-10-05 00:31:16 字数 678 浏览 0 评论 0原文

我已经成功地通过使用以下代码在 Delphi/Lazarus 中使用 SAPI 文本转语音:

procedure TForm1.Button1Click(Sender: TObject);
var
  SpVoice: Variant;
begin
  SpVoice := CreateOleObject('SAPI.SpVoice');
  SpVoice.Speak('Hello World!', 0);
end;  

此代码自动选择英语标准语音。由于我需要将其本地化为西班牙语,因此我调查了我的系统(带有标准西班牙语的 Windows XP)是否有西班牙语语音,或者我需要安装它,以及如何更改默认语音,但到目前为止还没有运气。因此我的问题是:

  1. 我如何知道我的系统是否已经安装了西班牙语语音或者我需要安装它?
  2. 假设我安装了所需的语音,如何让 SAPI 使用该语音而不是标准语音?

我猜我可以使用以下代码获得西班牙语语音(C0A 是西班牙语代码):

SpVoice.GetVoices('','Language=C0A').Item(0)

但不知道如何设置要使用的语音。

编辑:为了避免混淆,我需要使其与 Delphi 和 Lazarus 兼容,成为最后一个主要开发工具。

I have managed to use SAPI Text-To-Speech in Delphi/Lazarus by using the following code:

procedure TForm1.Button1Click(Sender: TObject);
var
  SpVoice: Variant;
begin
  SpVoice := CreateOleObject('SAPI.SpVoice');
  SpVoice.Speak('Hello World!', 0);
end;  

This code automatically chooses an english standard voice. Since I need to localize it to spanish I investigated if my system (Windows XP with standard Spanish) had a spanish voice or I needed to install it, and how to change the default voice, but no luck so far. Therefore my questions are:

  1. How can I know if my system already has a spanish voice installed or I need to install it?
  2. Supposing I have the voice I need installed, how can I make SAPI use that voice instead of the standard one?

I am guessing I can get a spanish voice by using following code (C0A is the code for spanish language):

SpVoice.GetVoices('','Language=C0A').Item(0)

but do not know how to set the voice to be used.

EDIT: to avoid confusions, I need to make this compatible with Delphi and Lazarus, being the last one the primary development tool.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

套路撩心 2024-10-12 00:31:17

没有免费提供的 SAPI 版本附带西班牙语语音。 SAPI 5.1 for XP 自带中英文语音; SAPI 5.3 和 SAPI 5.4 仅安装了英语语音。

您可以从 Cepstral(以及其他供应商)购买西班牙语语音,该语音适用于任何版本的 SAPI 5。(我没有使用过这些声音,所以我不能保证这些声音的质量。)

No freely available version of SAPI comes packaged with a Spanish voice. SAPI 5.1 for XP comes with a Chinese and English voice; SAPI 5.3 and SAPI 5.4 have only English voices installed.

You can purchase a Spanish voice from Cepstral (among other vendors) that will work for any version of SAPI 5. (I have not used these voices, so I cannot vouch for the quality of these voices.)

人心善变 2024-10-12 00:31:17

安装 Microsoft Speech Server,并按照 这些提示操作href="http://fgaillard.com" rel="nofollow">弗朗索瓦·盖拉德。

Install Microsoft Speech Server, and follow these hints by Francois Gaillard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文