Для руби совсем просто. Правда, без Google Cloud Text-to-Speech API :
# gem install tts
# apt install mpg123
require 'tts'
# Will download "Ruby!.mp3" to your current directory
# Supported languages: ["zh", "en", "it", "fr"]
#"Ruby!".to_file "en"
# Playback in English (1 times)
s = "Say something in English"
repeatTimes = 1
s.play("en", repeatTimes)