aug module

This module defines class for augmentation of MultiChannelSignal objects and WAV audio flies.

class aug.SignalAugmentation(signal: MultiChannelSignal = None, seed=-1)

Class provides augmentation of multichannel sound data (MultiChannelSignal object) and audio files.

achn(list_of_chains: list[str]) MultiChannelSignal

Add chain to list of chains.

Parameters:

list_of_chains (list[str]) – A list of chains to add.

Returns:

The updated SignalAugmentation instance

with added chains. Result, allowing for method chaining.

Return type:

self (SignalAugmentation)

add_chain(list_of_chains: list[str]) MultiChannelSignal

Add chain to list of chains.

Parameters:

list_of_chains (list[str]) – A list of chains to add.

Returns:

The updated SignalAugmentation instance

with added chains. Result, allowing for method chaining.

Return type:

self (SignalAugmentation)

amp(amplitude_list: list[float], amplitude_deviation_list: list[float] = None) SignalAugmentation

Apply amplitude control to a multichannel sound. If amplitude_deviation_list is defined, you can get different versions of the same MultiChannelSignal data.

Parameters:
  • amplitude_list (list[float]) – The list of amplitude coefficients to apply to each channel.

  • amplitude_deviation_list (list[float]) – If exists, sets amplitude values random with uniform distribution in range [amplitude - deviation, amplitude + deviation)].

Returns:

Object with amplitude-controlled

multichannel sound.

Return type:

self (SignalAugmentation)

amplitude_ctrl(amplitude_list: list[float], amplitude_deviation_list: list[float] = None) SignalAugmentation

Apply amplitude control to a multichannel sound. If amplitude_deviation_list is defined, you can get different versions of the same MultiChannelSignal data.

Parameters:
  • amplitude_list (list[float]) – The list of amplitude coefficients to apply to each channel.

  • amplitude_deviation_list (list[float]) – If exists, sets amplitude values random with uniform distribution in range [amplitude - deviation, amplitude + deviation)].

Returns:

Object with amplitude-controlled

multichannel sound.

Return type:

self (SignalAugmentation)

copy() SignalAugmentation

Deep copy of the SignalAugmentation object.

cpy() SignalAugmentation

Deep copy of the SignalAugmentation object.

delay_ctrl(delay_us_list: list[int], delay_deviation_list: list[int] = None) SignalAugmentation

Add delays of channels of multichannel sound. Output data become longer. Values of delay will be converted to count of samples.

Parameters:
  • delay_us_list (list[int]) – The list of delay values in microseconds

  • integer. (to apply to each channel. Each value should be a positive)

  • data. (sound)

  • delay_deviation_list (list[int]) – If exists, the list of delay

  • distributed. (deviations makes delays uniformly)

Returns:

Object with delayed multichannel sound.

Return type:

self (SignalAugmentation)

dly(delay_us_list: list[int], delay_deviation_list: list[int] = None) SignalAugmentation

Add delays of channels of multichannel sound. Output data become longer. Values of delay will be converted to count of samples.

Parameters:
  • delay_us_list (list[int]) – The list of delay values in microseconds

  • integer. (to apply to each channel. Each value should be a positive)

  • data. (sound)

  • delay_deviation_list (list[int]) – If exists, the list of delay

  • distributed. (deviations makes delays uniformly)

Returns:

Object with delayed multichannel sound.

Return type:

self (SignalAugmentation)

echo(delay_us_list: list[int], amplitude_list: list[float], delay_deviation_list: list[int] = None, amplitude_deviation_list: list[float] = None) SignalAugmentation

Add echo to multichannel sound. The output data become longer. To each channel will be added it’s copy with corresponding delay delay and amplitude. It looks like acoustic wave was reflected from the hard wall.

Parameters:
  • delay_us_list (list[int]) – The list of delay values in microseconds to apply to each channel. Each value should be a positive integer.

  • amplitude_list (list[float]) – The list of amplitude coefficients to apply to each channel.

  • delay_deviation_list (list[int]) – If exists gives random deviation of reflection delay.

  • amplitude_deviation_list (list[float]) – If exists gives random deviation of reflection amplitude.

Returns:

The object with echoed multichannel

