glutanimate / simple-google-tts

Use Google text-to-speech on your Linux desktop
GNU General Public License v3.0
119 stars 32 forks source link

Save to .mp3 #5

Open Blunderchips opened 8 years ago

Blunderchips commented 8 years ago

Is there any way to save the returned audio to a .mp3? (or any other audio format)

glutanimate commented 8 years ago

There's no easy inbuilt option to do this, but you can modify the script to keep the generated audio snippets on your file system. You will have to do the following:

In simple_google_tts, remove line 295 in cleanup():

[[ -n "$TmpDir" && -d "$TmpDir" ]] && rm -r "$TmpDir"

and modify tts_google() to remove the call to rm (l. 258):

      [[ -f "out_$((i-1)).mp3" ]] && rm "out_$((i-1)).mp3"

Having done this, simple_google_tts will now preserve all of its temporary files. These files will be located under /tmp/simple_google_tts/.... Please note, though, that the script works by downloading smaller audio segments and playing them back one by one. Processing one paragraph can yield up to a dozen smaller mp3 files which you would then have to concatenate if you wanted to use them in one single file.

Unfortunately I don't have the time to add a proper switch for all of this right now.

ambagasdowa commented 6 years ago

I have made some changes to the code to be able to save the audio in ogg, I intend to make more changes much more polished, I hope it is still useful , check the fork