a
    h	                     @   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ejee ee dd
ddZdS )    N)platform)Optionalu8Zs16Zs32Zs64ZfltZdbl)waveformsample_ratedevicereturnc              	   C   sN  t dkr|pd}d}ntdt  ttjj  }||vrTtd| d| | jt	vrxtd| j dt	  t	| j }| j
d	krtd
| j
 d|  \}}|d	krtjd| dd	d tjj||d}|j|||d d}	| D td||	D ]&}
|d| |
|
|	 ddf  qW d   n1 s@0    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.
    darwinZ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utilsZffmpeg_utilsZget_output_deviceskeysZdtypedict_formatndimsizewarningswarnioStreamWriterZadd_audio_streamopenrangeZwrite_audio_chunk)r   r   r   pathZavailable_devicesr   timeZnum_channelss
block_sizei r#   E/var/www/auris/lib/python3.9/site-packages/torchaudio/io/_playback.py
play_audio   s0    




r%   )N)r   sysr   typingr   Ztorchr   Zuint8int16int32int64float32float64r   ZTensorfloatstrr%   r#   r#   r#   r$   <module>   s$    