2

I am doing Ai research. I have been using pyttsx3 for the voice. The pyttsx3 function does not produce visemes. It does produce limited timing for each word. I intend to make a function that take in the text, then produce the visemes for animation of an avatar. The problem is that the data is trapped in the engine. I wanted to save the audio to a file, then load and extract it. The problem is that the save_to_file appears to be a dummy function. I have spent days researching it and the best that I have gotten are files with 0 (zero) bytes. What is going on?

David Day
  • 21
  • 3

3 Answers3

0

I came across this when searching for solutions to the same problem. Eventually, what I noticed was that it was to do with the file name. When I chose the file name to be 'test.mp3' or 'name.mp3', it saved properly, but if I changed the name to 'text.mp3' or basically anything else while keeping everything else exactly the same, it produced a file of zero bytes in size. When I saved it to a different folder but the same name, e.g. 'folder/test.mp3', then it also failed, presumably because it's the full absolute path name which matters.

My hack/workaround was to just always use the file name 'test.mp3' in the same directory, and then use python's os module to move it or change the name immediately afterwards, e.g.:

engine.save_to_file(text, "test.mp3")
os.rename("test.mp3", "folder/nameIwanttogive.mp3")

So 'test.mp3' seemed to work for me. Maybe see what works by initially copying and pasting some demo code from a website.

Vigoxin
  • 63
  • 7
0

I had the same problem, it was because i forgot a litle thing:

engine.save_to_file('hello', 'test.mp3')

it just for preparation, to implement everything use the code:

import pyttsx3 as tts 
engine=tts.init()
engine.save_to_file('hello', 'HelloSound.mp3')

engine.runAndWait() #  implement everything
LORD_M.D
  • 11
  • 1
-1

I just update my pyttsx3 to 2.90 and started to work!! Just reinstall! try:

pip uninstall pyttsx3

and than:

pip install pyttsx3