[C#] 글 읽어주는 메모장 만들기(Application to speak the text written in the textbox using C#.Net)
예전에 똑같은 프로그램이 있었죠.
"ba bo ya(바보야)" 뭐 이런거 적어서 읽게 만들고 -ㅁ-
C#으로 간단히 구현해 볼 수 있어요. 라이브러리를 쓰는 거니깐요ㅎ
우선 폼에다가 텍스트박스랑 버튼 세개를 추가 해 줍니다.
그리고 텍스트 박스 설정 중 Dock 은 "Top"으로 Multiline은 "True"로 바꿔줍니다.
그런다음 Menu -> Select 'AddReference' -> COM tab에서
Microsoft Speech Object Livrary'를 선택하여 줍니다~
그런다음 소스코드에 using SpeechLib을 추가 해 주겠지요~
Code:
using System;
using System.Windows.Forms;
using SpeechLib;//include this namespace
namespace TextSpeaker
{
public partial class TextSpeakerForm : Form
{
public TextSpeakerForm()
{
InitializeComponent();
}
private void btnSpeak_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim().Length > 0)
{
SpVoice obj = new SpVoice();
obj.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFDefault);
}
MessageBox.Show(“Plz. write some text in the TextBox”,”Info.”,MessageBoxButtons.OK,MessageBoxIcon.Information);
}
private void btnClear_Click(object sender, EventArgs e)
{
textBox1.Text = “”;
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Output:
글씨를 적은 다음 'speak' 버튼을 눌러보세요~ (스피커 켜야됨)
이것도 응용하면 재밌는거 많이 만들수 있겠죵 ㅋㅋ