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
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.