nateshmbhat/pyttsx3

Need a return of the filename save_to_file() used

Closed this issue · 1 comments

On window save_to_file() writes a WAV file.
If you pass it a filename with an extension - say your_file.mp3 - it will happily save the WAV data into 'your_file.mp3,' without caring that the contents are not mp3 data. And that's fine.

But if you pass save_to_file() a filename without an extension, it will give the file the correct extension of .wav. (on Windows) So if you simply pass in 'your_file' it will save to 'your_file.wav'. This is also fine.

What's left to answer, that I can't find in the documentation, or figure out looking through the library's code, is how I'm supposed to know what filename save_to_file() used. Because if I pass it an extension, that extension might not actually match the data type that comes out the other end. But if I pass no extension, it alters the filename; And now my application doesn't know where it was saved.

I expected the method save_to_file() to return the name of the file it saved to. But it doesn't. And, like I say, I don't see where I can get the filename it used, back from the library.

I was mistaken, here. It DOESN'T append the correct extension on Windows. If you hand it a filename without an extension, it will save to a file without an extension.

I suppose I ended up with a .wav, .mp3, and no-extension version of the same audio output in my directory while I was trying to figure out why the ".mp3" version wouldn't play in foobar2000. (because the library is rendering a wav, not encoding an mp3) From there I simply overlooked that there was a no-extension version there at all, and concluded the .wav version sitting there was the product of the extension being added automagically.