
    QVji              	           d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 dgZ
 ed           G d de	eeef                                        Zd	S )
    )Iterator)IOBase)Optional)functional_datapipe)IterDataPipeStreamReaderIterDataPiperead_from_streamc                   v    e Zd ZdZ	 ddeeeef                  dee	         fdZ
deeeef                  fdZdS )	r   a  
    Given IO streams and their label names, yield bytes with label name as tuple.

    (functional name: ``read_from_stream``).

    Args:
        datapipe: Iterable DataPipe provides label/URL and byte stream
        chunk: Number of bytes to be read from stream per iteration.
            If ``None``, all bytes will be read until the EOF.

    Example:
        >>> # xdoctest: +SKIP
        >>> from torchdata.datapipes.iter import IterableWrapper, StreamReader
        >>> from io import StringIO
        >>> dp = IterableWrapper([("alphabet", StringIO("abcde"))])
        >>> list(StreamReader(dp, chunk=1))
        [('alphabet', 'a'), ('alphabet', 'b'), ('alphabet', 'c'), ('alphabet', 'd'), ('alphabet', 'e')]
    Ndatapipechunkc                 "    || _         || _        d S N)r   r   )selfr   r   s      f/root/voice-cloning/.venv/lib/python3.11/site-packages/torch/utils/data/datapipes/iter/streamreader.py__init__z!StreamReaderIterDataPipe.__init__!   s     !


    returnc              #      K   | j         D ]>\  }}	 |                    | j                  }|s|                                 n||fV  8?d S r   )r   readr   close)r   furlstreamds       r   __iter__z!StreamReaderIterDataPipe.__iter__'   sl       M 	  	 LD& KK
++ LLNNNQi  	  	 r   r   )__name__
__module____qualname____doc__r   tuplestrr   r   intr   r   bytesr    r   r   r   r      s         ( RV $U3;%78AI#    (5e#45            r   N)collections.abcr   ior   typingr   %torch.utils.data.datapipes._decoratorr   #torch.utils.data.datapipes.datapiper   __all__r   r    r"   r   r#   r   r   <module>r*      s    $ $ $ $ $ $             E E E E E E < < < < < < &
& '((!  !  !  !  ! |E#u*,=> !  !  )(!  !  ! r   