
    mPj?                     T    d Z ddlZddlmc mZ ddlZddlZddl	Z
ddlZd Zd Zd Zy)zJWAV encoding: float32 PCM -> valid 16-bit PCM WAV bytes (no model needed).    Nc            	      4	   t        j                  t        j                  ddd            dz  j                  t         j                        } t        j                  | t
        j                        }t        j                  t        j                  |      d      5 }|j                  } |       }d}||k(  }|st        j                  d|fd||f      d	t        j                          v st        j"                  |      rt        j$                  |      nd	t        j$                  |      t        j$                  |      t        j$                  |      d
z  }dd|iz  }t'        t        j(                  |            d x}x}x}}|j*                  } |       }d}||k(  }|st        j                  d|fd||f      d	t        j                          v st        j"                  |      rt        j$                  |      nd	t        j$                  |      t        j$                  |      t        j$                  |      d
z  }dd|iz  }t'        t        j(                  |            d x}x}x}}|j,                  } |       }t
        j                  }	||	k(  }|s
t        j                  d|fd||	f      d	t        j                          v st        j"                  |      rt        j$                  |      nd	t        j$                  |      t        j$                  |      dt        j                          v st        j"                  t
              rt        j$                  t
              ndt        j$                  |	      dz  }
dd|
iz  }t'        t        j(                  |            d x}x}x}}	|j.                  } |       }d}||k(  }|st        j                  d|fd||f      d	t        j                          v st        j"                  |      rt        j$                  |      nd	t        j$                  |      t        j$                  |      t        j$                  |      d
z  }dd|iz  }t'        t        j(                  |            d x}x}x}}d d d        y # 1 sw Y   y xY w)Nr   gQ@i`	  g      ?rb   ==)zK%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.getnchannels
}()
} == %(py7)swpy0py2py4py7assert %(py9)spy9   )zK%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.getsampwidth
}()
} == %(py7)s)zl%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.getframerate
}()
} == %(py8)s
{%(py8)s = %(py6)s.SAMPLE_RATE
}tts)r
   r   r   py6py8zassert %(py10)spy10zI%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.getnframes
}()
} == %(py7)s)npsinlinspaceastypefloat32r   float32_to_wav_bytesSAMPLE_RATEwaveopenioBytesIOgetnchannels
@pytest_ar_call_reprcompare@py_builtinslocals_should_repr_global_name	_safereprAssertionError_format_explanationgetsampwidthgetframerate
getnframes)samplesblobr   @py_assert1@py_assert3@py_assert6@py_assert5@py_format8@py_format10@py_assert7@py_format9@py_format11s               H/Users/ahmed/devFolder/Ultron/claude-voice/gateway/tests/test_tts_wav.py"test_wav_bytes_are_valid_16bit_pcmr9   
   s   vvbkk!T401C7??

KG##GS__=D	2::d#T	*a~~$~$1$1$$$$1$$$$$$q$$$q$$$~$$$$$$1$$$$$$$~~$~$1$1$$$$1$$$$$$q$$$q$$$~$$$$$$1$$$$$$$~~2~23??2?2222?222222q222q222~22222222232223222?2222222||%|~%%~%%%%~%%%%%%q%%%q%%%|%%%~%%%%%%%%%%	 
+	*	*s   O-RRc                     t        j                  t        j                  dt        j                              } t        j                  t        j                  |       d      5 }|j                  } |       }d}||k(  }|st        j                  d|fd||f      dt        j                         v st        j                  |      rt        j                  |      ndt        j                  |      t        j                  |      t        j                  |      dz  }dd	|iz  }t!        t        j"                  |            d x}x}x}}d d d        y # 1 sw Y   y xY w)
Nr   dtyper   r   r   r   r	   r   r   )r   r   r   zerosr   r   r   r   r    r,   r"   r#   r$   r%   r&   r'   r(   r)   )r.   r   r/   r0   r1   r2   r3   r4   s           r8   "test_empty_samples_still_valid_wavr>      s    ##BHHQbjj$ABD	2::d#T	*a||"|~""~""""~""""""q"""q"""|"""~"""""""""" 
+	*	*s   "C&EEc                  f   t        j                  ddgt         j                        } t        j                  |       }t        j                  t        j                  |      d      5 }|j                  |j                               }d d d        t        j                  d      }g }|j                  } |       }d}||k  }	|	}
|	r|j                  } |       }d}| }||k\  }|}
|
st        j                  d|	fd||f      d	t!        j"                         v st        j$                  |      rt        j&                  |      nd	t        j&                  |      t        j&                  |      t        j&                  |      d
z  }dd|iz  }|j)                  |       |	rt        j                  dfdf      d	t!        j"                         v st        j$                  |      rt        j&                  |      nd	t        j&                        t        j&                  |      t        j&                        dz  }dd|iz  }|j)                  |       t        j*                  |d      i z  }dd|iz  }t-        t        j.                  |            d x}
x}x}x}x}	x}x}x}x}x}}y # 1 sw Y   "xY w)Ng      @g      r;   r   z<i2i  )<=)zB%(py6)s
{%(py6)s = %(py4)s
{%(py4)s = %(py2)s.max
}()
} <= %(py9)svals)r   r   r   r   z%(py11)spy11)>=)zI%(py17)s
{%(py17)s = %(py15)s
{%(py15)s = %(py13)s.min
}()
} >= -%(py20)s)py13py15py17py20z%(py23)spy23r   zassert %(py26)spy26)r   arrayr   r   r   r   r   r   r    
readframesr,   
frombuffermaxminr"   r#   r$   r%   r&   r'   append_format_boolopr(   r)   )loudr.   r   framesrA   r/   r0   r2   @py_assert8r5   @py_assert0@py_assert14@py_assert16@py_assert19@py_assert21@py_assert18r4   @py_format12@py_format22@py_format24@py_format25@py_format27s                         r8   test_clipping_is_appliedr_      s   88S$Krzz2D##D)D	2::d#T	*aalln- 
+==u-D748878:77:748878:7%7%7:#77777:777777477747778777:7777777777:777777477747778777:777%777777777777777 
+	*s   & J&&J0)__doc__builtinsr$   _pytest.assertion.rewrite	assertionrewriter"   r   r   numpyr   r   r9   r>   r_        r8   <module>rh      s'    P   	   
&#8rg   