Speak Something with file using python (without internet)

------------------------------------------------------------

firstly install pip install pyttsx3 in cmd

------------------------------------------------------------

A SUDHIR TAWANIYA PRODUCT

------------------------------------------------------------

import pyttsx3

def say():

    global engin

    engin = pyttsx3.init()

    voices=engin.getProperty('voice')

    engin.setProperty('voice',voices[0])

    engin.setProperty('rate',130)

def open_file():

    with open("file_name") as file_object:

      for line in file_object.readlines():

        print(line)

        engin.say(line)

        engin.runAndWait()


say()

open_file()

Comments

Post a Comment