0
def finalvoice():
    engine = pyttsx3.init()  
    raw_voice = Path("post_data.json").read_text()
    final_voice = json.loads(raw_voice.replace("post_body",""))
    voices = engine.getProperty('voices')
    engine.setProperty('voice', voices[1].id)  
    engine.say(final_voice)
    output_path = r'C:\Users\Lenovo\OneDrive\Desktop\reddit video\test.mp3'
    engine.save_to_file(final_voice, output_path)
    engine.runAndWait()
finalvoice()

The program runs but I cant find test.mp3 in the given directory

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jun 10 '23 at 10:47

1 Answers1

0

This seems a bit late but the save_to_file accepts a filename and not a path as the second argument. i think you should try using the os library to exchange the file path of the save_to_file function to what every directory you want it to land in.

samad
  • 1