medkit.io.medkit_json.audio#

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()

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.

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 (Union[str, Path]) – Path to the medkit-json file containing the document

  • anns_input_file (Union[str, Path, None]) – Optional medkit-json file containing separate annotations of the document.

  • encoding (Optional[str]) – 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 (Union[str, Path]) – Path to the medkit-json file containing the documents

  • encoding (Optional[str]) – Optional encoding of input_file

Return type

Iterator[AudioDocument]

Returns

Iterator[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 (Union[str, Path]) – Path to the medkit-json file containing the annotations

  • encoding (Optional[str]) – Optional encoding of input_file

Return type

Iterator[Segment]

Returns

Iterator[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 (Union[str, Path]) – Path of the generated medkit-json file

  • split_anns (bool) – 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 (Union[str, Path, None]) – 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 (Optional[str]) – 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[AudioDocument]) – The audio documents to save

  • output_file (Union[str, Path]) – Path of the generated medkit-json file

  • encoding (Optional[str]) – 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 – The audio annotations to save

  • output_file (Union[str, Path]) – Path of the generated medkit-json file

  • encoding (Optional[str]) – Optional encoding of output_file