1. 程式人生 > >MainForm介面點選按鈕讀特定文字

MainForm介面點選按鈕讀特定文字

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 WindowsFormsAppOne
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            label1.Text = "歡迎入住!";
        }

        private void CheckInButton_Click(object sender, EventArgs e)
        {
            SpeechVoiceSpeakFlags flag = SpeechVoiceSpeakFlags.SVSFlagsAsync;
            SpVoice voice = new SpVoice();
            String voice_txt = label1.Text;
            voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0);
            voice.Speak(voice_txt,flag);
        }
    }
}

如需轉載,請註明出處!