• C# 语音技术


    1、使用DotNetSpeech.dll。

    /// <summary>

    /// 朗读
    /// </summary>
    /// <param name="text">要朗读的文本</param>
    private void Read(string text)
    {
        SpVoice sv = new SpVoice();
        sv.Rate = 0;//设置朗读速度
        SpeechVoiceSpeakFlags SSF = SpeechVoiceSpeakFlags.SVSFlagsAsync;
        sv.Speak(text, SSF);
    }
    /// <summary>
    /// 生成声音文件
    /// </summary>
    /// <param name="text">要朗读的文本</param>
    /// <param name="filePath">生成声音文件的路径</param>
    /// <param name="fileName">生成声音文件的名称</param>
    private void CreateFile(string text, string filePath,string fileName)
    {
        if (!Directory.Exists(filePath))
            Directory.CreateDirectory(filePath);
        SpVoice sv = new SpVoice();
        SpeechVoiceSpeakFlags SVSF = SpeechVoiceSpeakFlags.SVSFlagsAsync;
        SpeechStreamFileMode SSFM = SpeechStreamFileMode.SSFMCreateForWrite;
        SpFileStream SFS = new SpFileStream();
        SFS.Open(filePath+fileName, SSFM, false);
        sv.AudioOutputStream = SFS;
        sv.Speak(text, SVSF);
        sv.WaitUntilDone(System.Threading.Timeout.Infinite);
        SFS.Close();
    }

    2、 使用System.Speech

    SpeechSynthesizer ss = new SpeechSynthesizer();
    //播放
    if (ss != null)
    {
        ss.Dispose();
        ss.SpeakAsync("朗读的文本");
    }
    //暂停
    if (ss.State == SynthesizerState.Speaking)
    {
        ss.Pause();
    }
    //继续
    if (reader.State == SynthesizerState.Paused)
    {
        ss.Resume();
    }
    //停止
    if (ss != null)
    {
        ss.Dispose();

    文字识别  ocr组件

  • 相关阅读:
    static和final
    java面向对象白话解说
    方法
    数组
    JDK的安装和java程序的开发步骤以及环境变量配置
    VS2010 根据模型生成数据库 打开edmx.sql文件时 vs出现无响应的解决方案
    js简易写法
    .NET程序性能优化基本要领
    数据采集类
    ASP.NET MVC 3 配置EF自动生成模型
  • 原文地址:https://www.cnblogs.com/siyunianhua/p/11947445.html
Copyright © 2020-2023  润新知