medkit.io.medkit_json#

Functions:

load_audio_anns(input_file[, encoding])

Load audio annotations from a medkit-json file generated with save_audio_anns()

load_audio_document(input_file[, ...])

Load an audio document from a medkit-json file generated with save_audio_document()

load_audio_documents(input_file[, encoding])

Load audio documents from a medkit-json file generated with save_audio_documents()

load_text_anns(input_file[, encoding])

Return an iterator on text annotations loaded from a medkit-json file generated with save_text_anns()

load_text_document(input_file[, ...])

Load a text document from a medkit-json file generated with save_text_document().

load_text_documents(input_file[, encoding])

Returns an iterator on text documents loaded from a medkit-json file generated with save_text_documents()

save_audio_anns(anns, output_file[, encoding])

Save audio annotations into a medkit-json file.

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

Save an audio document into a medkit-json file.

save_audio_documents(docs, output_file[, ...])

Save audio documents into a medkit-json file.

save_text_anns(anns, output_file[, encoding])

Save text annotations into a medkit-json file.

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

Save a text document into a medkit-json file.

save_text_documents(docs, output_file[, ...])

Save text documents into a medkit-json file.

load_audio_document(input_file, anns_input_file=None, encoding='utf-8')[source]#

Load an audio document from a medkit-json file generated with save_audio_document()

Parameters:
  • input_file (str or Path) – Path to the medkit-json file containing the document

  • anns_input_file (str or Path, optional) – Optional medkit-json file containing separate annotations of the document.

  • encoding (str, default="utf-8") – Optional encoding of input_file and anns_input_file

Return type:

AudioDocument

Returns:

AudioDocument – The audio document in the file

load_audio_documents(input_file, encoding='utf-8')[source]#

Load audio documents from a medkit-json file generated with save_audio_documents()

Parameters:
  • input_file (str or Path) – Path to the medkit-json file containing the documents

  • encoding (str, default="utf-8") – Optional encoding of input_file

Return type:

Iterator[AudioDocument]

Returns:

iterator of AudioDocument – An iterator to the audio documents in the file

load_audio_anns(input_file, encoding='utf-8')[source]#

Load audio annotations from a medkit-json file generated with save_audio_anns()

Parameters:
  • input_file (str or Path) – Path to the medkit-json file containing the annotations

  • encoding (str, default="utf-8") – Optional encoding of input_file

Return type:

Iterator[Segment]

Returns:

iterator of Segment – An iterator to the audio annotations in the file

save_audio_document(doc, output_file, split_anns=False, anns_output_file=None, encoding='utf-8')[source]#

Save an audio document into a medkit-json file.

Parameters:
  • doc (AudioDocument) – The audio document to save

  • output_file (str or Path) – Path of the generated medkit-json file

  • split_anns (bool, 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_file (str 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.

  • encoding (str, default="utf-8") – Optional encoding of output_file and anns_output_file

save_audio_documents(docs, output_file, encoding='utf-8')[source]#

Save audio documents into a medkit-json file.

Parameters:
  • docs (iterable of AudioDocument) – The audio documents to save

  • output_file (str or Path) – Path of the generated medkit-json file

  • encoding (str, default="utf-8") – Optional encoding of output_file

save_audio_anns(anns, output_file, encoding='utf-8')[source]#

Save audio annotations into a medkit-json file.

Parameters:
  • docs (iterable of Segment) – The audio annotations to save

  • output_file (str or Path) – Path of the generated medkit-json file

  • encoding (str, default="utf-8") – Optional encoding of output_file

load_text_document(input_file, anns_input_file=None, encoding='utf-8')[source]#

Load a text document from a medkit-json file generated with save_text_document().

Parameters:
  • input_file (str or Path) – Path to the medkit-json file containing the document

  • anns_input_file (str or Path, optional) – Optional medkit-json file containing separate annotations of the document.

  • encoding (str, default="utf-8") – Optional encoding of input_file and anns_input_file

Return type:

TextDocument

Returns:

TextDocument – The text document in the file

load_text_documents(input_file, encoding='utf-8')[source]#

Returns an iterator on text documents loaded from a medkit-json file generated with save_text_documents()

Parameters:
  • input_file (str or Path) – Path to the medkit-json file containing the documents

  • encoding (str, default="utf-8") – Optional encoding of input_file

Return type:

Iterator[TextDocument]

Returns:

iterator of TextDocument – An iterator to the text documents in the file

load_text_anns(input_file, encoding='utf-8')[source]#

Return an iterator on text annotations loaded from a medkit-json file generated with save_text_anns()

Parameters:
  • input_file (str or Path) – Path to the medkit-json file containing the annotations

  • encoding (str, default="utf-8") – Optional encoding of input_file

Return type:

Iterator[TextAnnotation]

Returns:

iterator of TextAnnotation – An iterator to the text annotations in the file

save_text_document(doc, output_file, split_anns=False, anns_output_file=None, encoding='utf-8')[source]#

Save a text document into a medkit-json file.

Parameters:
  • doc (TextDocument) – The text document to save

  • output_file (str or Path) – Path of the generated medkit-json file

  • split_anns (bool, 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_file (str 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.

  • encoding (str, default="utf-8") – Optional encoding of output_file and anns_output_file

save_text_documents(docs, output_file, encoding='utf-8')[source]#

Save text documents into a medkit-json file.

Parameters:
  • docs (iterable of TextDocument) – The text documents to save

  • output_file (str or Path) – Path of the generated medkit-json file

  • encoding (str, default="utf-8") – Optional encoding of output_file

save_text_anns(anns, output_file, encoding='utf-8')[source]#

Save text annotations into a medkit-json file.

Parameters:
  • anns (iterable of TextAnnotation) – The text annotations to save

  • output_file (str or Path) – Path of the generated medkit-json file

  • encoding (str, default="utf-8") – Optional encoding of output_file