• 语音播报


    相关: http://blog.sina.com.cn/s/blog_45c379c001016d7u.html

     DLL     :

    备注:

             1、运行TTSrepair.exe,修护系统语音功能。(确保系统语音相关组件能正常使用)

             2、添加 Interop.SpeechLib.dll 和 SpeechLib.dll
            3、如无语音库,请安装“girl_xialkun.exe”(为一种语音库)
    下载地址:http://download.iciba.com/pwpe/girl_xiaokun.exe

    注:win7系统默认语音库为microsoft lily chinese,阉割版的系统没有相关功能

    using SpeechLib;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using SAMPLETTSENGLib;
    
    
    namespace 语音播报
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                
                //检查
                if (comboBox1.SelectedIndex < 0)
                {
                    MessageBox.Show("请选择语音库!", "Message", MessageBoxButtons.OK);
                    return;
                }
                if (textBox1.Text == "")
                {
                    MessageBox.Show("请在文本中输入将要读取的信息!", "Message", MessageBoxButtons.OK);
                    return;
                    
                }
                
                //执行朗读
                    SpeechVoiceSpeakFlags flag = SpeechVoiceSpeakFlags.SVSFlagsAsync;
                    SpVoice sv = new SpVoice();
                    //用第3个语音库,根据系统所安装语音库进行选择
                    sv.Voice = sv.GetVoices().Item(comboBox1.SelectedIndex);
                    sv.Speak(textBox1.Text, flag);//播放
    
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                //将所有语音库加载到combox
                List<string> lst = new List<string>();
                ISpeechObjectTokens obj = new SpVoice().GetVoices();
                for (int i = 0; i < obj.Count; i++)
                { 
                    comboBox1.Items.Add(obj.Item(i).GetDescription());
    
                }
                
            }
        }
    }
    

      

  • 相关阅读:
    初识Mybatis
    Servlet基础
    JSP数据交互(二)
    JSP九大内置对象
    JSP数据交互(一)
    动态网页开发基础
    使用jquery操作dom
    jQuery中的事件与动画
    jQuery选择器
    [leetcode]198. House Robber小偷抢钱
  • 原文地址:https://www.cnblogs.com/lhlong/p/5075842.html
Copyright © 2020-2023  润新知