资源简介

本案例调用科大讯飞开放接口实现了语音合成,识别,录音,以及语音朗读功能。有界面,可运行。

资源截图

代码片段和文件信息

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 iFlyDotNet;
using NAudio.Wave;
using Microsoft.DirectX.DirectSound;
namespace demoTTS
{
    public partial class Form1 : Form
    {

        bool luyin = true;
        WaveInStream wi;
        private WaveFileWriter writer;
        iFlyISR isr;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            button1.Enabled = false;
            string c1 = “appid=53f4099e“;
            iFlyTTS tts = new iFlyTTS(c1);
            tts.Finished += tts_Finished;
            tts.vol = enuVol.x_loud;
            tts.speed = enuSpeed.medium;
            tts.speeker = (enuSpeeker)comboBox1.SelectedIndex;
            tts.MultiSpeek(textBox1.Text “audio.wav“);
            button1.Enabled = true;
        }

        void tts_Finished(object sender iFlyTTS.JinDuEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(e.AllP.ToString());
        }

        private void Form1_Load(object sender EventArgs e)
        {
            foreach (string s in Enum.GetNames(typeof(enuSpeeker)))
                comboBox1.Items.Add(s);
            comboBox1.SelectedIndex = 0;
        }

        private void button2_Click(object sender EventArgs e)
        {
            button2.Enabled = false;
            string c1 = “server_url=dev.voicecloud.cnappid=53f4099etimeout=10000“;
            string c2 = “sub=iatssm=1auf=audio/L16;rate=16000aue=speexent=sms16krst=plain“;
            isr = new iFlyISR(c1 c2);
            isr.DataArrived += new EventHandler(asr_DataAvailable);
            isr.ISREnd += new EventHandler(Isr_ISREnd);            
            isr.Audio2TxtAsync(“audio.wav“ null);
        }

        void Isr_ISREnd(object sender EventArgs e)
        {
            button2.Invoke(new MethodInvoker(delegate() { button2.Enabled = true; }));
        }

        void asr_DataAvailable(object sender iFlyISR.DataArrivedEventArgs e)
        {
            textBox1.Invoke(new MethodInvoker(delegate() { textBox1.AppendText(e.result); }));
        }

        private void button3_Click(object sender EventArgs e)
        {
            if (luyin)
            {
                luyin = false;
                //wi = new WaveInStream(0 new WaveFormat(16000 16 1) this);
                //wi.DataAvailable += new EventHandler(wi_DataAvailable);
                //writer = new WaveFileWriter(“audio.wav“ wi.WaveFormat);
                //wi.StartRecording();
                string c1 = “server_url=dev.voicecloud.cnappid=53f4099etimeout=10000“;
                string c2 = “sub=iatssm=1auf=audio/L16;rate=16000aue=speexent=sms16krst=plain“;
         

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

     文件        159  2013-01-23 10:59  iFlyTTS\demoTTS\app.config

     文件     745004  2014-08-20 16:10  iFlyTTS\demoTTS\bin\Debug\audio.wav

     文件      11776  2016-10-08 19:25  iFlyTTS\demoTTS\bin\Debug\demoTTS.exe

     文件        159  2013-01-23 10:59  iFlyTTS\demoTTS\bin\Debug\demoTTS.exe.config

     文件      34304  2016-10-08 19:25  iFlyTTS\demoTTS\bin\Debug\demoTTS.pdb

     文件      11600  2016-10-08 19:25  iFlyTTS\demoTTS\bin\Debug\demoTTS.vshost.exe

     文件        159  2013-01-23 10:59  iFlyTTS\demoTTS\bin\Debug\demoTTS.vshost.exe.config

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

     文件          8  2013-01-14 13:50  iFlyTTS\demoTTS\bin\Debug\f2973f3705180a753e51c71480ee645e\usr.dat

     文件      78336  2016-10-08 19:25  iFlyTTS\demoTTS\bin\Debug\iFlyDotNet.dll

     文件      34304  2016-10-08 19:25  iFlyTTS\demoTTS\bin\Debug\iFlyDotNet.pdb

     文件     243496  2008-05-17 11:14  iFlyTTS\demoTTS\bin\Debug\Microsoft.DirectX.DirectSound.dll

     文件     326440  2008-05-17 11:14  iFlyTTS\demoTTS\bin\Debug\Microsoft.DirectX.dll

     文件     364544  2011-08-18 10:43  iFlyTTS\demoTTS\bin\Debug\msc.dll

     文件        140  2016-10-08 19:26  iFlyTTS\demoTTS\bin\Debug\msc_assist.dat

     文件     310272  2008-06-26 06:59  iFlyTTS\demoTTS\bin\Debug\NAudio.dll

     文件     278528  2011-09-15 09:58  iFlyTTS\demoTTS\bin\Debug\speex.dll

     文件       4455  2013-01-23 10:59  iFlyTTS\demoTTS\demoTTS.csproj

     文件       6144  2013-01-14 17:51  iFlyTTS\demoTTS\demoTTS.v11.suo

     文件       4048  2014-08-20 15:57  iFlyTTS\demoTTS\Form1.cs

     文件       5214  2011-11-25 16:23  iFlyTTS\demoTTS\Form1.Designer.cs

     文件       5817  2011-11-25 16:23  iFlyTTS\demoTTS\Form1.resx

     文件       3316  2016-10-08 19:25  iFlyTTS\demoTTS\obj\x86\Debug\demoTTS.csproj.FileListAbsolute.txt

     文件        975  2014-08-20 17:10  iFlyTTS\demoTTS\obj\x86\Debug\demoTTS.csproj.GenerateResource.Cache

     文件      26250  2014-08-20 17:10  iFlyTTS\demoTTS\obj\x86\Debug\demoTTS.csprojResolveAssemblyReference.cache

     文件      11776  2016-10-08 19:25  iFlyTTS\demoTTS\obj\x86\Debug\demoTTS.exe

     文件        180  2016-10-08 19:25  iFlyTTS\demoTTS\obj\x86\Debug\demoTTS.Form1.resources

     文件      34304  2016-10-08 19:25  iFlyTTS\demoTTS\obj\x86\Debug\demoTTS.pdb

     文件        180  2016-10-08 19:25  iFlyTTS\demoTTS\obj\x86\Debug\demoTTS.Properties.Resources.resources

     文件       2152  2016-10-08 19:25  iFlyTTS\demoTTS\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

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

评论

共有 条评论