TTS Speech
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 SpeechLib;
namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// SpVoice voice = new SpVoice();
//voice.Rate = 1; //语速 [-10,10]
//voice.Volume = 100; //语量[0,100]
//voice.Voice = voice.GetVoices().Item(0); //语音库
SpVoiceClass voice = new SpVoiceClass(); //右键点击“SpeechLib.dll”导入库,选择“属性”,修改“嵌入式互操作类型”为 false 解决嵌入式操作问题
foreach (ISpeechObjectToken s in voice.GetVoices())
{
listBox1.Items.Add(s.Id);
}
voice.Speak("测试文字",SpeechVoiceSpeakFlags.SVSFlagsAsync);
}
}
}
参考:https://www.cnblogs.com/stoneniqiu/p/3871754.html