Module: GoogleTranslateTts
- Includes:
- Constanting, Fileable, Utils
- Defined in:
- lib/google_translate_tts.rb,
lib/google_translate_tts/utils.rb,
lib/google_translate_tts/version.rb,
lib/google_translate_tts/fileable.rb,
lib/google_translate_tts/constanting.rb
Defined Under Namespace
Modules: Constanting, Fileable, Utils
Constant Summary collapse
- VERSION =
"0.2.0"
Constants included from Constanting
Constanting::BASE_URL, Constanting::REFERER, Constanting::TTS_TMP_DIR, Constanting::USER_AGENT
Class Method Summary collapse
Methods included from Utils
Methods included from Fileable
Class Method Details
.fetch(phrase, **options) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/google_translate_tts.rb', line 16 def fetch(phrase, **) with_temp_file do |file| lang, filename = .values_at(:lang, :file) filename ||= .fetch(:file, "file") response = Faraday.get(translate_tts_url(q: phrase, tl: lang)) file.write(response.body) copy_file(file.path, "#{filename}.mp3") end end |