Ë
    ÿÍ:jÍ-  ã            	       ó  — 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y)$é    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                  j                  | |«      }|dk(  rÂt         |   d   }t         |   d   }t	        |d«      5 }t        ||«      D ]„  \  }}t        j                  j                  | t        j                  j                  |«      «      }	t        ||	|¬«       t	        |	d«      5 }
|j                  |
j                  «       «       d d d «       Œ† 	 d d d «       n&t         |   d	   }t         |   d
   }t        |||¬«       t        |«       �Œ* y # 1 sw Y   ŒÏxY w# 1 sw Y   Œ$xY w)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              úr/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/torchaudio/datasets/voxceleb1.pyÚ_download_extract_wavsr-   &   s7  € Ø"ó #ˆÜ'¨Ñ0°Ñ@ˆÜ—w‘w—|‘| D¨,Ó7ˆð �eÒÜ# GÑ,¨VÑ4ˆDÜ(¨Ñ1°+Ñ>ˆIÜ�l DÓ)ð 0¨QÜ%(¨¨yÓ%9ò 0‘M�C˜Ü "§¡§¡¨T´2·7±7×3CÑ3CÀCÓ3HÓ I�IÜ(¨¨iÀXÕNÜ˜i¨Ó.ð 0°'ØŸ™ §¡£Ô/÷0ð 0ñ0÷0ð 0ô # 7Ñ+¨EÑ2ˆCÜ'¨Ñ0°Ñ<ˆHÜ   lÀÕIÜ�\Ö"ñ%#÷0ð 0ú÷	0ð 0ús%   ÁA*D;Ã D/	Ã&
D;Ä/D8Ä4D;Ä;E	r*   ÚsubsetÚreturnc                 ó  — g }|dk(  rd}n
|dk(  rd}nd}t        |d«      5 }|D ]5  }|j                  «       \  }}t        |«      |k(  sŒ%|j                  |«       Œ7 	 d d d «       t	        |«      S # 1 sw Y   t	        |«      S xY w)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˜%ÓØ—‘˜dÕ#ñ	$÷$ô
 �&‹>Ð÷$ô
 �&‹>Ðús   ¡'A0Á	A0Á0BÚveri_test_pathc                 ó®   — g }t        |d«      5 }|D ]*  }|j                  «       \  }}}|j                  |||f«       Œ, 	 d d d «       |S # 1 sw Y   |S xY w)Nr5   )r"   r6   r8   )r   r?   r:   r)   r<   ÚlabelÚpath1Úpath2s           r,   Ú_get_paired_flistrD   L   se   € Ø€FÜ	ˆn˜cÓ	"ð 1 aØò 	1ˆDØ"&§*¡*£,ÑˆE�5˜%Ø�M‰M˜5 %¨Ð/Õ0ñ	1÷1ð €M÷	1ð €Mús   �0A
Á
AÚ
_ext_audioc                 ó‚   — | j                  d«      dd  \  }}}|j                  |d«      }dj                  |||g«      }|S )Nú/éýÿÿÿÚ ú-)r6   Úreplacer!   )r*   rE   Ú
speaker_idÚ
youtube_idÚutterance_idÚfile_ids         r,   Ú_get_file_idrP   U   sJ   € Ø+4¯?©?¸3Ó+?ÀÀÐ+DÑ(€J�
˜LØ×'Ñ'¨
°BÓ7€LØ�h‰h˜
 J°Ð=Ó>€GØ€Nó    c                   óX   — 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y)Ú	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.wavr   Údownloadr/   Nc                 ó  — t        j                  |«      }t         j                  j                  |d«      | _        t         j                  j                  | j                  «      s'|st        d| j                  › d�«      ‚t        |«       y y )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   si   € ä�y‰y˜‹ˆÜ—W‘W—\‘\ $¨Ó.ˆŒ
Ü�w‰w�}‰}˜TŸZ™ZÔ(ÙÜ"Ø+¨D¯J©J¨<Ð7lÐ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   \   sU   „ ñð €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                 óL  •— t         ‰| �  ||«       |dvrt        d«      ‚t        j                  j                  |t        j                  j                  |«      «      }t        j                  j                  |«      st        ||«       t        | j                  ||«      | _        y )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__˜   sz   ø€ ô 	‰Ñ˜˜xÔ(ØÐ1Ñ1ÜÐOÓPÐPäŸ™Ÿ™ d¬B¯G©G×,<Ñ,<¸XÓ,FÓGˆÜ�w‰w�~‰~˜nÔ-Ü  ¨>Ô:Ü  §¡¨^¸VÓDˆ�rQ   r]   c                 ó¤   — | j                   |   }t        || j                  «      }|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¤   sS   € ð& —K‘K ‘Nˆ	Ü˜y¨$¯/©/Ó:ˆØ—]‘] 3Ó'¨Ñ*ˆ
Ü˜ A B˜Ó(ˆ
Øœ+ z°7Ð:Ð:rQ   c                 óp   — | j                  |«      }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__½   sA   € ð$ ×$Ñ$ QÓ'ˆÜ! $§*¡*¨h°q©k¸8ÀA¹;ÓGˆØˆ{˜X a 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Ø˜#˜t˜)Ñ$ð
EØ.1ð
EØGJð
EØhlð
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                 ó,  •— t         ‰| �  ||«       t        j                  j	                  |t        j                  j                  |«      «      }t        j                  j                  |«      st        ||«       t        | j                  |«      | _
        y r_   )ru   r\   r   r    r!   r$   rw   r	   rD   rX   rx   )r[   r   rs   rT   ry   rz   s        €r,   r\   zVoxCeleb1Verification.__init__ô   sa   ø€ Ü‰Ñ˜˜xÔ(äŸ™Ÿ™ d¬B¯G©G×,<Ñ,<¸XÓ,FÓGˆÜ�w‰w�~‰~˜nÔ-Ü  ¨>Ô:Ü'¨¯
©
°NÓ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ü   sU   € ð. 15·±¸A±Ñ-ˆˆ~˜~Ü�E“
ˆÜ# N°D·O±OÓDˆÜ# N°D·O±OÓDˆØ˜~¬{¸EÀ<ÐQ]Ð]Ð]rQ   c                 ó¬   — | j                  |«      }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__  s^   € ð, ×$Ñ$ QÓ'ˆÜ& t§z¡z°8¸A±;ÀÈÁÓLˆÜ& t§z¡z°8¸A±;ÀÈÁÓ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˜U 3¨ 9Ñ-ð D¸ð DÐY]ð DÐjnõ 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ß Bð €ð +ò
ò
ñð  ,ØXØVññ!Ð ð, W€ØT€ð# ó #ð,�Sð  Sð °#ð ¸$¸s¹)ó ð ˜Cð °ó ð˜Cð ¨Só ô"�ô "ô@X ˜iô X ôv^ ˜Iõ ^ rQ   