基本信息
源码名称:C#调用科大讯飞语音转写语音合成的接口
源码大小:1.50M
文件格式:.rar
开发语言:C#
更新时间:2017-11-22
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
非常好用 我就不贴图了
非常好用 我就不贴图了
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.cn,appid=53f4099e,timeout=10000";
string c2 = "sub=iat,ssm=1,auf=audio/L16;rate=16000,aue=speex,ent=sms16k,rst=plain";
isr = new iFlyISR(c1, c2);
isr.DataArrived = new EventHandler<iFlyISR.DataArrivedEventArgs>(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<WaveInEventArgs>(wi_DataAvailable);
//writer = new WaveFileWriter("audio.wav", wi.WaveFormat);
//wi.StartRecording();
string c1 = "server_url=dev.voicecloud.cn,appid=53f4099e,timeout=10000";
string c2 = "sub=iat,ssm=1,auf=audio/L16;rate=16000,aue=speex,ent=sms16k,rst=plain";
isr = new iFlyISR(c1, c2);
isr.DataArrived = new EventHandler<iFlyISR.DataArrivedEventArgs>(asr_DataAvailable);
isr.ISREnd = new EventHandler(Isr_ISREnd);
isr.StartRecoding();
button3.Text = "停止录音";
}
else
{
luyin = true;
//wi.StopRecording();
//wi.Dispose();
//wi = null;
//writer.Close();
//writer.Dispose();
//writer = null;
isr.StopRecoding();
button3.Text = "开始录音";
}
}
void wi_DataAvailable(object sender, WaveInEventArgs e)
{
writer.WriteData(e.Buffer, 0, e.BytesRecorded);
}
private void button4_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer sp = new System.Media.SoundPlayer("audio.wav");
sp.Play();
}
}
}