System.Speech.Synthesis如何将语音从en-US更改为en-GB?

时间:2016-12-21 02:39:48

标签: c# .net visual-studio text-to-speech speech-synthesis

我在网上随处可见。我发现了如何改变声音的性别(合成器.SelectVoiceByHints(VoiceGender.Male)和声音的年龄,但我无法弄清楚如何改变声音的文化(又称添加声音)英国口音)。

另一个可行的选择是找到另一个语音合成器。但是,当我尝试将其应用到我的程序中时,语音合成器无法正常工作。

非常感谢你的帮助!

2 个答案:

答案 0 :(得分:1)

两周前,我开发了法语和英语的语音合成器工具。我按照以下步骤通过调用SelectVoiceByHints方法安装更多声音并配置了不同的声音。

Tools: Windows 7, Visual Studio 2013

您可以设置文化信息,如下所示

SpeechSynthesizer _synthesizer = new SpeechSynthesizer();
_synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult, 0, CultureInfo.GetCultureInfo("fr-FR")); // For French
// en-US for English(US)

安装更多声音的步骤

WARNING: This involves manual edits to your registry. Do at your own risk.

Step 1 --------------------------------------------------------------------------
Install the Speech Platform v11
a) go here: http://www.microsoft.com/en-us/download/details.aspx?id=27225
b) click "Download"
c) select the "x64_SpeechPlatformRuntime\SpeechPlatformRuntime.msi"
d) run the installer (duh :P)

Step 2: --------------------------------------------------------------------------
Get the alternate voices
a) go here: http://www.microsoft.com/en-us/download/details.aspx?id=27224
b) click "Download"
c) select the voice files you want. They are the ones that have "TTS" in the file name. 
    MSSpeech_TTS_en-CA_Heather
    MSSpeech_TTS_en-GB_Hazel
    MSSpeech_TTS_en-IN_Heera
    MSSpeech_TTS_en-US_Helen
    MSSpeech_TTS_en-US_ZiraPro
    MSSpeech_TTS_en-AU_Hayley
d) run the installers for each (duh :P)

Step 3: --------------------------------------------------------------------------
Extract the registry tokens
a) Open Regedit
b) Under - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech Server\v11.0\Voices - right click the "Tokens" folder and export. Save this file to your desktop as voices1.reg so it will be easy to find later.
c) Under - HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Speech Server\v11.0\Voices - right click "Tokens" and again export it, again to the desktop. Call it voices2.reg.

Step 4: --------------------------------------------------------------------------
Edit the voices1/2 files
a) open Voices1.reg in Notepad.
b) press "cntrl + H"
c) enter \Speech Server\v11.0\ into the "Find What" field
d) enter \Speech\ into the "Replace With" field
e) click "Replace All"
f) Save File
g) Repeat a-f with the Voices2.reg file

Step 5: --------------------------------------------------------------------------
Merge the new Registry files into your registry
a) double click to "run" both Voices1.reg and Voices2.reg
b) Click "Yes" when it prompts

您现在应该可以访问Voice Attack和Windows TTS选项菜单中的新语音。此过程也可以与其他语音包一起使用。

来源:https://superuser.com/questions/590779/how-to-install-more-voices-to-windows-speech/872573#872573

希望这能给出一些想法。

答案 1 :(得分:1)

在查看/** Typescript -> ES6 -> Babel -> ES5 */ gulp.task("ts-babel", function () { const tsconfig = { target: "es6", lib: ["es5", "dom"] } const babelconfig = { presets: ["es2015"], plugins: ["transform-runtime"] } const tsProject = ts.createProject(tsconfig); return gulp .src("src/**/*.ts") .pipe(sourcemaps.init()) .pipe(tsProject()) .js .pipe(babel(babelconfig)) .pipe(sourcemaps.write(".")) .pipe(gulp.dest("build/es5")); }) /** Webpack bundle */ gulp.task("webpack", ["ts-babel"], function () { const config = { devtool: "source-map", output: { filename: "app.bundle.js" }, module: { preLoaders: [ { test: /\.js$/, loader: "source-map-loader" } ] } } return gulp .src("build/es5/**/*.js") .pipe(webpack(config)) .pipe(gulp.dest("build/bundle")); })的文档后,我发现SpeechSynthesizer类型为VoiceInfo。在VoiceInfo中,还有另一个名为Culture的属性。我想你应该设置那个属性。

这样的事情:

var culture = new CultureInfo("en-gb");
var voice = new VoiceInfo();
voice.Culture = culture;
yourSpeechSynthesizer.voice = voice;