Base Class¶
Base class for some data corpus and the samples it contains.
-
class
pyroomacoustics.datasets.base.
AudioSample
(data, fs, **kwargs)¶ Bases:
pyroomacoustics.datasets.base.Sample
We add some methods specific to display and listen to audio samples. The sampling frequency of the samples is an extra parameter.
For multichannel audio, we assume the same format used by
`scipy.io.wavfile <https://docs.scipy.org/doc/scipy-0.14.0/reference/io.html#module-scipy.io.wavfile>`_
, that isdata
is then a 2D array with each column being a channel.-
data
¶ The actual data
Type: array_like
-
fs
¶ The sampling frequency of the input signal
Type: int
-
meta
¶ An object containing the sample metadata. They can be accessed using the dot operator
Type: pyroomacoustics.datasets.Meta
-
play
(**kwargs)¶ Play the sound sample. This function uses the sounddevice package for playback.
It takes the same keyword arguments as sounddevice.play.
-
plot
(NFFT=512, noverlap=384, **kwargs)¶ Plot the spectrogram of the audio sample.
It takes the same keyword arguments as matplotlib.pyplot.specgram.
-
-
class
pyroomacoustics.datasets.base.
Dataset
¶ Bases:
object
The base class for a data corpus. It has basically a list of samples and a filter function
-
samples
¶ A list of all the Samples in the dataset
Type: list
-
info
¶ This dictionary keeps track of all the fields in the metadata. The keys of the dictionary are the metadata field names. The values are again dictionaries, but with the keys being the possible values taken by the metadata and the associated value, the number of samples with this value in the corpus.
Type: dict
-
add_sample
(sample)¶ Add a sample to the Dataset and keep track of the metadata.
-
add_sample_matching
(sample, **kwargs)¶ The sample is added to the corpus only if all the keyword arguments match the metadata of the sample. The match is operated by
pyroomacoustics.datasets.Meta.match
.
-
filter
(**kwargs)¶ Filter the corpus and selects samples that match the criterias provided The arguments to the keyword can be 1) a string, 2) a list of strings, 3) a function. There is a match if one of the following is True.
value == attribute
value
is a list andattribute in value == True
value
is a callable (a function) andvalue(attribute) == True
-
head
(n=5)¶ Print n samples from the dataset
-
-
class
pyroomacoustics.datasets.base.
Meta
(**attr)¶ Bases:
object
A simple class that will take a dictionary as input and put the values in attributes named after the keys. We use it to store metadata for the samples
The parameters can be any set of keyword arguments. They will all be transformed into attribute of the object.
-
as_dict
()¶ Returns all the attribute/value pairs of the object as a dictionary
-
match
(**kwargs)¶ The key/value pairs given by the keyword arguments are compared to the attribute/value pairs of the object. If the values all match, True is returned. Otherwise False is returned. If a keyword argument has no attribute counterpart, an error is raised. Attributes that do not have a keyword argument counterpart are ignored.
There are three ways to match an attribute with keyword=value: 1.
value == attribute
2.value
is a list andattribute in value == True
3.value
is a callable (a function) andvalue(attribute) == True
-
-
class
pyroomacoustics.datasets.base.
Sample
(data, **kwargs)¶ Bases:
object
The base class for a dataset sample. The idea is that different corpus will have different attributes for the samples. They should at least have a data attribute.
-
data
¶ The actual data
Type: array_like
-
meta
¶ An object containing the sample metadata. They can be accessed using the dot operator
Type: pyroomacoustics.datasets.Meta
-