sound.

Return type:

self (SignalAugmentation)

echo_ctrl(delay_us_list: list[int], amplitude_list: list[float], delay_deviation_list: list[int] = None, amplitude_deviation_list: list[float] = None) SignalAugmentation

Add echo to multichannel sound. The output data become longer. To each channel will be added it’s copy with corresponding delay delay and amplitude. It looks like acoustic wave was reflected from the hard wall.

Parameters:
  • delay_us_list (list[int]) – The list of delay values in microseconds to apply to each channel. Each value should be a positive integer.

  • amplitude_list (list[float]) – The list of amplitude coefficients to apply to each channel.

  • delay_deviation_list (list[int]) – If exists gives random deviation of reflection delay.

  • amplitude_deviation_list (list[float]) – If exists gives random deviation of reflection amplitude.

Returns:

The object with echoed multichannel

sound.

Return type:

self (SignalAugmentation)

eval() list[MultiChannelSignal]

Evaluate list of chains.

Parameters:

none

Returns:

The updated SignalAugmentation instance with added chains. Result, allowing for method chaining.

Return type:

self (SignalAugmentation)

gen(frequency_list: list[int], duration: float = 5, sampling_rate: int = -1, mode='sine') SignalAugmentation

Generates a multichannel sound based on the given frequency list, duration, sample rate, and mode.

Parameters:
  • frequency_list (list[int]) – A list of frequencies to generate sound

  • duration (for.) – The duration of the sound in seconds.

  • ms.DEF_SIGNAL_LEN. (Defaults to)

  • sampling_rate (int) – The sample rate of the sound. Defaults to -1.

  • mode (str) – The mode of sound generation. Can be ‘sine’ or

  • the ('speech'. Defaults to 'sine'. See details in)

  • MultiChannelSignal.

Returns:

Object with generated multichannel sound.

Return type:

self (SignalAugmentation)

generate(frequency_list: list[int], duration: float = 5, sampling_rate: int = -1, mode='sine') SignalAugmentation

Generates a multichannel sound based on the given frequency list, duration, sample rate, and mode.

Parameters:
  • frequency_list (list[int]) – A list of frequencies to generate sound

  • duration (for.) – The duration of the sound in seconds.

  • ms.DEF_SIGNAL_LEN. (Defaults to)

  • sampling_rate (int) – The sample rate of the sound. Defaults to -1.

  • mode (str) – The mode of sound generation. Can be ‘sine’ or

  • the ('speech'. Defaults to 'sine'. See details in)

  • MultiChannelSignal.

Returns:

Object with generated multichannel sound.

Return type:

self (SignalAugmentation)

get() MultiChannelSignal

Returns the multichannel sound data stored in the MultiChannelSignal instance.

Returns:

The multichannel sound data.

Return type:

signal (MultiChannelSignal)

info() dict

Returns a dictionary containing information about the SignalAugmentation object.

The dictionary includes the information returned by the info() method of the signal attribute of the object, as well as a key-value pair where the key is ‘chains’ and the value is the chains attribute of the object.

Returns:

A dictionary containing information about the object.

Return type:

dict

merge() SignalAugmentation

Mixes channels of a multichannel sound into a single channel.

Parameters:

none

Returns:

The object with merged sound data,

containing a single channel.

Return type:

self (SignalAugmentation)

mrg() SignalAugmentation

Mixes channels of a multichannel sound into a single channel.

Parameters:

none

Returns:

The object with merged sound data,

containing a single channel.

Return type:

self (SignalAugmentation)

noise_ctrl(noise_level_list: list[float]) SignalAugmentation

Apply noise to a multichannel sound.

Parameters:

noise_level_list (list[float]) – The list of noise levels to apply to each channel.

Returns:

The object noise-controlled multichannel

sound.

Return type:

self (SignalAugmentation)

ns(noise_level_list: list[float]) SignalAugmentation

Apply noise to a multichannel sound.

Parameters:

noise_level_list (list[float]) – The list of noise levels to apply to each channel.

Returns:

The object noise-controlled multichannel

sound.

Return type:

self (SignalAugmentation)

pause_detect(relative_level: list[float]) ndarray[int]

Detects pauses in a multichannel sound.

