zoukankan      html  css  js  c++  java
  • 在.Net中用TTS

    微软的SAPI(Speech Application Programming Interface)提供了强大的Text To Speech接口,而且支持自动化。这样可以在.Net的程序中引入该COM组件:
    先添加SpeechLib的引用,在系统盘Program Files\Common Files\Microsoft Shared\Speech目录中找到sapi.dll。
    在代码中调用SpVoiceClass类的Speak方法可以实现简单的句子发言:
    ISpeechVoice v=new SpVoiceClass();
    v.Speak(txtSpeak, SpeechVoiceSpeakFlags.SVSFDefault);
    还可以用SpFileStream创建音频流,如下面程序可以把文本“读到”wav文件中:
    //Declare the SpVoice object. 
    ISpeechVoice v=new SpVoiceClass();
    //Create a wave stream
    SpFileStream s = new SpFileStream();
    //Create a new .wav file for writing.
    s.Open("out.wav", SpeechStreamFileMode.SSFMCreateForWrite, false);
    //Set the .wav file stream as the output for the Voice object
    v.AudioOutputStream = s;
    //Call the Speak method now will send the output to the .wav file.
    v.Speak(txtSpeak, SpeechVoiceSpeakFlags.SVSFDefault);
    //Close the file
    s.Close();
    这只是很浅显的一些应用。Windows(我的是英文版win2003)自带的SAPI不支持中文,MS称5.1版本的SAPI可以支持中日英三国语言,可以到MS网站上免费下载。继续研究中……
  • 相关阅读:
    JMeter学习(二十三)关联
    最常用的DOS命令
    不同类型的操作系统
    分级存储管理的四大优点
    软件工程中数据库设计
    PPP(点对点协议(Point to Point Protocol)
    关键路径法
    什么是鲁棒性测试
    何为蠕虫病毒
    临界区
  • 原文地址:https://www.cnblogs.com/wonderow/p/201503.html
Copyright © 2011-2022 走看看