medkit.io.rttm
medkit.io.rttm#
Classes:
|
Convert Rich Transcription Time Marked (.rttm) files containing diarization information into turn segments. |
|
Build Rich Transcription Time Marked (.rttm) files containing diarization information from |
- class RTTMInputConverter(turn_label='turn', speaker_label='speaker', store=None, converter_id=None)[source]#
Convert Rich Transcription Time Marked (.rttm) files containing diarization information into turn segments.
For each turn in a .rttm file, a
Segmentwill be created, with an associatedAttributeholding the name of the turn speaker as value. The segments can be retrieved directly or as part of anAudioDocumentinstance.If a
ProvTraceris set, provenance information will be added for each segment and each attribute (referencing the input converter as the operation).- Parameters
turn_label (
str) – Label of segments representing turns in the .rttm file.speaker_label (
str) – Label of speaker attributes to add to each segment.store (
Optional[Store]) – Optional shared store to hold the annotations when adding them to audio documents.. If none provided, an internal store will be used for each document.converter_id (
Optional[str]) – Identifier of the converter.
Attributes:
Contains all the input converter init parameters.
Methods:
load(rttm_dir[, audio_dir, audio_ext])Load all .rttm file in a directory into a list of
AudioDocumentobjects.load_doc(rttm_file, audio_file)Load a single .rttm file into an
AudioDocument.load_turns(rttm_file, audio_file)Load a .rttm file and return a list of
Segmentobjects.set_prov_tracer(prov_tracer)Enable provenance tracing.
- property description: medkit.core.operation_desc.OperationDescription#
Contains all the input converter init parameters.
- Return type
- set_prov_tracer(prov_tracer)[source]#
Enable provenance tracing.
- Parameters
prov_tracer (
ProvTracer) – The provenance tracer used to trace the provenance.
- load(rttm_dir, audio_dir=None, audio_ext='.wav')[source]#
Load all .rttm file in a directory into a list of
AudioDocumentobjects.For each .rttm file, they must be a corresponding audio file with the same basename, either in the same directory or in an separated audio directory.
- Parameters
rttm_dir (
Union[str,Path]) – Directory containing the .rttm files.audio_dir (
Union[str,Path,None]) – Directory containing the audio files corresponding to the .rttm files, if they are not in rttm_dir.audio_ext (
str) – File extension to use for audio files.
- Return type
List[AudioDocument]- Returns
List[AudioDocument] – List of generated documents.
- load_doc(rttm_file, audio_file)[source]#
Load a single .rttm file into an
AudioDocument.- Parameters
rttm_file (
Union[str,Path]) – Path to the .rttm file.audio_file (
Union[str,Path]) – Path to the corresponding audio file.
- Return type
- Returns
AudioDocument – Generated document.
- class RTTMOutputConverter(turn_label='turn', speaker_label='speaker')[source]#
Build Rich Transcription Time Marked (.rttm) files containing diarization information from
Segmentobjects.There must be a segment for each turn, with an associated
Attributeholding the name of the turn speaker as value. The segments can be passed directly or as part ofAudioDocumentinstances.- Parameters
turn_label (
str) – Label of segments representing turns in the audio documents.speaker_label (
str) – Label of speaker attributes attached to each turn segment.
Methods:
save(docs, rttm_dir[, doc_names])Save
AudioDocumentinstances as .rttm files in a directory.save_doc(doc, rttm_file[, rttm_doc_id])Save a single
AudioDocumentas a .rttm file.save_turn_segments(turn_segments, rttm_file, ...)Save
Segmentobjects into a .rttm file.- save(docs, rttm_dir, doc_names=None)[source]#
Save
AudioDocumentinstances as .rttm files in a directory.- Parameters
docs (
List[AudioDocument]) – List of audio documents to save.rttm_dir (
Union[str,Path]) – Directory into which the generated .rttm files will be stored.doc_names (
Optional[List[str]]) – Optional list of names to use as basenames and file ids for the generated .rttm files (2d column). If none provided, the document ids will be used.
- save_doc(doc, rttm_file, rttm_doc_id=None)[source]#
Save a single
AudioDocumentas a .rttm file.- Parameters
doc (
AudioDocument) – Audio document to save.rttm_file (
Union[str,Path]) – Path of the generated .rttm file.rttm_doc_id (
Optional[str]) – File uid to use for the generated .rttm file (2d column). If none provided, the document uid will be used.
- save_turn_segments(turn_segments, rttm_file, rttm_doc_id)[source]#
Save
Segmentobjects into a .rttm file.- Parameters
turn_segments (
List[Segment]) – Turn segments to save.rttm_file (
Union[str,Path]) – Path of the generated .rttm file.rttm_doc_id (
Optional[str]) – File uid to use for the generated .rttm file (2d column).