medkit.io.medkit_json#

Submodules#

Functions#

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

Load audio annotations from JSON.

load_audio_document(→ medkit.core.audio.AudioDocument)

Load a single audio document from JSON.

load_audio_documents(...)

Load multiple audio documents from JSON.

save_audio_anns(anns, output_file[, encoding])

Save audio annotations to 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.

load_text_anns(→ Iterator[medkit.core.text.TextAnnotation])

Load text annotations from JSON.

load_text_document(→ medkit.core.text.TextDocument)

Load a text document from JSON.

load_text_documents(...)

Load multiple text documents from JSON.

save_text_anns(anns, output_file[, encoding])

Save text annotations to JSON.

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

Save a text document to JSON.

save_text_documents(docs, output_file[, encoding])

Save multiple text documents to JSON.

Package Contents#

medkit.io.medkit_json.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.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.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.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.

medkit.io.medkit_json.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.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.load_text_anns(input_file: str | pathlib.Path, encoding: str | None = 'utf-8') Iterator[medkit.core.text.TextAnnotation]#

Load text 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 TextAnnotation

An iterator to the text annotations in the file

See also

save_text_anns

Save text annotations to JSON.

medkit.io.medkit_json.load_text_document(input_file: str | pathlib.Path, anns_input_file: str | pathlib.Path | None = None, encoding: str | None = 'utf-8') medkit.core.text.TextDocument#

Load a text 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:
TextDocument

The text document in the file

See also

save_text_document

Save a text document to JSON.

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

Load multiple text 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 TextDocument

An iterator to the text documents in the file

See also

save_text_documents

Save multiple text documents to JSON.

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

Save text annotations to JSON.

Parameters:
annsiterable of TextAnnotation

The text 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_text_anns

Load text annotations from JSON.

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

Save a text document to JSON.

Parameters:
docTextDocument

The text 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_text_document

Load a text document from JSON.

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

Save multiple text documents to JSON.

Parameters:
docsiterable of TextDocument

The text 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_text_documents

Load multiple text documents from JSON.