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]);

  • 相关阅读:
    poj 1789 Truck History(最小生成树)
    POJ 3096 Surprising Strings(STL map string set vector)
    hdu 1412 (STL list)
    POJ 1552 Doubles (C++ STL set使用)
    poj 水题系列
    洛谷P4859 已经没有什么好害怕的了
    CF1228E Another Filling the Grid
    二项式反演
    AT [ABC177F] I hate Shortest Path Problem
    [NOI2020]制作菜品
  • 原文地址:https://www.cnblogs.com/fool-jingqiu/p/11303866.html
Copyright © 2011-2022 走看看