C# Winform SpeechSynthesizer 类是 .NET Framework 中的一个类,它位于 System.Speech.Synthesis 命名空间中,用于将文本转换为语音输出。
C# Winform System.Speech.Synthesis 引入
·
using System;
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;
using System.Speech.Synthesis;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
SpeechSynthesizer speech = new SpeechSynthesizer();
string words;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
words = textBox1.Text;
}
else
{
words = "默认内容";
}
//同步读取
speech.Speak(words);
}
}
}
***如 SpeechSynthesizer speech = new SpeechSynthesizer();报错时通过解决方案资源管理器 中找到引用 右键资源管理器 找到System.Speech再手动引入
更多推荐
所有评论(0)