medkit.io.medkit_json.audio#

Functions#

load_audio_document(→ medkit.core.audio.AudioDocument)

Load a single audio document from JSON.

load_audio_documents(...)

Load multiple audio documents from JSON.

load_audio_anns(→ Iterator[medkit.core.audio.Segment])

Load audio annotations from JSON.

save_audio_document(doc, output_file[, split_anns, ...])

Save a single audio document to JSON.

save_audio_documents(docs, output_file[, encoding])

Save multiple audio documents to JSON.

save_audio_anns(anns, output_file[, encoding])

Save audio annotations to JSON.

Module Contents#

medkit.io.medkit_json.audio.load_audio_document(input_file: str | pathlib.Path, anns_input_file: str | pathlib.Path | None = None, encoding: str | None = 'utf-8') medkit.core.audio.AudioDocument#

Load a single audio document from JSON.

Parameters:
input_filestr or Path

Path to the medkit-json file containing the document

anns_input_filestr or Path, optional

Optional medkit-json file containing separate annotations of the document.

encodingstr, default=”utf-8”

Optional encoding of input_file and anns_input_file

Returns:
AudioDocument

The audio document in the file

See also

save_audio_document

Save a single audio document to JSON.

medkit.io.medkit_json.audio.load_audio_documents(input_file: str | pathlib.Path, encoding: str | None = 'utf-8') Iterator[medkit.core.audio.AudioDocument]#

Load multiple audio documents from JSON.

Parameters:
input_filestr or Path

Path to the medkit-json file containing the documents

encodingstr, default=”utf-8”

Optional encoding of input_file

Returns:
iterator of AudioDocument

An iterator to the audio documents in the file

See also

save_audio_documents

Save multiple audio documents to JSON.

medkit.io.medkit_json.audio.load_audio_anns(input_file: str | pathlib.Path, encoding: str | None = 'utf-8') Iterator[medkit.core.audio.Segment]#

Load audio annotations from JSON.

Parameters:
input_filestr or Path

Path to the medkit-json file containing the annotations

encodingstr, default=”utf-8”

Optional encoding of input_file

Returns:
iterator of Segment

An iterator to the audio annotations in the file

See also

save_audio_anns

Save audio annotations to JSON.

medkit.io.medkit_json.audio.save_audio_document(doc: medkit.core.audio.AudioDocument, output_file: str | pathlib.Path, split_anns: bool = False, anns_output_file: str | pathlib.Path | None = None, encoding: str | None = 'utf-8')#

Save a single audio document to JSON.

Parameters:
docAudioDocument

The audio document to save

output_filestr or Path

Path of the generated medkit-json file

split_annsbool, default=False

If True, the annotations will be saved in a separate medkit-json file instead of being included in the main document file

anns_output_filestr or Path, optional

Path of the medkit-json file storing the annotations if split_anns is True. If not provided, output_file will be used with an extra “_anns” suffix.

encodingstr, default=”utf-8”

Optional encoding of output_file and anns_output_file

See also

load_audio_document

Load a single audio document from JSON.

medkit.io.medkit_json.audio.save_audio_documents(docs: Iterable[medkit.core.audio.AudioDocument], output_file: str | pathlib.Path, encoding: str | None = 'utf-8')#

Save multiple audio documents to JSON.

Parameters:
docsiterable of AudioDocument

The audio documents to save

output_filestr or Path

Path of the generated medkit-json file

encodingstr, default=”utf-8”

Optional encoding of output_file

See also

load_audio_documents

Load multiple audio documents from JSON.

medkit.io.medkit_json.audio.save_audio_anns(anns: Iterable[medkit.core.audio.Segment], output_file: str | pathlib.Path, encoding: str | None = 'utf-8')#

Save audio annotations to JSON.

Parameters:
docsiterable of Segment

The audio annotations to save

output_filestr or Path

Path of the generated medkit-json file

encodingstr, default=”utf-8”

Optional encoding of output_file

See also

load_audio_anns

Load audio annotations to JSON.