gTTS /python/ - can you text message the .mp3 file in your script?

594 views Asked by At

twilio api says it only handles mp4 for audio. Anyone have a solution to save python text to speach as .mp3 or .mp4 and text said audio file or a call and the mp3 audio plays.

1

There are 1 answers

5
philnash On

Twilio developer evangelist here.

Twilio does support mp3 files for audio, as well as wav, aiff, gsm and ulaw.

It looks as though that's exactly what gTTS does for you. The example in the documentation is:

>>> from gtts import gTTS
>>> tts = gTTS('hello')
>>> tts.save('hello.mp3')

Alternatively, you could just use Twilio's text to speech as part of your call, with <Say>. If you are not satisfied with the basic voices you can now use voices from AWS Polly in Twilio Voice.

Let me know if that helps at all.