
    ujh	                        d dl Z d dlmZ d dlmZ d dlZd dlZej                  dej                  dej                  dej                  dej                  dej                  d	iZ	 dd
ej                  dee   dee   ddfdZy)    N)platform)Optionalu8s16s32s64fltdblwaveformsample_ratedevicereturnc           	      h   t         dk(  r	|xs d}d}nt        dt                t        t        j                  j
                  j                         j                               }||vrt        d| d|       | j                  t        vr-t        d| j                   dt        j                                t        | j                     }| j                  d	k7  rt        d
| j                   d      | j                         \  }}|d	kD  rt        j                  d| dd	       t        j                  j                  ||      }|j!                  |||       d}	|j#                         5  t%        d||	      D ]   }
|j'                  d| |
|
|	z   ddf          " 	 ddd       y# 1 sw Y   yxY w)a  Plays audio through specified or available output device.

    .. warning::
       This function is currently only supported on MacOS, and requires
       libavdevice (FFmpeg) with ``audiotoolbox`` output device.

    .. note::
       This function can play up to two audio channels.

    Args:
        waveform: Tensor containing the audio to play.
            Expected shape: `(time, num_channels)`.
        sample_rate: Sample rate of the audio to play.
        device: Output device to use. If None, the default device is used.
    darwinaudiotoolbox-z5This function only supports MacOS, but current OS is zDevice z* is not available. Available devices are: zUnsupported type z". The list of supported types is:    z:Expected 2D tensor with shape `(time, num_channels)`, got zD tensor insteadzExpected up to 2 channels, got z< channels instead. Only the first 2 channels will be played.)
stacklevel)dstformat)r      r   N)r   
ValueErrorlist
torchaudioutilsffmpeg_utilsget_output_deviceskeysdtypedict_formatndimsizewarningswarnioStreamWriteradd_audio_streamopenrangewrite_audio_chunk)r   r   r   pathavailable_devicesr   timenum_channelss
block_sizeis              U/var/www/html/dev/engine/venv/lib/python3.12/site-packages/torchaudio/io/_playback.py
play_audior3      s   * 8)>PQYPZ[\\Z--::MMOTTVW&&76(*TUfTghii~~[(,X^^,<<^_j_o_o_q^rstt(F}}UV^VcVcUddtuvv!D,a-l^ <8 8	
 	""tF";A{L@ J	
 Dq$
+ 	DA8AJ,>,A#BC	DD D Ds   -1F((F1)N)r#   sysr   typingr   torchr   uint8int16int32int64float32float64r    Tensorfloatstrr3        r2   <module>rB      s         
KK	KK	KK	KK	MM5	MM5 !6Dll6D%6D SM6D 
	6DrA   