
    h                         S SK r S SKJr  S SKJrJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJrJr  SrS	rS
r/ SQrSSSSSSSS.rS rS\S\S\S\S\S\\\\\\\4   4S jr " S S\	5      rg)    N)Path)TupleUnion)Tensor)Dataset)download_url_to_file)_extract_tar_load_waveformtrain-clean-100LibriSpeechi>  )z	dev-cleanz	dev-otherz
test-cleanz
test-otherr   ztrain-clean-360ztrain-other-500@76f87d090650617fca0cac8f88b9416e0ebf80350acb97b343a85fa903728ab3@12661c48e8c3fe1de2c1caa4c3e135193bfb1811584f11f569dd12645aa84365@39fde525e59672dc6d1551919b1478f724438a95aa55f874b576be21967e6c23@d09c181bba5cf717b3dee7d4d592af11a3ee3a09e08ae025c5506f6ebe961c29@d4ddd1d5a6ab303066f14971d768ee43278a5f2a0aa43dc716b0e64ecbbbf6e2@146a56496217e96c14334a160df97fffedd6e0a04e66b9c5af0d40be3c792ecf@ddb22f27f96ec163645d53215559df6aa36515f26e01dd70798188350adcb6d2)z4http://www.openslr.org/resources/12/dev-clean.tar.gzz4http://www.openslr.org/resources/12/dev-other.tar.gzz5http://www.openslr.org/resources/12/test-clean.tar.gzz5http://www.openslr.org/resources/12/test-other.tar.gzz:http://www.openslr.org/resources/12/train-clean-100.tar.gzz:http://www.openslr.org/resources/12/train-clean-360.tar.gzz:http://www.openslr.org/resources/12/train-other-500.tar.gzc                 .   SnSnX-   n[         R                  R                  X5      n[         R                  R                  X$5      n[         R                  R                  U5      (       d   [        R                  US 5      n[        XeUS9  [        U5        g )Nz$http://www.openslr.org/resources/12/z.tar.gz)hash_prefix)ospathjoinisfile
_CHECKSUMSgetr   r	   )rooturlbase_urlext_archivefilenamearchivedownload_urlchecksums           W/var/www/auris/envauris/lib/python3.13/site-packages/torchaudio/datasets/librispeech.py_download_librispeechr%   !   sm    5HK Hggll4*G77<<3L77>>'"">>,5\I    fileidr   folder	ext_audioext_txtreturnc                    U R                  S5      u  pVnU SU SU 3n[        R                  R                  X%Xh U 35      n	U SU U 3n
[        R                  R                  XXVU
5      n
[	        U
5       nU H,  nUR                  5       R                  SS5      u  pX:X  d  M,    O   [        SU 35      e S S S 5        U	[        W[        U5      [        U5      [        U5      4$ ! , (       d  f       N5= f)N-    zTranslation not found for )	splitr   r   r   openstripFileNotFoundErrorSAMPLE_RATEint)r'   r   r(   r)   r*   
speaker_id
chapter_idutterance_idfileid_audiofilepath	file_textftlinefileid_text
transcripts                  r$   _get_librispeech_metadatar@   .   s    ,2<<+<(JL !\:,a~>Lww||F
nYK<XYH ,a
|G95IT:9MI	iBD&*jjl&8&8a&@#K*  $&@$OPP 	 
 	JJL  
s   8+C)'C))
C7c                       \ rS rSrSrSrSr\\S4S\	\
\4   S\
S\
S	\S
S4
S jjrS\S
\\
\\
\\\4   4S jrS\S
\\\\
\\\4   4S jrS
\4S jrSrg)LIBRISPEECHM   a  *LibriSpeech* :cite:`7178964` dataset.

Args:
    root (str or Path): Path to the directory where the dataset is found or downloaded.
    url (str, optional): The URL to download the dataset from,
        or the type of the dataset to dowload.
        Allowed type values are ``"dev-clean"``, ``"dev-other"``, ``"test-clean"``,
        ``"test-other"``, ``"train-clean-100"``, ``"train-clean-360"`` and
        ``"train-other-500"``. (default: ``"train-clean-100"``)
    folder_in_archive (str, optional):
        The top-level directory of the dataset. (default: ``"LibriSpeech"``)
    download (bool, optional):
        Whether to download the dataset if it is not found at root path. (default: ``False``).
z
.trans.txtz.flacFr   r   folder_in_archivedownloadr+   Nc                 N   X l         U[        ;  a  [        SU S[         S35      e[        R                  " U5      n[        R
                  R                  X5      U l        [        R
                  R                  XU5      U l        [        R
                  R                  U R                  5      (       d,  U(       a  [        X5        O[        SU R                   S35      e[        S [        U R                  5      R                  SU R                  -   5       5       5      U l        g )NzInvalid url 'z' given; please provide one of .zDataset not found at z5. Please set `download=True` to download the dataset.c              3   L   #    U  H  n[        UR                  5      v   M     g 7fN)strstem).0ps     r$   	<genexpr>'LIBRISPEECH.__init__.<locals>.<genexpr>w   s     d3cac!&&kk3cs   "$z*/*/*)_url_DATA_SUBSETS
ValueErrorr   fspathr   r   _archive_pathisdirr%   RuntimeErrorsortedr   glob
_ext_audio_walker)selfr   r   rD   rE   s        r$   __init__LIBRISPEECH.__init__`   s     	m#}SE1PQ^P__`abbyyT=WW\\$3?
ww}}TZZ((%d0"+DJJ<7lm  d4

3C3H3HSWSbSbIb3cddr&   nc                     U R                   U   n[        X R                  U R                  U R                  U R
                  5      $ )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 to be loaded

Returns:
    Tuple of the following items;

    str:
        Path to audio
    int:
        Sample rate
    str:
        Transcript
    int:
        Speaker ID
    int:
        Chapter ID
    int:
        Utterance ID
)r[   r@   rT   rP   rZ   _ext_txt)r\   r_   r'   s      r$   get_metadataLIBRISPEECH.get_metadatay   s5    . a(		4??\`\i\ijjr&   c                 p    U R                  U5      n[        U R                  US   US   5      nU4USS -   $ )a9  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
    int:
        Speaker ID
    int:
        Chapter ID
    int:
        Utterance ID
r   r/   N)rb   r
   rT   )r\   r_   metadatawaveforms       r$   __getitem__LIBRISPEECH.__getitem__   sA    , $$Q'!$--!hqkJ{Xab\))r&   c                 ,    [        U R                  5      $ rI   )lenr[   )r\   s    r$   __len__LIBRISPEECH.__len__   s    4<<  r&   )rT   rU   rP   r[   )__name__
__module____qualname____firstlineno____doc__ra   rZ   URLFOLDER_IN_ARCHIVEr   rJ   r   boolr]   r5   r   rb   r   rg   rk   __static_attributes__ r&   r$   rB   rB   M   s     HJ
 !2eCIe e 	e
 e 
e2kc keCc3S,H&I k4*S *U63S#s+J%K *4! !r&   rB   )r   pathlibr   typingr   r   torchr   torch.utils.datar   torchaudio._internalr   torchaudio.datasets.utilsr	   r
   rr   rs   r4   rQ   r   r%   rJ   r5   r@   rB   rv   r&   r$   <module>r}      s    	    $ 5 B!  =<~== CE CE CE

$'47BE
3S#sC'(>a!' a!r&   