将文字转换成声音的程序没出错,但不能发出声音
发表在C#图书答疑
2015-09-01
是否精华
是
否
版块置顶:
是
否
将文字转换成声音的程序没出错,但不能发出声音
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 System.Speech;
using System.Speech.Synthesis;
namespace 声音读卡器
{
public partial class Form1 : Form
{
private SpeechSynthesizer ss;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
ss = new SpeechSynthesizer();
}
private void button1_Click(object sender, EventArgs e)
{
ss.Rate = trackBarVolumn.Value;
ss.Volume = trackBarVolumn.Value;
ss.SpeakAsync(txtMsg.Text);
}
private void button2_Click(object sender, EventArgs e)
{
ss.Pause();
}
private void button3_Click(object sender, EventArgs e)
{
ss.Resume();
}
private void button4_Click(object sender, EventArgs e)
{
SpeechSynthesizer ss = new SpeechSynthesizer();
ss.Rate = trackBarVolumn.Value;
ss.Volume = trackBarVolumn.Value;
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Wave Files|*.wav";
ss.SetOutputToWaveFile(sfd.FileName);
ss.Speak(txtMsg.Text);
ss.SetOutputToDefaultAudioDevice();
MessageBox.Show("完成录音~~", "提示");
}
private void button5_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
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 System.Speech;
using System.Speech.Synthesis;
namespace 声音读卡器
{
public partial class Form1 : Form
{
private SpeechSynthesizer ss;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
ss = new SpeechSynthesizer();
}
private void button1_Click(object sender, EventArgs e)
{
ss.Rate = trackBarVolumn.Value;
ss.Volume = trackBarVolumn.Value;
ss.SpeakAsync(txtMsg.Text);
}
private void button2_Click(object sender, EventArgs e)
{
ss.Pause();
}
private void button3_Click(object sender, EventArgs e)
{
ss.Resume();
}
private void button4_Click(object sender, EventArgs e)
{
SpeechSynthesizer ss = new SpeechSynthesizer();
ss.Rate = trackBarVolumn.Value;
ss.Volume = trackBarVolumn.Value;
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Wave Files|*.wav";
ss.SetOutputToWaveFile(sfd.FileName);
ss.Speak(txtMsg.Text);
ss.SetOutputToDefaultAudioDevice();
MessageBox.Show("完成录音~~", "提示");
}
private void button5_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}