o
    i                     @   s&   d dl Zd dlZd dlZdddZdS )    N }  c                 C   s   t j|ddddR}t }d}d}| D ]>}|r t | }d}t|tjr,|  }| dkr8|	d}n| dkrK|j
d dkrK|dd}||  qW d   |S 1 s^w   Y  |S )	z>
    Play streamed audio chunks to speakers in real time.
       float32r   )
sampleratechannelsdtype	blocksizeNTF   )sdOutputStreamtime
isinstancetorchTensordetachcpudim	unsqueezeshape	transposewritenumpy)streamsample_rate
out_streamstartlatencyfirstchunk r   K/home/ubuntu/.local/lib/python3.10/site-packages/soprano/utils/streaming.pyplay_stream   s4   
r!   )r   )sounddevicer
   r   r   r!   r   r   r   r    <module>   s    