• 大小: 5.73MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-29
  • 语言: 其他
  • 标签: 语音识别  

资源简介

讯飞语音实时在线识别,百度语音实时在线识别

资源截图

代码片段和文件信息

using NAudio.Wave;
using SoundToTextDemo.Model;
using SoundToTextDemo.Utility;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SoundToTextDemo
{
    public partial class BaiDuMainForm : Form
    {
        private WaveIn wis = null;
        private WaveFormat pcmconfig = null;
        private bool pullmark = false;
        /// 
        /// 语音队列
        /// 

        private static readonly ConcurrentQueue cq = new ConcurrentQueue();
        //当前的互斥锁
        private static readonly Testcode code = new Testcode();
        private static object mutext = new object();
        public BaiDuMainForm()
        {
            InitializeComponent();
            int audio_rate = 16000;// 设置成8000会出现不是说话的内容
            int audio_byte = 16;
            int audio_channle = 1;
            this.pcmconfig = new WaveFormat(audio_rate audio_byte audio_channle);
            if (this.wis == null)
            {
                this.wis = new WaveIn();
            }
            this.wis.DataAvailable += wis_DataAvailable;
          
            
        }
        private void wis_DataAvailable(object sender WaveInEventArgs e)
        {
            if (e.Buffer != null && e.BytesRecorded > 0)
            {
                cq.Enqueue(e.Buffer);
            }
        }

        private void btn_start_Click(object sender EventArgs e)
        {
            try
            {
                btn_start.Enabled = false;
                btn_stop.Enabled = true;
                this.wis.DeviceNumber = 0;
                this.wis.WaveFormat = this.pcmconfig;
                this.wis.BufferMilliseconds = 6000;
                // this.bytelength = (uint)((float)(audio_rate * (audio_byte / 8)) * ((float)this.wis.BufferMilliseconds / 1000f));
                this.wis.StartRecording();
                pullmark = true;
                Task.Factory.StartNew(() =>
                {
                    while (pullmark)
                    {
                        if (!cq.IsEmpty)
                        {
                            ReciveDataModel redata = null;
                            byte[] localValue;
                            cq.TryDequeue(out localValue);
                            DataSendModel model = new DataSendModel(DataEnum.FormatEnum.wav 16000 ConfigHelper.Instance.Token Guid.NewGuid().ToString(“N“));
                            model.len = (int)localValue.Length;
                            model.speech = Convert.Tobase64String(localValue);
                            string poststr = Newtonsoft.Json.JsonConvert.Serializeobject(model);
                            string str = code.GetResponseStr(ConfigHelper.Instance.ApiUrl poststr);
          

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

     文件        497  2016-09-21 11:57  SoundToTextDemo\SoundToTextDemo\App.config

     文件       4588  2016-09-21 14:17  SoundToTextDemo\SoundToTextDemo\BaiDuMainForm.cs

     文件       6385  2016-06-17 16:36  SoundToTextDemo\SoundToTextDemo\BaiDuMainForm.Designer.cs

     文件       5817  2016-06-17 16:36  SoundToTextDemo\SoundToTextDemo\BaiDuMainForm.resx

     文件    6238674  2016-09-21 11:22  SoundToTextDemo\SoundToTextDemo\bin\Debug\msc.log

     文件   10484951  2016-06-17 17:01  SoundToTextDemo\SoundToTextDemo\bin\Debug\msc_2016617_1713.log

     文件   10484934  2016-09-20 15:29  SoundToTextDemo\SoundToTextDemo\bin\Debug\msc_2016920_152927.log

     文件        140  2016-09-21 11:22  SoundToTextDemo\SoundToTextDemo\bin\Debug\msc_assist.dat

     文件     364544  2015-04-13 09:51  SoundToTextDemo\SoundToTextDemo\bin\Debug\msc_old.dll

     文件     471040  2016-06-17 14:02  SoundToTextDemo\SoundToTextDemo\bin\Debug\NAudio.dll

     文件     940967  2016-06-17 14:02  SoundToTextDemo\SoundToTextDemo\bin\Debug\NAudio.xml

     文件     485888  2016-06-17 14:02  SoundToTextDemo\SoundToTextDemo\bin\Debug\Newtonsoft.Json.dll

     文件     516075  2016-06-17 14:02  SoundToTextDemo\SoundToTextDemo\bin\Debug\Newtonsoft.Json.xml

     文件      44544  2016-09-21 12:21  SoundToTextDemo\SoundToTextDemo\bin\Debug\SoundToTextDemo.exe

     文件        497  2016-09-21 11:57  SoundToTextDemo\SoundToTextDemo\bin\Debug\SoundToTextDemo.exe.config

     文件     108032  2016-09-21 12:21  SoundToTextDemo\SoundToTextDemo\bin\Debug\SoundToTextDemo.pdb

     文件      24224  2016-09-21 12:21  SoundToTextDemo\SoundToTextDemo\bin\Debug\SoundToTextDemo.vshost.exe

     文件        497  2016-09-21 11:57  SoundToTextDemo\SoundToTextDemo\bin\Debug\SoundToTextDemo.vshost.exe.config

     文件        490  2015-11-13 10:24  SoundToTextDemo\SoundToTextDemo\bin\Debug\SoundToTextDemo.vshost.exe.manifest

     文件     278528  2015-04-14 20:14  SoundToTextDemo\SoundToTextDemo\bin\Debug\speex.dll

     文件    1099666  2016-06-17 17:01  SoundToTextDemo\SoundToTextDemo\bin\Debug.rar

     文件     471040  2016-06-17 14:02  SoundToTextDemo\SoundToTextDemo\bin\Release\NAudio.dll

     文件     940967  2016-06-17 14:02  SoundToTextDemo\SoundToTextDemo\bin\Release\NAudio.xml

     文件     485888  2016-06-17 14:02  SoundToTextDemo\SoundToTextDemo\bin\Release\Newtonsoft.Json.dll

     文件     516075  2016-06-17 14:02  SoundToTextDemo\SoundToTextDemo\bin\Release\Newtonsoft.Json.xml

     文件      42496  2016-09-21 14:14  SoundToTextDemo\SoundToTextDemo\bin\Release\SoundToTextDemo.exe

     文件        497  2016-09-21 11:57  SoundToTextDemo\SoundToTextDemo\bin\Release\SoundToTextDemo.exe.config

     文件      85504  2016-09-21 14:14  SoundToTextDemo\SoundToTextDemo\bin\Release\SoundToTextDemo.pdb

     文件      24216  2016-09-21 14:16  SoundToTextDemo\SoundToTextDemo\bin\Release\SoundToTextDemo.vshost.exe

     文件        497  2016-09-21 11:57  SoundToTextDemo\SoundToTextDemo\bin\Release\SoundToTextDemo.vshost.exe.config

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

评论

共有 条评论