
    hC                         S SK r S SKJr  S SKrS SKJr  S SKJr  S SKJ	r	  S SK
Jr  SrSS0r\\\\\\4   r " S	 S
\5      rg)    N)Tuple)Tensor)Dataset)download_url_to_file)_extract_zipzNhttps://datashare.is.ed.ac.uk/bitstream/handle/10283/3443/VCTK-Corpus-0.92.zip@f96258be9fdc2cbff6559541aae7ea4f59df3fcaf5cf963aae5ca647357e359cc            	           \ rS rSrSrSS\S4S\S\S\S	\4S
 jjrS\4S jr	S\
\\4   4S jrS\S\S\S\4S jrS\S\4S jrS\4S jrSrg)VCTK_092   a  *VCTK 0.92* :cite:`yamagishi2019vctk` dataset

Args:
    root (str): Root directory where the dataset's top level directory is found.
    mic_id (str, optional): Microphone ID. Either ``"mic1"`` or ``"mic2"``. (default: ``"mic2"``)
    download (bool, optional):
        Whether to download the dataset if it is not found at root path. (default: ``False``).
    url (str, optional): The URL to download the dataset from.
        (default: ``"https://datashare.is.ed.ac.uk/bitstream/handle/10283/3443/VCTK-Corpus-0.92.zip"``)
    audio_ext (str, optional): Custom audio extension if dataset is converted to non-default audio format.

Note:
    * All the speeches from speaker ``p315`` will be skipped due to the lack of the corresponding text files.
    * All the speeches from ``p280`` will be skipped for ``mic_id="mic2"`` due to the lack of the audio files.
    * Some of the speeches from speaker ``p362`` will be skipped due to the lack of  the audio files.
    * See Also: https://datashare.is.ed.ac.uk/handle/10283/3443
mic2Fz.flacrootmic_iddownloadurlc           
         US;  a  [        SU 35      e[        R                  R                  US5      n[        R                  R                  US5      U l        [        R                  R                  U R                  S5      U l        [        R                  R                  U R                  S5      U l        X l        XPl        U(       a  [        R                  R                  U R                  5      (       dY  [        R                  R                  U5      (       d   [        R                  US 5      n[        XFUS9  [        X`R                  5        [        R                  R                  U R                  5      (       d  [        S5      e[        [        R                   " U R
                  5      5      U l        / U l         U R"                   GH  nUS	:X  a  US
:X  a  M  [        R                  R                  U R
                  U5      n	[        S [        R                   " U	5       5       5       H  n
[        R                  R'                  U
5      S   n[        R                  R                  U R                  UU SU U R                   35      nUS:X  a&  [        R                  R                  U5      (       d  M  U R$                  R)                  UR+                  S5      5        M     GM      g )N)mic1r   z3`mic_id` has to be either "mic1" or "mic2". Found: zVCTK-Corpus-0.92.zipzVCTK-Corpus-0.92txtwav48_silence_trimmed)hash_prefixz=Dataset not found. Please use `download=True` to download it.p280r   c              3   T   #    U  H  oR                  S 5      (       d  M  Uv   M      g7f).txtN)endswith).0fs     P/var/www/auris/envauris/lib/python3.13/site-packages/torchaudio/datasets/vctk.py	<genexpr>$VCTK_092.__init__.<locals>.<genexpr>U   s      (d4MqQ[Q[\bQc4Ms   (	(r   _p362)RuntimeErrorospathjoin_path_txt_dir
_audio_dir_mic_id
_audio_extisdirisfile
_CHECKSUMSgetr   r   sortedlistdir_speaker_ids_sample_idssplitextappendsplit)selfr   r   r   r   	audio_extarchivechecksum
speaker_idutterance_dirutterance_fileutterance_idaudio_path_mics                r   __init__VCTK_092.__init__&   s    ))!TU[T\]^^'',,t%;<WW\\$(:;
TZZ7'',,tzz3JK#77==,,ww~~g..)~~c48H(8LWjj1ww}}TZZ((^__ #2::dmm#<=		 ++JV#&(8GGLL
CM"((dBJJ}4M(d"d!ww//?B!#OO#nAfXdoo->?"
 '~0N0N  ''(:(:3(?@ #e	 ,    returnc                 t    [        U5       nUR                  5       S   sS S S 5        $ ! , (       d  f       g = f)Nr   )open	readlinesr5   	file_paths     r   
_load_textVCTK_092._load_text`   s&    )_	&&(+ __s   )
7c                 .    [         R                  " U5      $ N)
torchaudioloadrE   s     r   _load_audioVCTK_092._load_audiod   s    y))r@   r9   r<   c           
      2   [         R                  R                  U R                  X SU S35      n[         R                  R                  U R                  UU SU SU U R
                   35      nU R                  U5      nU R                  U5      u  pxXxXaU4$ )Nr   r   )r"   r#   r$   r&   r'   r)   rG   rM   )	r5   r9   r<   r   transcript_path
audio_path
transcriptwaveformsample_rates	            r   _load_sampleVCTK_092._load_sampleg   s    '',,t}}jLPQR^Q__cBdeWW\\OOl!L>6(4??2CD

 ___5
 !% 0 0 <z|LLr@   nc                 \    U R                   U   u  p#U R                  X#U R                  5      $ )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
    int:
        Sample rate
    str:
        Transcript
    str:
        Speaker ID
    std:
        Utterance ID
)r1   rU   r(   )r5   rW   r9   r<   s       r   __getitem__VCTK_092.__getitem__w   s.    ( $(#3#3A#6 
  4<<HHr@   c                 ,    [        U R                  5      $ rJ   )lenr1   )r5   s    r   __len__VCTK_092.__len__   s    4##$$r@   )r'   r)   r(   r%   r1   r0   r&   N)__name__
__module____qualname____firstlineno____doc__URLstrboolr>   rG   r   r   intrM   
SampleTyperU   rY   r]   __static_attributes__ r@   r   r
   r
      s    * 8A8A 8A 	8A
 8At,s ,*fck(: *Ms M# Ms Mz M IS IZ I.% %r@   r
   )r"   typingr   rK   torchr   torch.utils.datar   torchaudio._internalr   torchaudio.datasets.utilsr   rd   r,   rg   re   rh   r
   rj   r@   r   <module>rp      sU    	    $ 5 2VT  WY

 63S#-.
|%w |%r@   