Awaaz
Awaaz is a Ruby gem for working with audio, from decoding to analysis, making it easier to process and understand sound in your projects.
Requirements
Awaaz can decode audio in two ways:
1. Shell-based decoding
You can install any one of the following:
-
ffmpeg
– supports most formats, including MP3. -
sox
– also supports most formats, including MP3. -
mpg123
– MP3 only.
2. Library-based decoding and resampling
-
libsndfile
– reads audio files (but cannot read MP3 files). -
libsamplerate
– resamples audio samples when usinglibsndfile
.
⚠ Important:
- If you need MP3 support with the library-based method, you must also install one of:
ffmpeg
sox
mpg123
Additional Requirement
- The Ruby gem
numo-narray
is required for numerical array operations.
Installation Examples
-
Just ffmpeg → works for all formats (no
libsndfile
orlibsamplerate
needed). -
Just sox → works for all formats (no
libsndfile
orlibsamplerate
needed). -
libsndfile + libsamplerate → works for non-MP3 formats. For MP3, add
ffmpeg
,sox
, ormpg123
. - Everything installed → maximum flexibility.
Installation
Install the gem and add to the application's Gemfile by executing:
bundle add awaaz
If bundler is not being used to manage dependencies, install the gem by executing:
gem install awaaz
Usage
# To decode the audio file
samples, sample_rate = Awaaz.load("path/to/audio_file")
# To decode the audio file using specified decoder
samples, sample_rate = Awaaz.load("path/to/audio_file", decoder: :sox)
Development
After checking out the repo, run bin/setup
to install dependencies. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at Awaaz. This project is intended to be a safe, welcoming space for collaboration, and contributors.
License
The gem is available as open source under the terms of the MIT License.