0

Essentially, the idea is to open a document ("document2read.txt") and read all the lines from it. Each line contains three full sentences. Then, each line is made into an audio clip, saved with a unique name (audio_0.mp3, audio_1.mp3, etc). Heres my code so far:

import pyttsx3

#Open DOC
comments_file=open("document2read.txt", "r")
lines=comments_file.readlines()

#start speech to text engine
engine = pyttsx3.init()

#Vars
start="audio_"
i=0

for line in lines:
    name=start+str(i)+".mp3"
    print(line)
    engine.save_to_file(line, name)
    i+=1
engine.runAndWait()

My problem is that when I run this code, the audio clip only saves the first sentence of the line! Any ideas on what to do? I'm stumped.

Glitchin
  • 21
  • 4
  • Me too!! readthedocs states there is engine.save_to_file but now my own script returns error Not found. I wrote a script a few months ago and it worked then so there seems to be a bug in pyttsx3 itself. – Derek Jun 26 '21 at 04:24
  • The answer I gave was not relevant since the problem is with `pyttsx3` itself. The GitHub has 79 issues pending and 91 solved (last time I looked) – Derek Jul 03 '21 at 02:50

0 Answers0