惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - MaxIE

jQuery选择器和选取方法 为什么Android的图片质量会比iPhone的差? 百度地图计算两坐标点之间距离计算 - MaxIE .net下BerkeleyDB操作封装C#版(附单元测试) MS SQL SERVER索引优化相关查询 SSD在SQLServer中的应用 让.net程序自动运行在管理员权限下 “请求的操作无法在使用用户映射区域打开的文件上执行”问题处理 C#随机字符串随机性不足的解決方式(随机数重复) json.net处理复杂json 未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序 解决办法 excel中根据单元格背景颜色进行数据筛选(excel2003实现方法) 跨平台加密版 SQLite 3 - wxSQLite3 数据库sql2000错误8908及处理 jQuery2011年年度最佳插件 jQ中文API离线版下载(适用版本1.4.4,1.5,1.5.1,1.5.2,1.6,1.6.1,1.6.2) 方便的CSS和jQuery下拉菜单解决方案 sql2000无法执行查询及未找到提供程序解决办法 - MaxIE SQL Server优化SELECT语句方法
Speech两种使用方法
MaxIE · 2013-06-27 · via 博客园 - MaxIE

COM组件使用speech:

public class Speach
{
private static Speach _Instance = null ;
private SpeechLib.SpVoiceClass voice =null; //SAPI5.1
private SpeechLib.SpVoice voice = null;//SAPI 5.4
private Speach()
{
BuildSpeach() ;
}
public static Speach instance()
{
if (_Instance == null)
_Instance = new Speach() ;
return _Instance ;
}

private void SetChinaVoice()
{
voice.Voice = voice.GetVoices(string.Empty,string.Empty).Item(0) ;
}

private void SetEnglishVoice()
{
voice.Voice = voice.GetVoices(string.Empty,string.Empty).Item(1) ;
}

private void SpeakChina(string strSpeak)
{
SetChinaVoice() ;
Speak(strSpeak) ;
}

private void SpeakEnglishi(string strSpeak)
{
SetEnglishVoice() ;
Speak(strSpeak) ;
}

public void AnalyseSpeak(string strSpeak)
{
int iCbeg = 0 ;
int iEbeg = 0 ;
bool IsChina = true ;
for(int i=0;i<strSpeak.Length;i++)
{
char chr = strSpeak[i] ;
if (IsChina)
{
if (chr<=122&&chr>=65)
{
int iLen = i - iCbeg ;
string strValue = strSpeak.Substring(iCbeg,iLen) ;
SpeakChina(strValue) ;
iEbeg = i ;
IsChina = false ;
}
}
else
{
if (chr>122||chr<65)
{
int iLen = i - iEbeg ;
string strValue = strSpeak.Substring(iEbeg,iLen) ;
this.SpeakEnglishi(strValue) ;
iCbeg = i ;
IsChina = true ;
}
}
}//end for
if (IsChina)
{
int iLen = strSpeak.Length - iCbeg ;
string strValue = strSpeak.Substring(iCbeg,iLen) ;
SpeakChina(strValue) ;
}
else
{
int iLen = strSpeak.Length - iEbeg ;
string strValue = strSpeak.Substring(iEbeg,iLen) ;
SpeakEnglishi(strValue) ;
}
}

private void BuildSpeach()
{
if (voice == null)
voice = new SpVoiceClass() ;
}

public int Volume
{
get
{
return voice.Volume ;
}

set
{
voice.SetVolume((ushort)(value)) ;
}
}

public int Rate
{
get
{
return voice.Rate ;
}
set
{
voice.SetRate(value) ;
}
}

private void Speak(string strSpeack)
{
try
{
voice.Speak(strSpeack,SpeechVoiceSpeakFlags.SVSFlagsAsync) ;
}
catch(Exception err)
{
throw(new Exception("发生一个错误:"+err.Message)) ;
}
}

public void Stop()
{
voice.Speak(string.Empty,SpeechLib.SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak) ;
}

public void Pause()

{
voice.Pause() ;
}

public void Continue()
{
voice.Resume() ;
}
}//end class

使用.NET类库和系统API:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Synthesis;
using System.Speech;

namespace StudyBeta
{
    public class SRead
    {
        public SpeechSynthesizer synth; //语音合成对象
        public SRead()
        {
            synth = new SpeechSynthesizer();
        }
        public SRead(int m, int n)
        {
            //使用 synth 设置朗读音量 [范围 0 ~ 100]
            synth.Volume = m;
            //使用 synth 设置朗读频率 [范围 -10 ~ 10]
            synth.Rate = n;
        }
        public void SpeakChina(string ggg)
        {
            //SpVoice Voice = new SpVoice();
            synth.SelectVoice("Microsoft Lili");
            //Voice.Speak(ggg, SpFlags);
            synth.SpeakAsync(ggg);
            //String speechPeople = synth.Voice;
            //使用 synth 设置朗读音量 [范围 0 ~ 100]
            // synth.Volume = 80;
            //使用 synth 设置朗读频率 [范围 -10 ~ 10]
            //      synth.Rate = 0;
            //使用synth 合成 wav 音频文件:
            //synth.SetOutputToWaveFile(string path);
        }
        public void SpeakEnglish(string ggg)
        {
            //SpVoice Voice = new SpVoice();
            synth.SelectVoice("VW Julie");
            synth.Speak(ggg); //ggg为要合成的内容
        }
        public int m
        {
            get
            {
                return synth.Volume;
            }
            set
            {
                synth.Volume = value;
            }
        }
        public int n
        {
            get
            {
                return synth.Rate;
            }
            set
            {
                synth.Rate = value;
            }
        }
}

TTS朗读软件调用Microsoft Speech Platform

1.支持Microsoft Speech Platform的TTS朗读软件

介绍过的BalabolkaTextToWav都支持Microsoft Speech Platform,可以直接使用。

  • Balabolka和TextToWav都是32位程序,所以Microsoft Speech Platform Runtime需要安装32位的,无论系统是否是64位;
  • TextToWav官方说明是支持Microsoft Speech Platform 10,但测试Version 11也完美支持。

2.不支持Microsoft Speech Platform的TTS朗读软件

也就是早期只支持SAPI4和SAPI5的TTS朗读软件,比如DSpeech朗读女。这类软件就只能更改Microsoft Speech Platform语音库的注册信息了。

以Windows 7安装Microsoft Huihui为例

  1. 执行完整“Microsoft Speech Platform 11安装”步骤(Dspeech和朗读女也是32位);
  2. 64位Windows7打开注册表,找到

    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Speech
    HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Speech Server

    分别导出(32为应该在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\);

  3. 编辑Speech Server.reg
    • 将全部“Speech Server\v11.0”替换为“Speech”;
    • 将全部“Speech Server\\v11.0”替换为“Speech”。
  4. 依次导入Speech Server.reg和Speech.reg,中间提示错误信息不用理会。

这样在Dspeech和朗读女中已经可以正确显示和调用Microsoft Huihui朗读文本了。
同时,这样修改后,支持Microsoft Speech Platform的TTS朗读软件并不受影响。

以上两种方法取决于TTS朗读软件对Microsoft Speech Platform的支持情况,但系统的控制面板并不会显示有新的语音库可选,只能使用TTS朗读软件。
其他收费TTS朗读软件没做测试。
如果你使用的是Neospeech等高级语音库,没有必要用微软的,微软的只是一个简化版语音库,但是是完全免费。

http://blog.sina.com.cn/s/blog_5de73d0b01017go4.html