auditok.core.AudioRegion

class auditok.core.AudioRegion(data, sampling_rate, sample_width, channels, meta=None)[source]

AudioRegion encapsulates raw audio data and provides an interface to perform simple operations on it. Use AudioRegion.load to build an AudioRegion from different types of objects.

Parameters:
  • data (bytes) – raw audio data as a bytes object
  • sampling_rate (int) – sampling rate of audio data
  • sample_width (int) – number of bytes of one audio sample
  • channels (int) – number of channels of audio data
  • meta (dict, default: None) – any collection of <key:value> elements used to build metadata for this AudioRegion. Meta data can be accessed via region.meta.key if key is a valid python attribute name, or via region.meta[key] if not. Note that the split() function (or the AudioRegion.split() method) returns AudioRegions with a start and a stop meta values that indicate the location in seconds of the region in original audio data.

See also

AudioRegion.load

__init__(data, sampling_rate, sample_width, channels, meta=None)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(data, sampling_rate, sample_width, …) Initialize self.
load(input[, skip, max_read]) Create an AudioRegion by loading data from input.
play([progress_bar, player]) Play audio region.
plot([scale_signal, show, figsize, save_as, …]) Plot audio region, one sub-plot for each channel.
save(file[, audio_format, exists_ok]) Save audio region to file.
split([min_dur, max_dur, max_silence, …]) Split audio region.
split_and_plot([min_dur, max_dur, …]) Split region and plot signal and detections.

Attributes

ch Number of channels of audio data, alias for channels.
channels Number of channels of audio data.
duration Returns region duration in seconds.
len Return region length in number of samples.
meta
millis end]``).
sample_width Number of bytes per sample, one channel considered.
samples Audio region as arrays of samples, one array per channel.
sampling_rate Samling rate of audio data.
seconds end]``).
sr Samling rate of audio data, alias for sampling_rate.
sw Number of bytes per sample, alias for sampling_rate.