auditok.io.Rewindable

class auditok.io.Rewindable(sampling_rate, sample_width, channels)[source]

Base class for rewindable audio sources.

This class serves as a base for audio sources that support rewinding. Subclasses should implement a method to return to the beginning of the stream (rewind), and provide a property position that allows getting and setting the current stream position, expressed in number of samples.

__init__(sampling_rate, sample_width, channels)

Methods

__init__(sampling_rate, sample_width, channels)

close()

Close audio source.

is_open()

Return True if audio source is open, False otherwise.

open()

Open audio source.

read(size)

Read and return up to size audio samples.

rewind()

Go back to the beginning of audio stream.

Attributes

ch

Number of channels in audio stream (alias for channels).

channels

Number of channels in audio stream.

position

Return stream position in number of samples.

position_ms

Return stream position in milliseconds.

position_s

Return stream position in seconds.

sample_width

Number of bytes used to represent one audio sample.

sampling_rate

Number of samples per second of audio stream.

sr

Number of samples per second of audio stream (alias for sampling_rate).

sw

Number of bytes used to represent one audio sample (alias for sample_width).