Silan
Audio::Silan - Audio silence detection using silan
SYNOPSIS
use Audio::Silan;
my $silan = Audio::Silan.new;
my $promise = $silan.find-boundaries($some-audio-file);
await $promise.then(-> $i { say "Start : { $i.start } End: { $i.end }" });
DESCRIPTION
This module provides a mechanism to use Silan to detect the silence at the beginning and end of an audio file (which are sometimes described as cue in and cue out points.)
It allows the setting of the silence threshold and "hold off" (that is the minimum length of silence required before it is considered the end of the audio.) For certain material these values may need adjustment in order to provide accurate output.
Because the detection may take some time for larger files, this takes
place asynchronously: the method find-boundaries
returns a Promise
which will be kept with the result of the detection (or broken if the
detection failed.)
METHODS
method new
method new(Str :$silan-path, Numeric :$hold-off, Numeric :$threshold)
The constructor for Audio::Silan. $silan-path
if provided must be
the fully qualified path to the silan
executable, otherwise it will be
looked for in the $PATH
environment. $hold-off
is the minimum time
in seconds before silence is detected, it really only applies to the end of
the file (this can be increased to stop spurious detection,) the default is
0.5. $threshold
is a floating point RMS signal threshold at which silence
is detected, the default is 0.001 (which is about -60dB) this can be decreased
to prevent spurious detection in quite passages.
method find-boundaries
method find-boundaries(Str $file) returns Promise
This uses silan
to detect the cue points in the audio file supplied as
$file
, returning a Promise.
If there is a problem with the detection or the file cannot be read or the
silan cannot be executed then the Promise
will be broken with an exception.
If the detection is successful the Promise will be kept with an object
of the type Audio::Silan::Info
which has the following members:
duration
The total length of the audio file in seconds
sample-rate
The sample rate of the audio, this can be used to convert the bounds to samples rather than seconds if they are to be used for processing.
start
The floating point number of seconds into the audio data that the content was detected to begin.
end
The floating point number of seconds (from the start of the file,) where the audio is detected to end.