Datacard¶
- class audbcards.Datacard(dataset, *, path='datasets', example=True, table_preview=True, sphinx_build_dir=None, sphinx_src_dir=None, template_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 example section in the data card, showing the waveform of the audio and an interactive player for audio or video examples, and the content of JSON examples. IfFalse, the example section is omittedtable_preview (
bool) – ifTrue, the rows of the tables overview in the data card can be clicked to show a preview of the content of each tablesphinx_build_dir (
str|None) – build dir of sphinx. If notNoneandexampleisTrue, a call toaudbcards.Datacard.player()will store an example audio file under<sphinx_build_dir>/<path>/<dataset-name>/sphinx_src_dir (
str|None) – source dir of sphinx. If notNoneandexampleisTrue, a call toaudbcards.Datacard.player()will store a waveform plot of the example audio file under<sphinx_src_dir>/<path>/<dataset-name>/template_dir (
str|None) – folder containing user defined template files. The following templates will overwrite default ones:datacard_description.j2,datacard_example.j2,datacard_header.j2,datacard.j2,datacard_schemes.j2,datacard_tables.j2,datasets.j2cache_root (
str|None) – cache folder. IfNone, the environmental variableAUDBCARDS_CACHE_ROOT, oraudbcards.config.CACHE_ROOTis used
cache_root¶
- Datacard.cache_root¶
Cache root folder.
content¶
- Datacard.content¶
Property Accessor for rendered jinja2 content.
dataset¶
- Datacard.dataset¶
Dataset object.
example¶
- Datacard.example¶
If the example section with media or JSON examples should be included.
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_diris 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.
json()¶
path¶
- Datacard.path¶
Folder to store datacard.
player()¶
- Datacard.player()[source]¶
Create an audio/video player showing the waveform.
If
audbcards.Datacard.sphinx_build_diroraudbcards.Datacard.sphinx_src_diris 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_diris 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_diris notNone, a plot of the waveform of the media file is cached under<dataset-name>-<dataset-version>-player-waveform.pnginside<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_dirandaudbcards.Datacard.sphinx_src_dirareNone, an empty string is returned.- Return type:
str- Returns:
String containing RST code to include the player
rst_preamble¶
- Datacard.rst_preamble¶
RST code added at top of data card.
save()¶
- Datacard.save(file=None)[source]¶
Save content of rendered template to rst.
- Parameters:
file (
str|None) – name of output RST file. IfNoneandaudbcards.Datacard.sphinx_src_diris 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_diris 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.
sphinx_build_dir¶
- Datacard.sphinx_build_dir¶
Sphinx build dir.
sphinx_src_dir¶
- Datacard.sphinx_src_dir¶
Sphinx source dir.
table_preview¶
- Datacard.table_preview¶
If a preview of the content of each table should be included.
template_dir¶
- Datacard.template_dir¶
User defined template dir.