§
    @Äj&  ã                   óÞ   — d dl mZ d dlZd dlZd dlmZmZmZmZ e G d„ d¦  «        ¦   «         Z	 e	dd¬¦  «        Z
d	e
_        e G d
„ d¦  «        ¦   «         Z edd¬¦  «        Zde_        dS )é    )Ú	dataclassN)Úsquim_objective_baseÚsquim_subjective_baseÚSquimObjectiveÚSquimSubjectivec                   óJ   — e Zd ZU dZeed<   eed<   defd„Ze	d„ ¦   «         Z
dS )ÚSquimObjectiveBundleu,  Data class that bundles associated information to use pretrained
    :py:class:`~torchaudio.models.SquimObjective` model.

    This class provides interfaces for instantiating the pretrained model along with
    the information necessary to retrieve pretrained weights and additional data
    to be used with the model.

    Torchaudio library instantiates objects of this class, each of which represents
    a different pretrained model. Client code should access pretrained models via these
    instances.

    This bundle can estimate objective metric scores for speech enhancement, such as STOI, PESQ, Si-SDR.
    A typical use case would be a flow like `waveform -> list of scores`. Please see below for the code example.

    Example: Estimate the objective metric scores for the input waveform.
        >>> import torch
        >>> import torchaudio
        >>> from torchaudio.pipelines import SQUIM_OBJECTIVE as bundle
        >>>
        >>> # Load the SquimObjective bundle
        >>> model = bundle.get_model()
        Downloading: "https://download.pytorch.org/torchaudio/models/squim_objective_dns2020.pth"
        100%|â–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆ| 28.2M/28.2M [00:03<00:00, 9.24MB/s]
        >>>
        >>> # Resample audio to the expected sampling rate
        >>> waveform = torchaudio.functional.resample(waveform, sample_rate, bundle.sample_rate)
        >>>
        >>> # Estimate objective metric scores
        >>> scores = model(waveform)
        >>> print(f"STOI: {scores[0].item()},  PESQ: {scores[1].item()}, SI-SDR: {scores[2].item()}.")
    Ú_pathÚ_sample_rateÚreturnc                 óî   — t          ¦   «         }t          j                             d| j        › �¦  «        }t          j        |d¬¦  «        }|                     |¦  «         |                     ¦   «          |S )z¦Construct the SquimObjective model, and load the pretrained weight.

        Returns:
            Variation of :py:class:`~torchaudio.models.SquimObjective`.
        úmodels/T©Úweights_only)	r   Ú
torchaudioÚutilsÚ_download_assetr
   ÚtorchÚloadÚload_state_dictÚeval©ÚselfÚmodelÚpathÚ
state_dicts       úUC:\Projects\Historical\venv\Lib\site-packages\torchaudio/pipelines/_squim_pipeline.pyÚ	get_modelzSquimObjectiveBundle.get_model.   sj   € õ %Ñ&Ô&ˆÝÔ×/Ò/Ð0F¸$¼*Ð0FÐ0FÑGÔGˆÝ”Z °4Ð8Ñ8Ô8ˆ
Ø×Ò˜jÑ)Ô)Ð)Ø�
Š
‰ŒˆØˆó    c                 ó   — | j         S ©zUSample rate of the audio that the model is trained on.

        :type: float
        ©r   ©r   s    r   Úsample_ratez SquimObjectiveBundle.sample_rate;   ó   € ð Ô Ð r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__Úfloatr   r   Úpropertyr$   © r   r   r	   r	   	   sn   € € € € € € ðð ð@ €J€J�JØÐÐÑð˜>ð ð ð ð ð ð!ð !ñ „Xð!ð !ð !r   r	   zsquim_objective_dns2020.pthi€>  r"   að  SquimObjective pipeline trained using approach described in
    :cite:`kumar2023torchaudio` on the *DNS 2020 Dataset* :cite:`reddy2020interspeech`.

    The underlying model is constructed by :py:func:`torchaudio.models.squim_objective_base`.
    The weights are under `Creative Commons Attribution 4.0 International License
    <https://github.com/microsoft/DNS-Challenge/blob/interspeech2020/master/LICENSE>`__.

    Please refer to :py:class:`SquimObjectiveBundle` for usage instructions.
    c                   óJ   — e Zd ZU dZeed<   eed<   defd„Ze	d„ ¦   «         Z
