Class: Awaaz::Decoders::WavefileDecoder
- Inherits:
-
BaseDecoder
- Object
- BaseDecoder
- Awaaz::Decoders::WavefileDecoder
- Includes:
- Utils::ViaShell
- Defined in:
- lib/awaaz/decoders/wavefile_decoder.rb
Overview
The WavefileDecoder is responsible for decoding ‘.wav` audio files into raw PCM data that can be processed by the Awaaz audio pipeline.
This decoder supports multiple decoding strategies:
-
Soundread — a Ruby-level ‘.wav` file reader.
-
**Shell-based decoding** — for raw audio extraction.
The decoder will choose a decoding method based on availability of decoders and the configured options.
Class Method Summary collapse
-
.default_available_options ⇒ Object
Sets the available decoding options for this decoder.
Instance Method Summary collapse
-
#load ⇒ Array<(Numo::NArray, Integer, Integer)>
Loads and decodes a ‘.wav` file into raw PCM data.
Methods inherited from BaseDecoder
#available_options, #initialize, load, set_available_options
Constructor Details
This class inherits a constructor from Awaaz::Decoders::BaseDecoder
Class Method Details
.default_available_options ⇒ Object
Sets the available decoding options for this decoder. Defaults to the base options plus the ‘:soundread` option.
27 |
# File 'lib/awaaz/decoders/wavefile_decoder.rb', line 27 + [:soundread] |
Instance Method Details
#load ⇒ Array<(Numo::NArray, Integer, Integer)>
The decoding method is chosen dynamically:
-
If there are no available decoders, or if ‘:soundread` is enabled, it will use the BaseDecoder#soundread method.
-
Otherwise, it will use shell based decoding.
Loads and decodes a ‘.wav` file into raw PCM data.
46 47 48 49 50 51 52 53 54 |
# File 'lib/awaaz/decoders/wavefile_decoder.rb', line 46 def load output_data = if no_decoders? || soundread? soundread else shell_load sox_options: { raw: true } end process(*output_data) end |