§
    @Äj/  ã            	       ó4  — d dl Z d dlmZ d dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZmZ dZd	g d
¢g d¢dœddddœdœZdZdZdefd„Zdedededee         fd„Zdedefd„Zdedefd„Z G d„ de
¦  «        Z G d „ d!e¦  «        Z G d"„ d#e¦  «        ZdS )$é    N)ÚPath)ÚListÚTupleÚUnion)ÚTensor)ÚDataset)Údownload_url_to_file)Ú_extract_zipÚ_load_waveformi€>  zvox1_dev_wav.zip)zIhttps://thor.robots.ox.ac.uk/~vgg/data/voxceleb/vox1a/vox1_dev_wav_partaazIhttps://thor.robots.ox.ac.uk/~vgg/data/voxceleb/vox1a/vox1_dev_wav_partabzIhttps://thor.robots.ox.ac.uk/~vgg/data/voxceleb/vox1a/vox1_dev_wav_partaczIhttps://thor.robots.ox.ac.uk/~vgg/data/voxceleb/vox1a/vox1_dev_wav_partad)Ú@21ec6ca843659ebc2fdbe04b530baa4f191ad4b0971912672d92c158f32226a0Ú@311d21e0c8cbf33573a4fce6c80e5a279d80736274b381c394319fc557159a04Ú@92b64465f2b2a3dc0e4196ae8dd6828cbe9ddd1f089419a11e4cbfe2e1750df0Ú@00e6190c770b27f27d2a3dd26ee15596b17066b715ac111906861a7d09a211a5)Úarchive_nameÚurlsÚ	checksumszvox1_test_wav.zipzGhttps://thor.robots.ox.ac.uk/~vgg/data/voxceleb/vox1a/vox1_test_wav.zipÚ@8de57f347fe22b2c24526e9f444f689ecf5096fc2a92018cf420ff6b5b15eaea)r   ÚurlÚchecksum©ÚdevÚtestzBhttps://www.robots.ox.ac.uk/~vgg/data/voxceleb/meta/iden_split.txtzAhttps://www.robots.ox.ac.uk/~vgg/data/voxceleb/meta/veri_test.txtÚrootc           	      ó  — dD �]ˆ}t           |         d         }t          j                             | |¦  «        }|dk    �rt           |         d         }t           |         d         }t	          |d¦  «        5 }t          ||¦  «        D ]£\  }}t          j                             | t          j                             |¦  «        ¦  «        }	t          ||	|¬¦  «         t	          |	d¦  «        5 }
|                     |
 	                    ¦   «         ¦  «         d d d ¦  «         n# 1 swxY w Y   Œ¤	 d d d ¦  «         n# 1 swxY w Y   n8t           |         d	         }t           |         d
         }t          |||¬¦  «         t          |¦  «         �ŒŠd S )Nr   r   r   r   r   Úwb)Úhash_prefixÚrbr   r   )Ú_ARCHIVE_CONFIGSÚosÚpathÚjoinÚopenÚzipÚbasenamer	   ÚwriteÚreadr
   )r   Úarchiver   Úarchive_pathr   r   Úfr   r   Ú	file_pathÚf_splits              úNC:\Projects\Historical\venv\Lib\site-packages\torchaudio/datasets/voxceleb1.pyÚ_download_extract_wavsr-   &   sì  € Ø"ð #ñ #ˆÝ'¨Ô0°Ô@ˆÝ”w—|’| D¨,Ñ7Ô7ˆð �eÒÑÝ# GÔ,¨VÔ4ˆDÝ(¨Ô1°+Ô>ˆIÝ�l DÑ)Ô)ð 0¨QÝ%(¨¨yÑ%9Ô%9ð 0ð 0‘M�C˜Ý "¤§¢¨Tµ2´7×3CÒ3CÀCÑ3HÔ3HÑ IÔ I�IÝ(¨¨iÀXÐNÑNÔNÐNÝ˜i¨Ñ.Ô.ð 0°'ØŸš §¢¡¤Ñ/Ô/Ð/ð0ð 0ð 0ñ 0ô 0ð 0ð 0ð 0ð 0ð 0ð 0øøøð 0ð 0ð 0ð 0øð0ð0ð 0ð 0ñ 0ô 0ð 0ð 0ð 0ð 0ð 0ð 0øøøð 0ð 0ð 0ð 0øõ # 7Ô+¨EÔ2ˆCÝ'¨Ô0°Ô<ˆHÝ   lÀÐIÑIÔIÐIÝ�\Ñ"Ô"Ð"Ñ"ð%#ð #s7   Á6A5D8Ã+(D	ÄD8ÄD#Ä#D8Ä&D#Ä'D8Ä8D<	Ä?D<	r*   ÚsubsetÚreturnc                 ó&  — g }|dk    rd}n|dk    rd}nd}t          |d¦  «        5 }|D ]A}|                     ¦   «         \  }}t          |¦  «        |k    r|                     |¦  «         ŒB	 d d d ¦  «         n# 1 swxY w Y   t	          |¦  «        S )NÚtrainé   r   é   é   Úr)r"   ÚsplitÚintÚappendÚsorted)	r   r*   r.   Úf_listÚindexr)   ÚlineÚidr    s	            r,   Ú
_get_flistr>   <   sç   € Ø€FØ�ÒÐØˆˆØ	�5ŠˆØˆˆàˆÝ	ˆi˜Ñ	Ô	ð $ Øð 	$ð 	$ˆDØ—z’z‘|”|‰HˆB�Ý�2‰wŒw˜%ÒÐØ—’˜dÑ#Ô#Ð#øð	$ð$ð $ð $ñ $ô $ð $ð $ð $ð $ð $ð $øøøð $ð $ð $ð $õ
 �&‰>Œ>Ðs   §AA9Á9A=Â A=Úveri_test_pathc                 óÆ   — g }t          |d¦  «        5 }|D ]2}|                     ¦   «         \  }}}|                     |||f¦  «         Œ3	 d d d ¦  «         n# 1 swxY w Y   |S )Nr5   )r"   r6   r8   )r   r?   r:   r)   r<   ÚlabelÚpath1Úpath2s           r,   Ú_get_paired_flistrD   L   s´   € Ø€FÝ	ˆn˜cÑ	"Ô	"ð 1 aØð 	1ð 	1ˆDØ"&§*¢*¡,¤,ÑˆE�5˜%Ø�MŠM˜5 %¨Ð/Ñ0Ô0Ð0Ð0ð	1ð1ð 1ð 1ñ 1ô 1ð 1ð 1ð 1ð 1ð 1ð 1øøøð 1ð 1ð 1ð 1ð €Ms   “6AÁAÁAÚ
