# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'F:\ZEEL_DATA\Python_Project\VANI PDF TO AUDIOBOOK\VANI\Text_Mode_Form.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
import pyttsx3


class Ui_Text_Mode_Form(object):
    def setupUi(self, Text_Mode_Form):
        Text_Mode_Form.setObjectName("Text_Mode_Form")
        Text_Mode_Form.setWindowModality(QtCore.Qt.ApplicationModal)
        Text_Mode_Form.resize(400, 250)
        Text_Mode_Form.setMinimumSize(QtCore.QSize(400, 250))
        Text_Mode_Form.setMaximumSize(QtCore.QSize(400, 250))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("F:\\ZEEL_DATA\\Python_Project\\VANI PDF TO AUDIOBOOK\\VANI\\../icons/audiobook.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        Text_Mode_Form.setWindowIcon(icon)
        self.btn_Audio = QtWidgets.QPushButton(Text_Mode_Form)
        self.btn_Audio.setGeometry(QtCore.QRect(140, 200, 111, 41))
        self.btn_Audio.setObjectName("btn_Audio")
        self.txt_Speach = QtWidgets.QPlainTextEdit(Text_Mode_Form)
        self.txt_Speach.setGeometry(QtCore.QRect(20, 20, 361, 161))
        self.txt_Speach.setPlainText("")
        self.txt_Speach.setObjectName("txt_Speach")

        self.retranslateUi(Text_Mode_Form)
        QtCore.QMetaObject.connectSlotsByName(Text_Mode_Form)

        self.btn_Audio.clicked.connect(self.Speach)

    def retranslateUi(self, Text_Mode_Form):
        _translate = QtCore.QCoreApplication.translate
        Text_Mode_Form.setWindowTitle(_translate("Text_Mode_Form", "Text Mode"))
        self.btn_Audio.setText(_translate("Text_Mode_Form", "Audio"))

    def Speach(self):
        speaker = pyttsx3.init()
        speach = self.txt_Speach.toPlainText()
        if speach == '':
            speach = 'Please Write somthin in the textbox so i can speak and remember zeel is the best'
        speaker.say(speach)
        speaker.runAndWait()

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Text_Mode_Form = QtWidgets.QFrame()
    ui = Ui_Text_Mode_Form()
    ui.setupUi(Text_Mode_Form)
    Text_Mode_Form.show()
    sys.exit(app.exec_())
