zoukankan      html  css  js  c++  java
  • C# 导入speech lib,阅读文本信息,support text to speech

    1. 第一步,需要三个dll

    using System.Speech.Synthesis;
    using System.Speech.Recognition;
    using SpeechLib;

    SpeechLib的导入有点不太好找,参考下图(图片排版不太好)

     2.准备个测试demo

    ///获取计算机本身自带的语言系统

    public static List<string> GetInstalledVoiceIdList()
            {
                List<string> resultList = new List<string>();
                try
                {
                    SpVoice voice = new SpVoice();
                    ISpeechObjectTokens ss = voice.GetVoices(string.Empty, string.Empty);
                    if (ss != null && ss.Count > 0)
                    {
                        for (int i = 0; i < ss.Count; i++)
                        {
                            resultList.Add(ss.Item(i).Id);
                        }
                    }
                }
                catch (Exception)
                {
                }
                return resultList;
            }

    //指定语言Speak方法中第二个参数,指定语言,从上段代码中获取到中文系统的index 是3,所以将传递3进行阅读

    voice.Speak(txt.Text, GetInstalledVoiceIdList()[3]);

  • 相关阅读:
    记一次腾讯云服务器被黑
    mui学习笔记
    Maven(二)名词、命令、仓库、依赖、私服
    MySQL触发器
    SSL证书安装(Tomcat)腾讯云服务器
    Maven(一)简介安装
    HTML多图片压缩上传
    Gradle(一)安装配置
    dubbo本地服务化实现(dubbo三)
    Object is not a function
  • 原文地址:https://www.cnblogs.com/fool-jingqiu/p/11303866.html
Copyright © 2011-2022 走看看