medkit.core.audio.document#

Classes:

AudioDocument(audio[, anns, attrs, ...])

Document holding audio annotations.

class AudioDocument(audio, anns=None, attrs=None, metadata=None, uid=None)[source]#

Document holding audio annotations.

Variables
  • uid (str) – Unique identifier of the document.

  • audio – Audio buffer containing the entire signal of the document.

  • anns (AudioAnnotationContainer) – Annotations of the document. Stored in an AudioAnnotationContainer but can be passed as a list at init.

  • attrs (AttributeContainer) – Attributes of the document. Stored in an AttributeContainer but can be passed as a list at init

  • metadata (Dict[str, Any]) – Document metadata.

  • raw_segment (Segment) – Auto-generated segment containing the full unprocessed document audio.

Attributes:

RAW_LABEL

Label to be used for raw segment

Methods:

from_dir(path[, pattern])

Create documents from audio files in a directory

from_file(path)

Create document from an audio file

get_subclass_for_data_dict(data_dict)

Return the subclass that corresponds to the class name found in a data dict

RAW_LABEL: ClassVar[str] = 'RAW_AUDIO'#

Label to be used for raw segment

classmethod get_subclass_for_data_dict(data_dict)#

Return the subclass that corresponds to the class name found in a data dict

Parameters

data_dict (Dict[str, Any]) – Data dict returned by the to_dict() method of a subclass (or of the base class itself)

Return type

Optional[Type[Self]]

Returns

subclass – Subclass that generated data_dict, or None if data_dict correspond to the base class itself.

classmethod from_file(path)[source]#

Create document from an audio file

Parameters

path (PathLike) – Path to the audio file. Supports all file formats handled by libsndfile (http://www.mega-nerd.com/libsndfile/#Features)

Return type

Self

Returns

AudioDocument – Audio document with signal of path as audio. The file path is included in the document metadata.

classmethod from_dir(path, pattern='*.wav')[source]#

Create documents from audio files in a directory

Parameters
Return type

List[Self]

Returns

List[AudioDocument] – Audio documents with signal of each file as audio