Datacard¶
- class audbcards.Datacard(dataset, *, path='datasets', example=True, sphinx_build_dir=None, sphinx_src_dir=None, cache_root=None)[source]¶
Datacard of a dataset.
The datacard object writes a RST file for a given dataset, which can then be used to generate an HTML datacard page using
sphinx
.- Parameters
dataset (
Dataset
) – dataset objectpath (
str
) – path to folder that store datacard filesexample (
bool
) – ifTrue
, include an audio or video example in the data card showing the waveform of the audio and an interactive playersphinx_build_dir (
Optional
[str
]) – build dir of sphinx. If notNone
andexample
isTrue
, a call toaudbcards.Datacard.player()
will store an example audio file under<sphinx_build_dir>/<path>/<dataset-name>/
sphinx_src_dir (
Optional
[str
]) – source dir of sphinx. If notNone
andexample
isTrue
, a call toaudbcards.Datacard.player()
will store a waveform plot of the example audio file under<sphinx_src_dir>/<path>/<dataset-name>/
cache_root (
Optional
[str
]) – cache folder. IfNone
, the environmental variableAUDBCARDS_CACHE_ROOT
, oraudbcards.config.CACHE_ROOT
is used
file_duration_distribution¶
- Datacard.file_duration_distribution¶
Minimum and maximum of files durations, and plotted distribution.
This generates a single line containing the mininimum and maximum values of files durations.
If
audbcards.Datacard.sphinx_src_dir
is notNone
(e.g. when used in the sphinx extension), and the dataset contains audio or video files, an image is stored in the file<dataset-name>-<dataset-version>-file-duration-distribution.png
, which is cached in<cache-root>/<dataset-name>/<dataset-version>/
and copied to the sphinx source folder into<sphinx-src-dir>/<path><dataset-name>/
. The image is displayed inline between the minimum and maximum values. If all duration values are the same, no distribution plot is created.
player()¶
- Datacard.player()[source]¶
Create an audio/video player showing the waveform.
If
audbcards.Datacard.sphinx_build_dir
oraudbcards.Datacard.sphinx_src_dir
is notNone
, an example media file is cached in the folder<dataset-name>-<dataset-version>-player-media/
inside<cache-root>/<dataset-name>/<dataset-version>/
, using the same sub-folder structure as the media file has inside its dataset. Ifaudbcards.Datacard.sphinx_build_dir
is notNone
, the media sub-folder structure is also copied to the sphinx build dir into<sphinx-build-dir>/<path>/<dataset-name>/
, and an audio element referencing this file is added to the returned RST string.If
audbcards.Datacard.sphinx_src_dir
is notNone
, a plot of the waveform of the media file is cached under<dataset-name>-<dataset-version>-player-waveform.png
inside<cache-root>/<dataset-name>/<dataset-version>/
. It is also copied to the sphinx source folder into<sphinx-src-dir>/<path>/<dataset-name>/
, and referenced at the beginning of the returned RST string.If
audbcards.Datacard.sphinx_build_dir
andaudbcards.Datacard.sphinx_src_dir
areNone
, an empty string is returned.- Return type
str
- Returns
String containing RST code to include the player
save()¶
- Datacard.save(file=None)[source]¶
Save content of rendered template to rst.
- Parameters
file (
Optional
[str
]) – name of output RST file. IfNone
andaudbcards.Datacard.sphinx_src_dir
is notNone
, the RST file will be stored as<sphinx_src_dir>/<path>/<dataset>.rst
segment_duration_distribution¶
- Datacard.segment_duration_distribution¶
Minimum and maximum of segment durations, and plotted distribution.
This generates a single line containing the mininimum and maximum values of segment durations.
If
audbcards.Datacard.sphinx_src_dir
is notNone
(e.g. when used in the sphinx extension), and the dataset contains segments, an image is stored in the file<dataset-name>-<dataset-version>-segment-duration-distribution.png
, which is cached in<cache-root>/<dataset-name>/<dataset-version>/
and copied to the sphinx source folder into<sphinx-src-dir>/<path><dataset-name>/
. The image is displayed inline between the minimum and maximum values. If all duration values are the same, no distribution plot is created.