
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
A Ruby library and CLI tool to interface with Google Translate's Text-to-Speech API. This is a Ruby port of the Python gTTS library.
Add this line to your application's Gemfile:
gem 'gtts'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install gtts
require 'gtts'
# Simple example
tts = Gtts::GTTS.new("Hello World")
tts.save("hello.mp3")
# More options
tts = Gtts::GTTS.new(
"Hola Mundo",
lang: "es", # Language
tld: "com.mx", # Top-level domain
slow: true # Slower speed
)
tts.save("hola.mp3")
# Stream the audio data
tts.stream do |audio_chunk|
# Process audio data chunks
# For example, write to a file
File.open("output.mp3", "ab") { |f| f.write(audio_chunk) }
end
# Check supported languages
Gtts.languages.each do |code, name|
puts "#{code}: #{name}"
end
# Check if a language is supported
puts Gtts.language_supported?("es") # true
puts Gtts.language_supported?("xx") # false
The gem comes with a command-line tool called gtts-cli
:
# Basic usage
gtts-cli "Hello World" -o hello.mp3
# Specify language
gtts-cli "Hola Mundo" -l es -o hola.mp3
# Read from file
gtts-cli -f input.txt -o output.mp3
# List available languages
gtts-cli --list-langs
# Show all options
gtts-cli --help
-f, --file FILE
: Read text from file-o, --output FILE
: Output file (default: output.mp3)-l, --lang LANG
: Language (default: en)-t, --tld TLD
: Top-level domain for Google Translate-s, --slow
: Speak more slowly--list-langs
: List available languages--debug
: Debug mode-h, --help
: Show help messageThe library supports multiple languages. Use gtts-cli --list-langs
to see all available languages or check Gtts.languages
in your code.
Bug reports and pull requests are welcome on GitHub.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that gtts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.