:py:mod:`medkit.core.audio.document`
====================================

.. py:module:: medkit.core.audio.document


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   medkit.core.audio.document.AudioDocument




.. py:class:: AudioDocument(audio: medkit.core.audio.audio_buffer.AudioBuffer, anns: Sequence[medkit.core.audio.annotation.Segment] | None = None, attrs: Sequence[medkit.core.Attribute] | None = None, metadata: dict[str, Any] | None = None, uid: str | None = None)


   Bases: :py:obj:`medkit.core.dict_conv.SubclassMapping`

   
   Document holding audio annotations.














   :Attributes:

       **uid: str**
           Unique identifier of the document.

       **audio: AudioBuffer**
           Audio buffer containing the entire signal of the document.

       **anns: :class:`~.audio.AudioAnnotationContainer`**
           Annotations of the document. Stored in an
           :class:`~.audio.AudioAnnotationContainer` but can be passed as a list at init.

       **attrs: :class:`~.core.AttributeContainer`**
           Attributes of the document. Stored in an
           :class:`~.core.AttributeContainer` but can be passed as a list at init

       **metadata: dict of str to Any**
           Document metadata.

       **raw_segment: :class:`~.audio.Segment`**
           Auto-generated segment containing the full unprocessed document audio.


   ..
       !! processed by numpydoc !!
   .. py:property:: audio
      :type: medkit.core.audio.audio_buffer.AudioBuffer


   .. py:attribute:: RAW_LABEL
      :type: ClassVar[str]
      :value: 'RAW_AUDIO'

      
      Label to be used for raw segment
















      ..
          !! processed by numpydoc !!

   .. py:attribute:: uid
      :type: str

      

   .. py:attribute:: anns
      :type: medkit.core.audio.annotation_container.AudioAnnotationContainer

      

   .. py:attribute:: attrs
      :type: medkit.core.AttributeContainer

      

   .. py:attribute:: metadata
      :type: dict[str, Any]

      

   .. py:attribute:: raw_segment
      :type: medkit.core.audio.annotation.Segment

      

   .. py:method:: _generate_raw_segment(audio: medkit.core.audio.audio_buffer.AudioBuffer, doc_id: str) -> medkit.core.audio.annotation.Segment
      :classmethod:


   .. py:method:: __init_subclass__()
      :classmethod:


   .. py:method:: to_dict(with_anns: bool = True) -> dict[str, Any]


   .. py:method:: from_dict(data: dict[str, Any]) -> typing_extensions.Self
      :classmethod:


   .. py:method:: from_file(path: os.PathLike) -> typing_extensions.Self
      :classmethod:

      
      Create document from an audio file.


      :Parameters:

          **path: path-like**
              Path to the audio file. Supports all file formats handled by
              `libsndfile` (http://www.mega-nerd.com/libsndfile/#Features)

      :Returns:

          AudioDocument
              Audio document with signal of `path` as audio. The file path is
              included in the document metadata.













      ..
          !! processed by numpydoc !!

   .. py:method:: from_dir(path: os.PathLike, pattern: str = '*.wav') -> list[typing_extensions.Self]
      :classmethod:

      
      Create documents from audio files in a directory.


      :Parameters:

          **path: path-like**
              Path of the directory containing audio files

          **pattern: str, default="*.wav"**
              Glob pattern to match audio files in `path`. Supports all file
              formats handled by `libsndfile`
              (http://www.mega-nerd.com/libsndfile/#Features)

      :Returns:

          List[AudioDocument]
              Audio documents with signal of each file as audio













      ..
          !! processed by numpydoc !!


