TextToSpeech QML Type
TextToSpeech 유형은 텍스트 음성 변환 엔진에 대한 액세스를 제공합니다. 더 보기...
| Import Statement: | import QtTextToSpeech |
속성
- engine : string
- engineCapabilities : enumeration
(since 6.6) - engineParameters : map
- locale : locale
- pitch : double
- rate : double
- state : enumeration
- voice : voice
- volume : double
신호
- aboutToSynthesize(number id)
(since 6.6) - void errorOccurred(enumeration reason, string errorString)
- sayingWord(string word, int id, int start, int length)
(since 6.6)
방법
- list<string> availableEngines()
- list<voice> availableLocales()
- list<voice> availableVoices()
- int enqueue(string utterance)
(since 6.6) - enumeration errorReason()
- string errorString()
- list<voice> findVoices(map criteria)
(since 6.6) - void pause(BoundaryHint boundaryHint)
- void resume()
- void say(string text)
- void stop(BoundaryHint boundaryHint)
상세 설명
say()를 사용하여 기본 오디오 장치로 텍스트 낭독을 시작하고, stop(), pause(), resume()를 사용하여 텍스트 낭독을 제어합니다.
TextToSpeech {
id: tts
volume: volumeSlider.value
pitch: pitchSlider.value
rate: rateSlider.value
...
RowLayout {
Button {
text: qsTr("Speak")
enabled: [TextToSpeech.Paused, TextToSpeech.Ready].includes(tts.state)
onClicked: {
let voices = tts.availableVoices()
tts.voice = voices[voicesComboBox.currentIndex]
tts.say(input.text)
}
}
Button {
text: qsTr("Pause")
enabled: tts.state == TextToSpeech.Speaking
onClicked: tts.pause()
visible: tts.engineCapabilities & TextToSpeech.Capabilities.PauseResume
}
Button {
text: qsTr("Resume")
enabled: tts.state == TextToSpeech.Paused
onClicked: tts.resume()
visible: tts.engineCapabilities & TextToSpeech.Capabilities.PauseResume
}
...추가 처리를 위해 텍스트를 PCM 데이터로 합성하려면 synthesize()를 사용합니다.
음성을 설정하려면 다음과 같이 VoiceSelector 부착 속성을 사용합니다:
TextToSpeech {
VoiceSelector.locale: Qt.locale("en_UK")
VoiceSelector.gender: Voice.Male
}지정된 모든 기준에 부합하는 첫 번째 음성이 사용됩니다. 모든 기준에 부합하는 음성이 없는 경우, 음성은 변경되지 않습니다.
또는 findVoices()을 사용하여 일치하는 음성 목록을 얻거나, availableVoices()을 사용하여 현재 로케일을 지원하는 음성 목록을 얻을 수 있습니다. locale 속성을 변경할 때는, 입력 텍스트의 언어와 원하는 음성 출력의 억양에 잘 맞는 availableLocales() 중 하나를 사용하십시오. 이렇게 하면 대부분의 플랫폼에서 사용 가능한 음성 목록이 변경됩니다. 그런 다음 voice 속성에 사용 가능한 음성 중 하나를 지정하십시오.
모든 엔진이 모든 기능을 지원하는 것은 아닙니다. engineCapabilities() 함수를 사용하여 사용 가능한 기능을 확인하고, 그에 따라 type의 사용 방법을 조정하십시오.
참고: 엔진이 지원하는로케일 및 음성은 대개 운영 체제 구성에 따라 달라집니다. 예를 들어, macOS에서는 최종 사용자가 시스템 환경설정의 ‘접근성’ 패널을 통해 음성을 설치할 수 있습니다.
속성 문서
engine : string
텍스트 음성 변환을 합성하는 데 사용되는 엔진.
엔진을 변경하면 진행 중인 음성 출력이 중단됩니다.
대부분의 플랫폼에서 엔진을 변경하면 available locales 및 available voices 의 목록이 업데이트됩니다.
engineCapabilities : enumeration [since 6.6]
이 속성은 현재 엔진에서 구현된 기능을 담고 있습니다.
이 속성은 Qt 6.6에서 도입되었습니다.
engine 및 QTextToSpeech::Capability도 참조하십시오 .
engineParameters : map
이 속성은 엔진별 매개변수를 저장합니다.
engine도 참조하십시오 .
locale : locale
이 속성은 현재 사용 중인 로케일을 저장합니다.
기본적으로 시스템 로케일이 사용됩니다.
voice도 참조하십시오 .
pitch : double
이 속성은 -1.0에서 1.0 사이의 음높이를 저장합니다.
기본값인 0.0은 일반적인 말소리 음높이를 나타냅니다.
rate : double
이 속성은 -1.0에서 1.0 사이의 범위에서 현재 음성 속도를 나타냅니다.
기본값인 0.0은 정상적인 말하기 속도를 나타냅니다.
state : enumeration
이 속성은 음성 합성기의 현재 상태를 저장합니다.
onStateChanged: updateStateLabel(state)
function updateStateLabel(state)
{
switch (state) {
case TextToSpeech.Ready:
statusLabel.text = qsTr("Ready")
break
case TextToSpeech.Speaking:
statusLabel.text = qsTr("Speaking")
break
case TextToSpeech.Paused:
statusLabel.text = qsTr("Paused...")
break
case TextToSpeech.Error:
statusLabel.text = qsTr("Error!")
break
}
}QTextToSpeech::State, say(), stop(), pause()도 참조하십시오 .
voice : voice
이 속성은 음성 출력에 사용될 음성을 지정합니다.
음성은 해당 엔진에서 지원하는 voices available 중 하나여야 합니다.
일부 플랫폼에서는 음성을 설정하면 ‘ locale ’, ‘ pitch ’ 등과 같은 다른 음성 속성도 변경됩니다. 이러한 변경 사항은 신호 발신을 유발합니다.
volume : double
이 속성은 0.0에서 1.0 사이의 현재 볼륨 값을 저장합니다.
기본값은 플랫폼의 기본 볼륨입니다.
Signal 문서
[since 6.6] aboutToSynthesize(number id)
이 신호는 엔진이 id 에 대한 음성 오디오 합성을 시작하기 직전에 발생합니다. 애플리케이션은 이 신호를 사용하여 voice 속성을 마지막 순간에 수정하거나, enqueue()를 통해 큐에 추가된 텍스트의 처리 과정을 추적할 수 있습니다.
참고: 해당 핸들러는 onAboutToSynthesize 입니다.
이 신호는 Qt 6.6에서 도입되었습니다.
void errorOccurred(enumeration reason, string errorString)
이 신호는 오류가 발생한 후 state 가 TextToSpeech.Error 로 설정되었을 때 발신됩니다. reason 매개변수는 오류 유형을 지정하며, errorString 는 사람이 읽기 쉬운 오류 설명을 제공합니다.
참고: 이에 대응하는핸들러는 onErrorOccurred 입니다.
state, errorReason() 및 errorString()도 참조하십시오 .
[since 6.6] sayingWord(string word, int id, int start, int length)
이 신호는 id 발화에서 start 및 length 로 지정한 텍스트 구간인 ‘ word ’가 오디오 장치로 재생될 때 발생합니다.
참고: 이 신호를 사용하려면 엔진에 WordByWordProgress 기능이 있어야 합니다.
다음 코드는 TextArea input 에서 발음되는 단어를 강조 표시합니다:
onSayingWord: (word, id, start, length)=> {
input.select(start, start + length)
}참고: 해당 핸들러는 onSayingWord 입니다.
이 신호는 Qt 6.6에서 도입되었습니다.
QTextToSpeech::Capability 및 say()도 참조하십시오 .
메서드 문서
list<string> availableEngines()
지원되는 텍스트 음성 변환 엔진 플러그인 목록을 포함합니다.
list<voice> availableLocales()
현재 활성화된 engine 에서 지원하는 로케일 목록을 보관합니다.
list<voice> availableVoices()
현재 locale 에서 사용할 수 있는 음성 목록을 포함합니다.
[since 6.6] int enqueue(string utterance)
utterance 를 낭독할 텍스트 대기열에 추가하고, 낭독을 시작합니다.
엔진의 ` state `이 현재 ` Ready`인 경우, ` utterance `이 즉시 낭독됩니다. 그렇지 않은 경우, 엔진은 현재 텍스트의 낭독을 마친 후 ` utterance `을 낭독하기 시작합니다.
엔진이 대기열의 다음 텍스트 항목으로 넘어갈 때마다 aboutToSynthesize() 신호가 발생합니다. 이를 통해 애플리케이션은 진행 상황을 추적하고, 음성 속성을 마지막 순간에 변경할 수 있습니다.
stop()를 호출하면 큐가 지워집니다.
이 메서드는 Qt 6.6에서 도입되었습니다.
say(), stop(), aboutToSynthesize()도 참조하십시오 .
enumeration errorReason()
엔진이 오류를 보고한 원인을 반환합니다.
QTextToSpeech::ErrorReason도 참조하십시오 .
string errorString()
현재 엔진 오류 메시지를 반환합니다.
[since 6.6] list<voice> findVoices(map criteria)
지정된 모든 criteria 에 일치하는 음성 목록을 반환합니다.
criteria 는 음성 속성 이름과 속성 값 간의 매핑으로, 다음과 같은 검색 기준의 조합을 지원합니다:
let daniel = tts.findVoices({
"name": "Daniel"
})
let maleEnglish = tts.findVoices({
"gender": Voice.Male,
"language": Qt.locale('en')
})이 메서드는 Qt 6.6에서 도입되었습니다.
VoiceSelector도 참조하십시오 .
void pause(BoundaryHint boundaryHint)
boundaryHint 에서 현재 음성 재생이 일시 정지됩니다.
boundaryHint 가 준수되는지는 engine 에 따라 달라집니다.
resume(), QTextToSpeech::BoundaryHint 및 PauseResume도 참조하십시오 .
void resume()
pause()가 호출된 후 다시 말을 이어갑니다.
pause()도 참조하십시오 .
void say(string text)
text 의 합성을 시작합니다.
이 함수는 음성 합성을 비동기 방식으로 시작하고, 텍스트를 기본 오디오 출력 장치로 읽어 냅니다.
RowLayout {
Button {
text: qsTr("Speak")
enabled: [TextToSpeech.Paused, TextToSpeech.Ready].includes(tts.state)
onClicked: {
let voices = tts.availableVoices()
tts.voice = voices[voicesComboBox.currentIndex]
tts.say(input.text)
}
}참고: 새로 합성된 텍스트를 읽기 시작하기 전에 진행 중인모든 낭독이 중지됩니다.
현재 상태는 state 속성을 통해 확인할 수 있으며, 낭독이 시작되면 QTextToSpeech::Speaking 로 설정됩니다. 낭독이 완료되면 state 가 QTextToSpeech::Ready 로 설정됩니다.
stop(), pause(), resume()도 참조하십시오 .
void stop(BoundaryHint boundaryHint)
boundaryHint 에서 현재 판독을 중지하고, 대기 중인 텍스트 큐를 지웁니다.
읽기 작업을 다시 시작할 수 없습니다. ` boundaryHint `가 준수되는지는 엔진에 따라 다릅니다.
say(), enqueue(), pause() 및 QTextToSpeech::BoundaryHint도 참조하십시오 .
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.