
    h                     n    S SK r 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r " S S	\
5      rg)
    N)Path)TupleUnion)Tensor)Dataset)_load_waveformi>  c                       \ rS rSrSrSS\\\4   S\4S jjrS\	S\
\\	\\	\\\\4   4S jrS\	4S	 jrS\	S\
\\	\\	\\\\4   4S
 jrSrg)FluentSpeechCommands   a  *Fluent Speech Commands* :cite:`fluent` dataset

Args:
    root (str of Path): Path to the directory where the dataset is found.
    subset (str, optional): subset of the dataset to use.
        Options: [``"train"``, ``"valid"``, ``"test"``].
        (Default: ``"train"``)
rootsubsetc                    US;  a  [        S5      e[        R                  " U5      n[        R                  R	                  US5      U l        [        R                  R                  U R
                  5      (       d  [        S5      e[        R                  R	                  U R
                  SU S35      n[        U5       n[        R                  " U5      n[        U5      nS S S 5        WS   U l        USS  U l        g ! , (       d  f       N#= f)	N)trainvalidtestz2`subset` must be one of ['train', 'valid', 'test']fluent_speech_commands_datasetzDataset not found.dataz	_data.csvr      )
ValueErrorosfspathpathjoin_pathisdirRuntimeErroropencsvreaderlistheaderr   )selfr   r   subset_path
subset_csvsubset_readerr   s          Z/var/www/auris/envauris/lib/python3.13/site-packages/torchaudio/datasets/fluentcommands.py__init__FluentSpeechCommands.__init__   s    33QRRyyWW\\$(HI
ww}}TZZ((344ggll4::v&7KL+*JJz2M&D  1gH	 s   ?"C>>
Dnreturnc                    U R                   U   nX R                  R                  S5         R                  S5      S   nUR                  S5      S   nUSS u  pEpgn[        R
                  R                  SS	XC S
35      n	U	[        X4XVXx4$ )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:
        File name
    int:
        Speaker ID
    str:
        Transcription
    str:
        Action
    str:
        Object
    str:
        Location
r   /.r      Nwavsspeakersz.wav)r   r!   indexsplitr   r   r   SAMPLE_RATE)
r"   r)   sample	file_name
speaker_idtranscriptionactionobjlocation	file_paths
             r&   get_metadata!FluentSpeechCommands.get_metadata)   s    6 1;;,,V45;;C@D	OOC(+	;A!":8
6GGLLZ;dAST	+ymUXbb    c                 ,    [        U R                  5      $ )N)lenr   )r"   s    r&   __len__FluentSpeechCommands.__len__M   s    499~r?   c                 p    U R                  U5      n[        U R                  US   US   5      nU4USS -   $ )ag  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:
        File name
    int:
        Speaker ID
    str:
        Transcription
    str:
        Action
    str:
        Object
    str:
        Location
r   r   N)r=   r   r   )r"   r)   metadatawaveforms       r&   __getitem__ FluentSpeechCommands.__getitem__P   sA    4 $$Q'!$**hqk8A;G{Xab\))r?   )r   r   r!   N)r   )__name__
__module____qualname____firstlineno____doc__r   strr   r'   intr   r=   rB   r   rG   __static_attributes__ r?   r&   r
   r
      s    U39- s $"cc "ceCc3S#s,R&S "cH *S *U63S#sCQT+T%U *r?   r
   )r   r   pathlibr   typingr   r   torchr   torch.utils.datar   torchaudio.datasets.utilsr   r4   r
   rQ   r?   r&   <module>rW      s-    
 	    $ 4_*7 _*r?   