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', 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
Segment
will be created, with an associatedAttribute
holding the name of the turn speaker as value. The segments can be retrieved directly or as part of anAudioDocument
instance.If a
ProvTracer
is 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.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 files in a directory into a list of
AudioDocument
objects.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
Segment
objects.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 files in a directory into a list of
AudioDocument
objects.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
Segment
objects.There must be a segment for each turn, with an associated
Attribute
holding the name of the turn speaker as value. The segments can be passed directly or as part ofAudioDocument
instances.- 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
AudioDocument
instances as .rttm files in a directory.save_doc
(doc, rttm_file[, rttm_doc_id])Save a single
AudioDocument
as a .rttm file.save_turn_segments
(turn_segments, rttm_file, ...)Save
Segment
objects into a .rttm file.- save(docs, rttm_dir, doc_names=None)[source]#
Save
AudioDocument
instances 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
AudioDocument
as 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
Segment
objects 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).