o
    i	                     @   s   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dZdS )    N)platform)Optionalu8s16s32s64fltdblwaveformsample_ratedevicereturnc              	   C   sL  t dkr|pd}d}ntdt  ttjj  }||vr*td| d| | jt	vr<td| j dt	  t	| j }| j
d	krOtd
| j
 d|  \}}|d	krdtjd| dd	d tjj||d}|j|||d d}	| " td||	D ]}
|d| |
|
|	 ddf  qW d   dS 1 sw   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i r0   U/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/torchaudio/io/_playback.py
play_audio   s4   




""r2   )N)r!   sysr   typingr   torchr   uint8int16int32int64float32float64r   Tensorfloatstrr2   r0   r0   r0   r1   <module>   s,    