Args: relative_level (list[float]): The list of relative levels for each channel, signal below this level will be marked as pause.

Returns:

The mask indicating the pauses in the multichannel

sound. The mask has the same shape as the input sound. It contains zeros and ones 0 - pause, 1 - not a pause.

Return type:

np.ndarray

pause_set(pause_map: list, pause_sz: list[int]) SignalAugmentation

Set pauses lengths in multichannel sound to selected values.

Parameters:
  • pause_map (list) – A list of dictionaries containing pairs of (index, length) of pauses for each channel.

  • pause_sz (list[int]) – A list of pause sizes (in samples) for each channel.

Returns:

The object with multichannel sound

with pauses shrunk.

Return type:

self (SignalAugmentation)

pause_shrink(mask: ndarray[int], min_pause: list[int]) SignalAugmentation

Shrink pauses in multichannel sound.

Parameters:
  • mask (np.ndarray) – The mask indicating the pauses in the multichannel sound.

  • min_pause (list[int]) – The list of minimum pause lengths for each channel in samples.

Returns:

The object with multichannel sound with

pauses shrunk.

Return type:

self (SignalAugmentation)

pdt(relative_level: list[float]) ndarray[int]

Detects pauses in a multichannel sound.

Args: relative_level (list[float]): The list of relative levels for each channel, signal below this level will be marked as pause.

Returns:

The mask indicating the pauses in the multichannel

sound. The mask has the same shape as the input sound. It contains zeros and ones 0 - pause, 1 - not a pause.

Return type:

np.ndarray

put(signal: MultiChannelSignal) SignalAugmentation

Updates the multichannel sound data and sample rate of the MultiChannelSignal instance.

Parameters:

signal (MultiChannelSignal) – source of multichannel sound data.

Returns:

The updated SignalAugmentation instance.

Return type:

self (SignalAugmentation)

rdac(source_path: str) list[MultiChannelSignal]

Reads data from a file at the specified path and updates the sample rate and data attributes and applies chains if they exist in object.

Parameters:

source_path (str) – Path to the file containing the data.

Returns:

The updated SignalAugmentation data field.

Return type:

list[MultiChannelSignal]

read_file_apply_chains(source_path: str) list[MultiChannelSignal]

Reads data from a file at the specified path and updates the sample rate and data attributes and applies chains if they exist in object.

Parameters:

source_path (str) – Path to the file containing the data.

Returns:

The updated SignalAugmentation data field.

Return type:

list[MultiChannelSignal]

sbs(signal2: MultiChannelSignal) SignalAugmentation

Concatenates two multichannel sound signals side by side.

Parameters:

signal2 (MultiChannelSignal) – The second multichannel signal.

Returns:

The object with concatenated signal

containing channels of both objects.

Return type:

self (SignalAugmentation)

set_seed(seed: int = -1)

Set seeding value.

side_by_side(signal2: MultiChannelSignal) SignalAugmentation

Concatenates two multichannel sound signals side by side.

Parameters:

signal2 (MultiChannelSignal) – The second multichannel signal.

Returns:

The object with concatenated signal

containing channels of both objects.

Return type:

self (SignalAugmentation)

split(channels_count: int) SignalAugmentation

Splits a multichannel signal (containing single channel) into multiple identical channels.

Parameters:

channels_count (int) – The number of channels to split the signal into.

Returns:

The split multichannel signal, with each

channel identical.

Return type:

self (SignalAugmentation)

splt(channels_count: int) SignalAugmentation

Splits a multichannel signal (containing single channel) into multiple identical channels.

Parameters:

channels_count (int) – The number of channels to split the signal into.

Returns:

The split multichannel signal, with each

channel identical.

Return type:

self (SignalAugmentation)

sum(signal2: MultiChannelSignal) SignalAugmentation

Sums two multichannel sound signals.

Parameters:

signal2 (MultiChannelSignal) – The second multichannel signal.

Returns:

The sum of self._data and signal2

signals as SignalAugmentation object.

Return type:

self (SignalAugmentation)

aug.delay_syntez(delay_us_list: list[int], delay_deviation_list: list[int] = None, seed: int = -1) list[int]

Make delays list