dS )ÚSquimSubjectiveBundleu±  Data class that bundles associated information to use pretrained
    :py:class:`~torchaudio.models.SquimSubjective` model.

    This class provides interfaces for instantiating the pretrained model along with
    the information necessary to retrieve pretrained weights and additional data
    to be used with the model.

    Torchaudio library instantiates objects of this class, each of which represents
    a different pretrained model. Client code should access pretrained models via these
    instances.

    This bundle can estimate subjective metric scores for speech enhancement, such as MOS.
    A typical use case would be a flow like `waveform -> score`. Please see below for the code example.

    Example: Estimate the subjective metric scores for the input waveform.
        >>> import torch
        >>> import torchaudio
        >>> from torchaudio.pipelines import SQUIM_SUBJECTIVE as bundle
        >>>
        >>> # Load the SquimSubjective bundle
        >>> model = bundle.get_model()
        Downloading: "https://download.pytorch.org/torchaudio/models/squim_subjective_bvcc_daps.pth"
        100%|â–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆ| 360M/360M [00:09<00:00, 41.1MB/s]
        >>>
        >>> # Resample audio to the expected sampling rate
        >>> waveform = torchaudio.functional.resample(waveform, sample_rate, bundle.sample_rate)
        >>> # Use a clean reference (doesn't need to be the reference for the waveform) as the second input
        >>> reference = torchaudio.functional.resample(reference, sample_rate, bundle.sample_rate)
        >>>
        >>> # Estimate subjective metric scores
        >>> score = model(waveform, reference)
        >>> print(f"MOS: {score}.")
    r
   r   r   c                 óî   — t          ¦   «         }t          j                             d| j        › �¦  «        }t          j        |d¬¦  «        }|                     |¦  «         |                     ¦   «          |S )z¦Construct the SquimSubjective model, and load the pretrained weight.
        Returns:
            Variation of :py:class:`~torchaudio.models.SquimObjective`.
        r   Tr   )	r   r   r   r   r
   r   r   r   r   r   s       r   r   zSquimSubjectiveBundle.get_modelz   sj   € õ
 &Ñ'Ô'ˆÝÔ×/Ò/Ð0F¸$¼*Ð0FÐ0FÑGÔGˆÝ”Z °4Ð8Ñ8Ô8ˆ
Ø×Ò˜jÑ)Ô)Ð)Ø�
Š
‰ŒˆØˆr   c                 ó   — | j         S r!   r"   r#   s    r   r$   z!SquimSubjectiveBundle.sample_rate†   r%   r   N)r&   r'   r(   r)   r*   r+   r,   r   r   r-   r$   r.   r   r   r0   r0   S   sn   € € € € € € ð ð  ðD €J€J�JØÐÐÑð
˜?ð 
ð 
ð 
ð 
ð ð!ð !ñ „Xð!ð !ð !r   r0   zsquim_subjective_bvcc_daps.ptha
  SquimSubjective pipeline trained
    as described in :cite:`manocha2022speech` and :cite:`kumar2023torchaudio`
    on the *BVCC* :cite:`cooper2021voices` and *DAPS* :cite:`mysore2014can` datasets.

    The underlying model is constructed by :py:func:`torchaudio.models.squim_subjective_base`.
    The weights are under `Creative Commons Attribution Non Commercial 4.0 International
    <https://zenodo.org/record/4660670#.ZBtWPOxuerN>`__.

    Please refer to :py:class:`SquimSubjectiveBundle` for usage instructions.
    )Údataclassesr   r   r   Útorchaudio.modelsr   r   r   r   r	   ÚSQUIM_OBJECTIVEr)   r0   ÚSQUIM_SUBJECTIVEr.   r   r   ú<module>r7      s  ðØ !Ð !Ð !Ð !Ð !Ð !à €€€Ø Ð Ð Ð à jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jÐ jð ð7!ð 7!ð 7!ð 7!ð 7!ñ 7!ô 7!ñ „ð7!ðt 'Ð&Ø!Øðñ ô €ð€Ô ð ð8!ð 8!ð 8!ð 8!ð 8!ñ 8!ô 8!ñ „ð8!ðv )Ð(Ø$Øðñ ô Ð ð	Ð Ô Ð Ð r   