• 大小: 81KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-15
  • 语言: C#
  • 标签: C#  朗读文本  

资源简介

研究了一下C#的文本语音朗读,写了一个小demo,在32位win7下可以运行朗读,还可以将朗读保存WAV,,,大家可以参考参考

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DotNetSpeech;

namespace SpeechApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        /// 
        /// 朗读
        /// 

        /// 
        /// 
        private void ButtonSynthesis_Click(object sender EventArgs e)
        {
            try
            {
                DotNetSpeech.SpeechVoiceSpeakFlags SSF = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;
                DotNetSpeech.SpVoice vo = new SpVoiceClass();
                vo.Speak(this.textBox1.Text SSF);
                
            }
            catch (System.Exception ec)
            {
                MessageBox.Show(ec.ToString() “SpeechApp“ MessageBoxButtons.OK System.Windows.Forms.MessageBoxIcon.Error);
            }
        }

        /// 
        /// 生成声音文件
        /// 

        /// 
        /// 
        private void ButtonTTStoWave_Click(object sender EventArgs e)
        {
            try
            {
                DotNetSpeech.SpeechVoiceSpeakFlags SSF = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;
                DotNetSpeech.SpVoice vo = new SpVoiceClass();
                System.Windows.Forms.SaveFileDialog SFD = new System.Windows.Forms.SaveFileDialog();
                SFD.Filter = “All files (*.*)|*.*|wav files (*.wav)|*.wav“;
                SFD.title = “Save to a wav file“;
                SFD.FilterIndex = 2;
                SFD.RestoreDirectory = true;
                if (SFD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    DotNetSpeech.SpeechStreamFileMode SSFM = DotNetSpeech.SpeechStreamFileMode.SSFMCreateForWrite;
                    DotNetSpeech.SpFileStream SFS = new DotNetSpeech.SpFileStreamClass();
                    SFS.Open(SFD.FileName SSFM false);
                    vo.AudioOutputStream = SFS;
                    vo.Speak(this.textBox1.Text SSF);
                    vo.WaitUntilDone(System.Threading.Timeout.Infinite);
                    SFS.Close();
                }
            }
            catch (System.Exception ec)
            {
                MessageBox.Show(ec.ToString() “SpeechApp“ MessageBoxButtons.OK System.Windows.Forms.MessageBoxIcon.Error);
            }
        }





    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     163840  2017-02-22 14:32  SpeechApp\SpeechApp\bin\Debug\DotNetSpeech.dll

     文件       9728  2017-02-22 16:05  SpeechApp\SpeechApp\bin\Debug\SpeechApp.exe

     文件      26112  2017-02-22 16:05  SpeechApp\SpeechApp\bin\Debug\SpeechApp.pdb

     文件      11608  2017-02-22 16:08  SpeechApp\SpeechApp\bin\Debug\SpeechApp.vshost.exe

     文件        490  2010-03-17 22:39  SpeechApp\SpeechApp\bin\Debug\SpeechApp.vshost.exe.manifest

     文件       2701  2017-02-22 16:05  SpeechApp\SpeechApp\Form1.cs

     文件       3463  2017-02-22 16:05  SpeechApp\SpeechApp\Form1.Designer.cs

     文件       5817  2017-02-22 16:05  SpeechApp\SpeechApp\Form1.resx

     文件       6278  2017-02-22 16:05  SpeechApp\SpeechApp\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        566  2017-02-22 16:05  SpeechApp\SpeechApp\obj\x86\Debug\GenerateResource-ResGen.read.1.tlog

     文件        922  2017-02-22 16:05  SpeechApp\SpeechApp\obj\x86\Debug\GenerateResource-ResGen.write.1.tlog

     文件       2714  2017-02-22 16:01  SpeechApp\SpeechApp\obj\x86\Debug\ResolveAssemblyReference.cache

     文件       1083  2017-02-22 16:08  SpeechApp\SpeechApp\obj\x86\Debug\SpeechApp.csproj.FileListAbsolute.txt

     文件       9728  2017-02-22 16:05  SpeechApp\SpeechApp\obj\x86\Debug\SpeechApp.exe

     文件        180  2017-02-22 16:05  SpeechApp\SpeechApp\obj\x86\Debug\SpeechApp.Form1.resources

     文件      26112  2017-02-22 16:05  SpeechApp\SpeechApp\obj\x86\Debug\SpeechApp.pdb

     文件        180  2017-02-22 16:01  SpeechApp\SpeechApp\obj\x86\Debug\SpeechApp.Properties.Resources.resources

     文件        490  2017-02-22 15:56  SpeechApp\SpeechApp\Program.cs

     文件       1370  2017-02-22 15:56  SpeechApp\SpeechApp\Properties\AssemblyInfo.cs

     文件       2869  2017-02-22 15:56  SpeechApp\SpeechApp\Properties\Resources.Designer.cs

     文件       5612  2017-02-22 15:56  SpeechApp\SpeechApp\Properties\Resources.resx

     文件       1095  2017-02-22 15:56  SpeechApp\SpeechApp\Properties\Settings.Designer.cs

     文件        249  2017-02-22 15:56  SpeechApp\SpeechApp\Properties\Settings.settings

     文件       3816  2017-02-22 16:01  SpeechApp\SpeechApp\SpeechApp.csproj

     文件        869  2017-02-22 15:56  SpeechApp\SpeechApp.sln

    ..A..H.     19456  2017-02-22 16:09  SpeechApp\SpeechApp.suo

     目录          0  2017-02-22 15:56  SpeechApp\SpeechApp\obj\x86\Debug\TempPE

     目录          0  2017-02-22 16:05  SpeechApp\SpeechApp\obj\x86\Debug

     目录          0  2017-02-22 16:01  SpeechApp\SpeechApp\bin\Debug

     目录          0  2017-02-22 15:56  SpeechApp\SpeechApp\obj\x86

............此处省略8个文件信息

评论

共有 条评论