lib/awaaz/utils/via_shell.rb
popen pipes to/from command
SHA-2566cf3a3d31e4b352ea3cb147c46f77f6fd5a57f5382a415405f98d4fc2c8576e4
MaleculeH(Po)
Evidence
1# frozen_string_literal: true
2
3module Awaaz
4 module Utils
5 ##
6 # Utility module providing shell-based audio decoding support for decoder classes.
7 #
8 # This module is intended to be mixed into decoder classes that rely on external
9 # tools such as `ffmpeg`, `mpg123`, or `sox` to decode audio files. It builds the
10 # appropriate shell commands, executes them, and converts the raw audio data into
11 # [Numo::NArray] samples.
12 #
13 # @note This module is …
62:63… g)
63
64 ffmpeg_command
65 .add_flag("-nostdin")
66 .add_option("-v", "quiet")
67 .add_option("-i", filename)
68 .add_opt …
121:38… .command unless shell_command.is_a?(String)
122 raw_audio = IO.popen(shell_command, "rb", &:read)
123 samples = Numo::Int16.from_string(raw_audio).cast_to(Numo::DFloat) / amplification_fact …
130:75… raises
131 # a {Awaaz::DecoderNotFound} error with a list of potential decoders.
132 #
133 # @raise [Awaaz::DecoderNotFound] if no decoder cou …