0

I want to make python read string which added in a variable from before because I am creating scraping script and if there are any errors, I want it to tell me, I watched many of video about that but all were about read the text and then creating mp3 file, not to read the string in the same time

2 Answers2

1

You can use win32com to read text directly from the command line:

from win32com.client import Dispatch

speaker = Dispatch("SAPI.spVoice")

text = "Error" # Choose what the speaker should speak

speaker.Speak(text) # It starts speaking here
Red
  • 26,798
  • 7
  • 36
  • 58
-1

i found a selution

import playsound
from gtts import gTTS
def speak(text):
    tts= gTTS(text= text, lang="en")
   # filename="voice.mp3"
    tts.save(filename)
    playsound.playsound(filename)
speak("error")