Text To Speech
- Shin Yoonah, Yoonah
- 2022년 7월 25일
- 1분 분량
최종 수정일: 2022년 8월 11일
Today, I set the "TTS" function in my app!!

First, accessing the "TextToSpeech" function provided in android

Declaring TextToSpeech: control the "TTS" android library
Declaring TTSUtteranceProgressListener: listener class that receive the station of speech (start, error, end)
Second, create TextToSpeech instance in "onCreate" process

Initializing preferences -> set to Korean speech
Third, speechOut method to print out text to speech

AudioManager: get volume information from audio preferences
maxVolume: get possible max volume to print out
curVolume: get current volume
am.setStreamVolume: set volume for the maximum volume
Fourth, if-else statement produced by the version of android SDK

One way implements when android SDK version is over 11
Other way implements when android SDK version is under 11

After speakApi13 implements, the volume will be reset as a current volume
Fifth, the method of printing out text to speech

Final result: Let's see how it works!!
Comments