_ext_audioc                 ó¤   — |                       d¦  «        dd …         \  }}}|                     |d¦  «        }d                     |||g¦  «        }|S )Nú/éýÿÿÿÚ ú-)r6   Úreplacer!   )r*   rE   Ú
speaker_idÚ
youtube_idÚutterance_idÚfile_ids         r,   Ú_get_file_idrP   U   sU   € Ø+4¯?ª?¸3Ñ+?Ô+?ÀÀÀÔ+DÑ(€J�
˜LØ×'Ò'¨
°BÑ7Ô7€LØ�hŠh˜
 J°Ð=Ñ>Ô>€GØ€Nó    c                   ó`   — e Zd ZdZdZddeeef         deddfd„Z	d	e
fd
„Zd	e
fd„Zde
fd„ZdS )Ú	VoxCeleb1a"  *VoxCeleb1* :cite:`nagrani2017voxceleb` dataset.

    Args:
        root (str or Path): Path to the directory where the dataset is found or downloaded.
        download (bool, optional):
            Whether to download the dataset if it is not found at root path. (Default: ``False``).
    z.wavFr   Údownloadr/   Nc                 ó  — t          j        |¦  «        }t           j                             |d¦  «        | _        t           j                             | j        ¦  «        s+|st          d| j        › d�¦  «        ‚t          |¦  «         d S d S )NÚwavzDataset not found at z5. Please set `download=True` to download the dataset.)r   Úfspathr    r!   Ú_pathÚisdirÚRuntimeErrorr-   )Úselfr   rT   s      r,   Ú__init__zVoxCeleb1.__init__g   sˆ   € åŒy˜‰ŒˆÝ”W—\’\ $¨Ñ.Ô.ˆŒ
ÝŒw�}Š}˜TœZÑ(Ô(ð 	)Øð Ý"Øm¨D¬JÐmÐmÐmñô ð õ # 4Ñ(Ô(Ð(Ð(Ð(ð	)ð 	)rQ   Únc                 ó   — t           ‚©N©ÚNotImplementedError©r[   r]   s     r,   Úget_metadatazVoxCeleb1.get_metadatar   ó   € Ý!Ð!rQ   c                 ó   — t           ‚r_   r`   rb   s     r,   Ú__getitem__zVoxCeleb1.__getitem__u   rd   rQ   c                 ó   — t           ‚r_   r`   ©r[   s    r,   Ú__len__zVoxCeleb1.__len__x   rd   rQ   )F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rE   r   Ústrr   Úboolr\   r7   rc   rf   ri   © rQ   r,   rS   rS   \   s­   € € € € € ðð ð €Jð	)ð 	)˜U 3¨ 9Ô-ð 	)¸ð 	)È$ð 	)ð 	)ð 	)ð 	)ð"˜cð "ð "ð "ð "ð"˜Sð "ð "ð "ð "ð"˜ð "ð "ð "ð "ð "ð "rQ   rS   c                   ó¤   ‡ — e Zd ZdZdedfdeeef         dedededd	f
ˆ fd
„Z	de
deee
e
ef         fd„Zde
deee
e
ef         fd„Zde
fd„Zˆ xZS )ÚVoxCeleb1Identificationuý  *VoxCeleb1* :cite:`nagrani2017voxceleb` dataset for speaker identification task.

    Each data sample contains the waveform, sample rate, speaker id, and the file id.

    Args:
        root (str or Path): Path to the directory where the dataset is found or downloaded.
        subset (str, optional): Subset of the dataset to use. Options: ["train", "dev", "test"]. (Default: ``"train"``)
        meta_url (str, optional): The url of meta file that contains the list of subset labels and file paths.
            The format of each row is ``subset file_path". For example: ``1 id10006/nLEBBc9oIFs/00003.wav``.
            ``1``, ``2``, ``3`` mean ``train``, ``dev``, and ``test`` subest, respectively.
            (Default: ``"https://www.robots.ox.ac.uk/~vgg/data/voxceleb/meta/iden_split.txt"``)
        download (bool, optional):
            Whether to download the dataset if it is not found at root path. (Default: ``False``).

    Note:
        The file structure of `VoxCeleb1Identification` dataset is as follows:

        â””â”€ root/

         â””â”€ wav/

         â””â”€ speaker_id folders

        Users who pre-downloaded the ``"vox1_dev_wav.zip"`` and ``"vox1_test_wav.zip"`` files need to move
        the extracted files into the same ``root`` directory.
    r1   Fr   r.   Úmeta_urlrT   r/   Nc                 ó€  •— t          ¦   «                              ||¦  «         |dvrt          d¦  «        ‚t          j                             |t          j                             |¦  «        ¦  «        }t          j                             |¦  «        st          ||¦  «         t          | j
        ||¦  «        | _        d S )N)r1   r   r   z0`subset` must be one of ['train', 'dev', 'test'])Úsuperr\   Ú
ValueErrorr   r    r!   r$   Úexistsr	   r>   rX   Ú_flist)r[   r   r.   rs   rT   Úmeta_list_pathÚ	__class__s         €r,   r\   z VoxCeleb1Identification.__init__˜   sž   ø€ õ 	‰Œ×Ò˜˜xÑ(Ô(Ð(ØÐ1Ð1Ð1ÝÐOÑPÔPÐPåœŸš d­B¬G×,<Ò,<¸XÑ,FÔ,FÑGÔGˆÝŒw�~Š~˜nÑ-Ô-ð 	;Ý  ¨>Ñ:Ô:Ð:Ý  ¤¨^¸VÑDÔDˆŒˆˆrQ   r]   c                 óÀ   — | j         |         }t          || j        ¦  «        }|                     d¦  «        d         }t	          |dd…         ¦  «        }|t
          ||fS )aÔ  Get metadata for the n-th sample from the dataset. Returns filepath instead of waveform,
        but otherwise returns the same fields as :py:func:`__getitem__`.

        Args:
            n (int): The index of the sample

        Returns:
            Tuple of the following items;

            str:
                Path to audio
            int:
                Sample rate
            int:
                Speaker ID
            str:
                File ID
        rJ   r   r4   N)rx   rP   rE   r6   r7   ÚSAMPLE_RATE)r[   r]   r*   rO   rL   s        r,   rc   z$VoxCeleb1Identification.get_metadata¤   sZ   € ð& ”K ”Nˆ	Ý˜y¨$¬/Ñ:Ô:ˆØ—]’] 3Ñ'Ô'¨Ô*ˆ
Ý˜ A B BœÑ(Ô(ˆ
Ø�+ z°7Ð:Ð:rQ   c                 óŒ   — |                       |¦  «        }t          | j        |d         |d         ¦  «        }|f|dd…         z   S )ad  Load the n-th sample from the dataset.

        Args:
            n (int): The index of the sample to be loaded

        Returns:
            Tuple of the following items;

            Tensor:
                Waveform
            int:
                Sample rate
            int:
                Speaker ID
            str:
                File ID
        r   r2   N©rc   r   rX   )r[   r]   ÚmetadataÚwaveforms       r,   rf   z#VoxCeleb1Identification.__getitem__½   sG   € ð$ ×$Ò$ QÑ'Ô'ˆÝ! $¤*¨h°q¬k¸8ÀA¼;ÑGÔGˆØˆ{˜X a b bœ\Ñ)Ð)rQ   c                 ó*   — t          | j        ¦  «        S r_   ©Úlenrx   rh   s    r,   ri   zVoxCeleb1Identification.__len__Ó   ó   € Ý�4”;ÑÔÐrQ   )rj   rk   rl   rm   Ú_IDEN_SPLIT_URLr   rn   r   ro   r\   r7   r   rc   r   rf   ri   Ú__classcell__©rz   s   @r,   rr   rr   |   s  ø€ € € € € ðð ð8 5<È_Ðotð
Eð 
EØ˜#˜t˜)Ô$ð
EØ.1ð
EØGJð
EØhlð
Eà	ð
Eð 
Eð 
Eð 
Eð 
Eð 
Eð;˜cð ; e¨C°°c¸3Ð,>Ô&?ð ;ð ;ð ;ð ;ð2*˜Sð * U¨6°3¸¸SÐ+@Ô%Að *ð *ð *ð *ð, ˜ð  ð  ð  ð  ð  ð  ð  ð  rQ   rr   c            
       ó¦   ‡ — e Zd ZdZedfdeeef         dededdfˆ fd„Z	d	e
deeee
e
eef         fd
„Zd	e
deeee
e
eef         fd„Zde
fd„Zˆ xZS )ÚVoxCeleb1Verificationuö  *VoxCeleb1* :cite:`nagrani2017voxceleb` dataset for speaker verification task.

    Each data sample contains a pair of waveforms, sample rate, the label indicating if they are
    from the same speaker, and the file ids.

    Args:
        root (str or Path): Path to the directory where the dataset is found or downloaded.
        meta_url (str, optional): The url of meta file that contains a list of utterance pairs
            and the corresponding labels. The format of each row is ``label file_path1 file_path2".
            For example: ``1 id10270/x6uYqmx31kE/00001.wav id10270/8jEAjG6SegY/00008.wav``.
            ``1`` means the two utterances are from the same speaker, ``0`` means not.
            (Default: ``"https://www.robots.ox.ac.uk/~vgg/data/voxceleb/meta/veri_test.txt"``)
        download (bool, optional):
            Whether to download the dataset if it is not found at root path. (Default: ``False``).

    Note:
        The file structure of `VoxCeleb1Verification` dataset is as follows:

        â””â”€ root/

         â””â”€ wav/

         â””â”€ speaker_id folders

        Users who pre-downloaded the ``"vox1_dev_wav.zip"`` and ``"vox1_test_wav.zip"`` files need to move
        the extracted files into the same ``root`` directory.
    Fr   rs   rT   r/   Nc                 óX  •— t          ¦   «                              ||¦  «         t          j                             |t          j                             |¦  «        ¦  «        }t          j                             |¦  «        st          ||¦  «         t          | j	        |¦  «        | _
        d S r_   )ru   r\   r   r    r!   r$   rw   r	   rD   rX   rx   )r[   r   rs   rT   ry   rz   s        €r,   r\   zVoxCeleb1Verification.__init__ô   s   ø€ Ý‰Œ×Ò˜˜xÑ(Ô(Ð(åœŸš d­B¬G×,<Ò,<¸XÑ,FÔ,FÑGÔGˆÝŒw�~Š~˜nÑ-Ô-ð 	;Ý  ¨>Ñ:Ô:Ð:Ý'¨¬
°NÑCÔCˆŒˆˆrQ   r]   c                 ó°   — | j         |         \  }}}t          |¦  «        }t          || j        ¦  «        }t          || j        ¦  «        }||t          |||fS )ag  Get metadata for the n-th sample from the dataset. Returns filepaths instead of waveforms,
        but otherwise returns the same fields as :py:func:`__getitem__`.

        Args:
            n (int): The index of the sample

        Returns:
            Tuple of the following items;

            str:
                Path to audio file of speaker 1
            str:
                Path to audio file of speaker 2
            int:
                Sample rate
            int:
                Label
            str:
                File ID of speaker 1
            str:
                File ID of speaker 2
        )rx   r7   rP   rE   r|   )r[   r]   rA   Úfile_path_spk1Úfile_path_spk2Úfile_id_spk1Úfile_id_spk2s          r,   rc   z"VoxCeleb1Verification.get_metadataü   sW   € ð. 15´¸A´Ñ-ˆˆ~˜~Ý�E‘
”
ˆÝ# N°D´OÑDÔDˆÝ# N°D´OÑDÔDˆØ˜~­{¸EÀ<ÐQ]Ð]Ð]rQ   c                 óÒ   — |                       |¦  «        }t          | j        |d         |d         ¦  «        }t          | j        |d         |d         ¦  «        }||f|dd…         z   S )aê  Load the n-th sample from the dataset.

        Args:
            n (int): The index of the sample to be loaded.

        Returns:
            Tuple of the following items;

            Tensor:
                Waveform of speaker 1
            Tensor:
                Waveform of speaker 2
            int:
                Sample rate
            int:
                Label
            str:
                File ID of speaker 1
            str:
                File ID of speaker 2
        r   r3   r2   Nr~   )r[   r]   r   Úwaveform_spk1Úwaveform_spk2s        r,   rf   z!VoxCeleb1Verification.__getitem__  se   € ð, ×$Ò$ QÑ'Ô'ˆÝ& t¤z°8¸A´;ÀÈÄÑLÔLˆÝ& t¤z°8¸A´;ÀÈÄÑLÔLˆØ˜}Ð-°¸¸¸´Ñ<Ð<rQ   c                 ó*   — t          | j        ¦  «        S r_   r‚   rh   s    r,   ri   zVoxCeleb1Verification.__len__4  r„   rQ   )rj   rk   rl   rm   Ú_VERI_TEST_URLr   rn   r   ro   r\   r7   r   rc   r   rf   ri   r†   r‡   s   @r,   r‰   r‰   ×   s  ø€ € € € € ðð ð8 @NÐ`eð Dð D˜U 3¨ 9Ô-ð D¸ð DÐY]ð DÐjnð Dð Dð Dð Dð Dð Dð^˜cð ^ e¨C°°c¸3ÀÀSÐ,HÔ&Ið ^ð ^ð ^ð ^ð:=˜Sð = U¨6°6¸3ÀÀSÈ#Ð+MÔ%Nð =ð =ð =ð =ð6 ˜ð  ð  ð  ð  ð  ð  ð  ð  rQ   r‰   )r   Úpathlibr   Útypingr   r   r   Útorchr   Útorch.utils.datar   Útorchaudio._internalr	   Útorchaudio.datasets.utilsr
   r   r|   r   r…   r”   rn   r-   r>   rD   rP   rS   rr   r‰   rp   rQ   r,   ú<module>r›      s  ðØ 	€	€	€	Ø Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à Ð Ð Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø BÐ BÐ BÐ BÐ BÐ BÐ BÐ Bð €ð +ð
ð 
ð 
ð
ð 
ð 
ðð ð  ,ØXØVðð ð!ð Ð ð, W€ØT€ð# ð #ð #ð #ð #ð,�Sð  Sð °#ð ¸$¸s¼)ð ð ð ð ð ˜Cð °ð ð ð ð ð˜Cð ¨Sð ð ð ð ð"ð "ð "ð "ð "�ñ "ô "ð "ð@X ð X ð X ð X ð X ˜iñ X ô X ð X ðv^ ð ^ ð ^ ð ^ ð ^ ˜Iñ ^ ô ^ ð ^ ð ^ ð ^ rQ   