Python tts

fukurou

the supreme coder
ADMIN
Python:
from playsound import playsound
import pyttsx3

if __name__ == "__main__":
    # init engine
    engine = pyttsx3.init()
    rate = engine.getProperty('rate')
    engine.setProperty('rate', 125)
    engine.setProperty('voice', 1)
    volume = engine.getProperty('volume')
    engine.setProperty('volume', 1.0)
    voices = engine.getProperty('voices')
    engine.setProperty('voice', voices[1].id)

    def speak(txt:str):
        engine.say(f'<pitch middle="10">{txt}</pitch>')
        engine.runAndWait()


    speak("hello admin how are you?")
    engine.stop()
    playsound('roar.mp3')
    playsound('roar.mp3')
 

fukurou

the supreme coder
ADMIN
Python:
from playsound import playsound
import pyttsx3


class LGTTSv1:
    def __init__(self):
        self.engine = pyttsx3.init()
        self.rate = self.engine.getProperty('rate')
        self.engine.setProperty('rate', 125)
        self.engine.setProperty('voice', 1)
        self.volume = self.engine.getProperty('volume')
        self.engine.setProperty('volume', 1.0)
        self.voices = self.engine.getProperty('voices')
        self.engine.setProperty('voice', self.voices[1].id)

    def speak(self, txt: str):
        self.engine.say(f'<pitch middle="10">{txt}</pitch>')
        self.engine.runAndWait()

    def stopEngine(self):
        self.engine.stop()

    @staticmethod
    def playSoundFile(file: str):
        playsound(file)
 
Top