pythontext-to-speechspeaker

How to make something say in python


I want my python program to say like

a = "Hello Boss I am your program"
say(a)
#and it should say the text

thanks in advance!


Solution

  • first you need to install module named PYTTSX3.

    do pip/pip3 install PYTTSX3

    then code is here:

    import PYTTSX3 as speaker
    tts = speaker.init()
    
    def say(text):
       tts.say(text)
       tts.runAndWait()
    
    a = "Hello Boss I am your program"
    say(a)
    

    This will read aloud 'Hello Boss I am your program' ;)