Documentation
¶
Index ¶
Constants ¶
const ( DefaultSilenceThreshold = 0.0005 // Default silence threshold DefaultSilenceDuration = time.Second * 2 // Default silence duration )
const (
Int16Gain = float64(math.MaxInt16) // Gain for converting int16 to float32
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Opt ¶ added in v1.7.6
type Opt func(*opts) error
func WithDefaultSilenceThreshold ¶ added in v1.7.6
func WithDefaultSilenceThreshold() Opt
func WithSilenceDuration ¶ added in v1.7.6
type SegmentFuncFloat32 ¶
SegmentFuncFloat is a callback function which is called for the next segment of audio samples. The first argument is the timestamp of the segment.
type SegmentFuncInt16 ¶
SegmentFuncInt16 is a callback function which is called for the next segment of audio samples. The first argument is the timestamp of the segment.
type Segmenter ¶
type Segmenter struct {
// contains filtered or unexported fields
}
A segmenter reads audio samples from a reader and segments them into fixed-size chunks. The segmenter can be used to process audio samples
func NewReader ¶
Create a new segmenter with a reader r which segments into raw audio of 'dur' length. If dur is zero then no segmenting is performed, the whole audio file is read and output in one go, which could cause some memory issues. The sample rate is the number of samples per second.
At the moment, the audio format is auto-detected, but there should be a way to specify the audio format.
func (*Segmenter) DecodeFloat32 ¶
func (s *Segmenter) DecodeFloat32(ctx context.Context, fn SegmentFuncFloat32) error
Segments are output through a callback, with the samples and a timestamp At the moment the "best" audio stream is used, based on ffmpeg heuristic.
func (*Segmenter) DecodeInt16 ¶
func (s *Segmenter) DecodeInt16(ctx context.Context, fn SegmentFuncInt16) error
Segments are output through a callback, with the samples and a timestamp At the moment the "best" audio stream is used, based on ffmpeg heuristic.