텍스트 일기 귀찮을 때 쓰면 좋을 듯.

TTS 사용하기 위해선 프로젝트에 참조 관리자를 통해서 참조 추가해야 함.

 

예제 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Speech.Synthesis;
 
namespace TextToSpeech
{
    public class TextReading : IDisposable
    {
        private SpeechSynthesizer m_speechSynthesizer = new SpeechSynthesizer();
        public void AsyncTextSpeak(string text)
        {
            if (string.IsNullOrEmpty(text))
                return;
 
            m_speechSynthesizer.SpeakAsync(text);
        }
 
        public void PauseTextSpeak()
        {
            if (m_speechSynthesizer.State == SynthesizerState.Speaking) {
                m_speechSynthesizer.Pause();
            }
        }
 
        public void ResumeTextSpeak()
        {
            if (m_speechSynthesizer.State == SynthesizerState.Paused) {
                m_speechSynthesizer.Resume();
            }
        }
 
        public void Dispose()
        {
            m_speechSynthesizer.Dispose();
        }
    }
}
cs

 

 

 

반응형