pip 설치 시 참고 링크
gTTS 모듈 설치
pip install gTTS
pip install playsound
from gtts import gTTS
text = '안녕하세요, 이수진입니다.'
tts = gTTS(text=text, lang='ko')
tts.save('./StudyPython/output/hi.mp3')
print('완료!')
pip install pyttsx3
import pyttsx3
tts = pyttsx3.init()
tts.say('안녕하세요')
tts.runAndWait()
import sys
from PyQt5 import uic
from PyQt5.QtWidgets import *
from PyQt5.QtGui import * # QIcon 여기있음
from PyQt5.QtCore import * # Qt.white 여기 있음
from gtts import gTTS
from playsound import playsound
import os
import time
class qtApp(QWidget):
def __init__(self):
super().__init__()
uic.loadUi('./studyPython/ttsApp.ui',self)
self.setWindowTitle('텍스트 투 스피치 v0.3')
self.btnQrGen.clicked.connect(self.btnQrGenClicked)
def btnQrGenClicked(self):
text = self.txtQrData.text()
if text == '':
QMessageBox.warning(self,'경고','텍스트를 입력하세요.')
return
tts = gTTS(text=text, lang='ko', slow=False)
tts.save('./StudyPython/output/hi.mp3')
time.sleep(1.0)
playsound('./StudyPython/output/hi.mp3')
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = qtApp()
ex.show()
sys.exit(app.exec_())