
    wi	                         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dS )    N)platform)Optionalu8s16s32s64fltdblwaveformsample_ratedevicereturnc           	         t           dk    r|pd}d}nt          dt                      t          t          j        j                                                                                  }||vrt          d| d|           | j        t          vr1t          d| j         dt                                                     t          | j                 }| j
        d	k    rt          d
| j
         d          |                                 \  }}|d	k    rt          j        d| dd	           t          j                            ||          }|                    |||           d}	|                                5  t%          d||	          D ]'}
|                    d| |
|
|	z   ddf                    (	 ddd           dS # 1 swxY w Y   dS )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              g/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/torchaudio/io/_playback.py
play_audior3      sh   * 8)>[QY[[\\\Z-:MMOOTTVVWW&&&h6hhUfhhiii~[((sX^ss_j_o_o_q_qssttt(F}uV^Vcuuuvvv!D,a8l 8 8 8	
 	
 	
 	
 	""tF";;A{L@@@ J	
 D Dq$
++ 	D 	DA8AJ,>,A#BCCCC	DD D D D D D D D D D D D D D D D D Ds   ?:GGG)N)r#   sysr   typingr   torchr   uint8int16int32int64float32float64r    Tensorfloatstrr3        r2   <module>rB      s                      
K	K	K	K	M5	M5 !6D 6Dl6D%6D SM6D 
	6D 6D 6D 6D 6D 6DrA   