
    AVhQ                        d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZm Z m!Z! ddl"m#Z# d/de#e!ejH                  f   de%de%de&de#e!ejH                  f   f
dZ'  ed       ejP                  e'            Z)de#e!ejH                  f   de%de%de&de#e!ejH                  f   f
dZ* ejV                  dddg      Z,ejZ                  ej\                   ed      d0de#e!ej^                  f   de%de%fd                      Z0  ed!       ejP                  e0            Z1e0jd                  jf                  Z4de#e!ej^                  f   de%de%fd"Z5ejZ                  ej\                   ed#      d1de#e!ejH                  f   de#e!ejl                  f   de#e!ej^                  f   fd$                     Z7  ed%       ejP                  e7            Z8e7jd                  jf                  Z9de#e!ejH                  f   de#e!ejl                  f   de#e!ej^                  f   fd&Z:d2d'e#e!ejH                  f   de#e!ejl                  f   d(e;d)e;d*e%d+e%de#e!ejH                  f   fd,Z<  ed-       ejP                  e<            Z=d'e#e!ejH                  f   de#e!ejl                  f   d(e;d)e;d*e%d+e%de#e!ejH                  f   fd.Z>y)3zUPython wrappers around TensorFlow ops.

This file is MACHINE GENERATED! Do not edit.
    N)
pywrap_tfe)context)core)execute)dtypes)annotation_types)op_def_registry)ops)op_def_library)deprecated_endpoints)dispatch)	tf_export)TypeVarListAny)	Annotatedinputwindow_sizestridemagnitude_squaredreturnc                 h   t         j                   xs t        j                         }|j                  }|j                  r!	 t	        j
                  |d|| d|d|d|
      }|S t        j                  |d      }t        j                  |d      }|d}t        j                  |d      }t!        j"                  d| ||||      \  }	}	}
}|dd }t        j$                         rYd|
j'                  d      d|
j'                  d      d|
j)                  d      f}|
j*                  }t        j,                  d|||       |\  }|S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | |||||      S # t        j                  $ r Y Pw xY w)	a  Produces a visualization of audio data over time.

  Spectrograms are a standard way of representing audio information as a series of
  slices of frequency information, one slice for each window of time. By joining
  these together into a sequence, they form a distinctive fingerprint of the sound
  over time.

  This op expects to receive audio data as an input, stored as floats in the range
  -1 to 1, together with a window width in samples, and a stride specifying how
  far to move the window between slices. From this it generates a three
  dimensional output. The first dimension is for the channels in the input, so a
  stereo audio input would have two here for example. The second dimension is time,
  with successive frequency slices. The third dimension has an amplitude value for
  each frequency during that time slice.

  This means the layout when converted and saved as an image is rotated 90 degrees
  clockwise from a typical spectrogram. Time is descending down the Y axis, and
  the frequency decreases from left to right.

  Each value in the result represents the square root of the sum of the real and
  imaginary parts of an FFT on the current window of samples. In this way, the
  lowest dimension represents the power of each frequency in the current window,
  and adjacent windows are concatenated in the next dimension.

  To get a more intuitive and visual look at what this operation does, you can run
  tensorflow/examples/wav_to_spectrogram to read in an audio file and save out the
  resulting spectrogram as a PNG image.

  Args:
    input: A `Tensor` of type `float32`. Float representation of audio data.
    window_size: An `int`.
      How wide the input window is in samples. For the highest efficiency
      this should be a power of two, but other values are accepted.
    stride: An `int`.
      How widely apart the center of adjacent sample windows should be.
    magnitude_squared: An optional `bool`. Defaults to `False`.
      Whether to return the squared magnitude or just the
      magnitude. Using squared magnitude can avoid extra calculations.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `float32`.
  AudioSpectrogramr   r   r   N)r   r   r   namectxF)r   r   r   r   r   )_contextr   _thread_local_datais_eagerr   TFE_Py_FastPathExecute_core_NotOkStatusException_opsraise_from_not_ok_status_FallbackException audio_spectrogram_eager_fallback_SymbolicException_executemake_int	make_bool_op_def_library_apply_op_helpermust_record_gradient_get_attr_int_get_attr_boolinputsrecord_gradient)r   r   r   r   r   _ctxtld_resulte__op_outputs_attrs_inputs_flats                 S/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/gen_audio_ops.pyaudio_spectrogramr;      s   X 
			0h..0$#\\11 $}k&-/@Bg n !!+}=+VX.&(():<OP'88%[#).?dL!QX QK'""$S..}=x)+>  !457F ::LL&';('	.; && -
##At,,## 
-
[-DdD D ## 
s0    D> >FE,,FF	F F10F1zraw_ops.AudioSpectrogramc                    t        j                  |d      }t        j                  |d      }|d}t        j                  |d      }t        j                  | t
        j                        } | g}d|d|d|f}t        j                  dd||||      }t        j                         rt        j                  d|||       |\  }|S )	Nr   r   Fr   s   AudioSpectrogram   r/   attrsr   r   r   )
r'   r(   r)   r"   convert_to_tensor_dtypesfloat32r   r,   r0   )	r   r   r   r   r   r   r9   r8   r3   s	            r:   r%   r%   o   s    !!+}=+VX.&(():<OP

 
 
8%,;&:M&0!L#)s?'""$L&';('	.    	DecodeWavaudiosample_ratezaudio.decode_wavcontentsdesired_channelsdesired_samplesc                 6   t         j                   xs t        j                         }|j                  }|j                  r4	 t	        j
                  |d|| d|d|      }t        j                  |      }|S t        | |||fd      }|t        ur|S |d}t3        j4                  |d      }|d}t3        j4                  |d      }	 t7        j8                  d| |||      \  }}}	}
|
dd }t3        j:                         rHd|	j=                  d      d|	j=                  d      f}|	j>                  }t3        j@                  d|||       t        j                  |      }|S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | |||fd      }|t        ur|S t        | ||||      S # t        j                   $ r Y Wt"        t$        f$ rJ t'        j(                  t*        dt-        | |||            }|t&        j.                  j0                  ur|cY S  w xY w# t"        t$        f$ rJ t'        j(                  t*        dt-        | |||            }|t&        j.                  j0                  ur|cY S  w xY w)	a  Decode a 16-bit PCM WAV file to a float tensor.

  The -32768 to 32767 signed 16-bit values will be scaled to -1.0 to 1.0 in float.

  When desired_channels is set, if the input contains fewer channels than this
  then the last channel will be duplicated to give the requested number, else if
  the input has more channels than requested then the additional channels will be
  ignored.

  If desired_samples is set, then the audio will be cropped or padded with zeroes
  to the requested length.

  The first output contains a Tensor with the content of the audio samples. The
  lowest dimension will be the number of channels, and the second will be the
  number of samples. For example, a ten-sample-long stereo WAV file should give an
  output shape of [10, 2].

  Args:
    contents: A `Tensor` of type `string`.
      The WAV-encoded audio, usually from a file.
    desired_channels: An optional `int`. Defaults to `-1`.
      Number of sample channels wanted.
    desired_samples: An optional `int`. Defaults to `-1`.
      Length of audio requested.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (audio, sample_rate).

    audio: A `Tensor` of type `float32`.
    sample_rate: A `Tensor` of type `int32`.
  rD   rH   rI   N)rH   rI   r   r    )rG   rH   rI   r   )!r   r   r   r   r   r   _DecodeWavOutput_maker    r!   r"   r#   r$   _dispatcher_for_decode_wavNotImplementeddecode_wav_eager_fallbackr&   	TypeError
ValueError	_dispatchr   
decode_wavdictOpDispatcherNOT_SUPPORTEDr'   r(   r*   r+   r,   r-   r/   r0   )rG   rH   rI   r   r1   r2   r3   r4   r5   r6   r7   r8   r9   s                r:   rU   rU      s   H 
			0h..0$#\\	11k4+=+_>g !&&w/gn2 )	#_d<dDGn$n&&'79KLO%%o7HI/
)::h9I%44AAq#x QK'""$ #"3"34F"G!2!23D!EGF::L\674""7+'	.q && -
##At,,## 
*%
>Fg		&&
%5)$@ @ ## 
z" ""D(2B1@tMg
 
	..<<	<2 Z	  
  
b$0@/>TK
G
 i,,:::n	
sP    2E H? F ,FF F $G >G H<$AH<:H<?AJJzraw_ops.DecodeWavc                    |d}t        j                  |d      }|d}t        j                  |d      }t        j                  | t        j
                        } | g}d|d|f}t        j                  dd||||      }t        j                         rt        j                  d|||       t        j                  |      }|S )NrL   rH   rI   s	   DecodeWav   r>   rD   )r'   r(   r"   r@   rA   stringr   r,   r0   rM   rN   )rG   rH   rI   r   r   r9   r8   r3   s           r:   rQ   rQ      s    &&'79KLO%%o7HI/##Hgnn=(, 02C&\1\#)s?'""$\674""7+'	.rC   zaudio.encode_wavc           
      *   t         j                   xs t        j                         }|j                  }|j                  r	 t	        j
                  |d|| |      }|S t        | ||fd      }|t        ur|S 	 t/        j0                  d| ||      \  }}}}	|	dd }t3        j4                         r&d}
|j6                  }t3        j8                  d||
|       |\  }|S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | ||fd      }|t        ur|S t        | |||      S # t        j                  $ r Y t        t         f$ rI t#        j$                  t&        dt)        | ||            }|t"        j*                  j,                  ur|cY S  w xY w# t        t         f$ rI t#        j$                  t&        dt)        | ||            }|t"        j*                  j,                  ur|cY S  w xY w)a  Encode audio data using the WAV file format.

  This operation will generate a string suitable to be saved out to create a .wav
  audio file. It will be encoded in the 16-bit PCM format. It takes in float
  values in the range -1.0f to 1.0f, and any outside that value will be clamped to
  that range.

  `audio` is a 2-D float Tensor of shape `[length, channels]`.
  `sample_rate` is a scalar Tensor holding the rate to use (e.g. 44100).

  Args:
    audio: A `Tensor` of type `float32`. 2-D with shape `[length, channels]`.
    sample_rate: A `Tensor` of type `int32`.
      Scalar containing the sample frequency.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `string`.
  	EncodeWavN)r   r   rK   )rE   rF   r   )r   r   r   r   r   r   r    r!   r"   r#   r$   _dispatcher_for_encode_wavrP   encode_wav_eager_fallbackr&   rR   rS   rT   r   
encode_wavrV   rW   rX   r*   r+   r'   r,   r/   r0   )rE   rF   r   r1   r2   r3   r4   r5   r6   r7   r8   r9   s               r:   r`   r`     s    . 
			0h..0$#\\11k45gn. )	T#T+Gn$n

)::5kFAq#x QK'""$F::L\674('	.[ && -
##At,,## 
*+t
%t-g		&&
4T3 3## 
z" ""Du+&*,g 
	..<<	<" Z	  
  
b$U$(*
G i,,:::n	
sP    C 5F: D+DDD#E <E F7 AF75F7:AHHzraw_ops.EncodeWavc                 8   t        j                  | t        j                        } t        j                  |t        j                        }| |g}d }t        j                  dd||||      }t        j                         rt        j                  d|||       |\  }|S )Ns	   EncodeWavr=   r>   r]   )	r"   r@   rA   rB   int32r'   r   r,   r0   )rE   rF   r   r   r9   r8   r3   s          r:   r_   r_   V  s    

 
 
8%&&{GMMB+%,&\1\#)s?'""$\674('	.rC   spectrogramupper_frequency_limitlower_frequency_limitfilterbank_channel_countdct_coefficient_countc                    t         j                   xs t        j                         }|j                  }|j                  r$	 t	        j
                  |d|| |d|d|d|d|      }	|	S |d}t        j                  |d      }|d	}t        j                  |d      }|d
}t        j                  |d      }|d}t        j                  |d      }t!        j"                  d| ||||||      \  }}}}|dd }	t        j$                         rjd|j'                  d      d|j'                  d      d|j)                  d      d|j)                  d      f}|j*                  }t        j,                  d|||	       |	\  }	|	S # t        j                  $ r }
t        j                  |
|       Y d}
~
nd}
~
wt        j                  $ r Y nw xY w	 t        | |||||||      S # t        j                  $ r Y w xY w)av  Transforms a spectrogram into a form that's useful for speech recognition.

  Mel Frequency Cepstral Coefficients are a way of representing audio data that's
  been effective as an input feature for machine learning. They are created by
  taking the spectrum of a spectrogram (a 'cepstrum'), and discarding some of the
  higher frequencies that are less significant to the human ear. They have a long
  history in the speech recognition world, and https://en.wikipedia.org/wiki/Mel-frequency_cepstrum
  is a good resource to learn more.

  Args:
    spectrogram: A `Tensor` of type `float32`.
      Typically produced by the Spectrogram op, with magnitude_squared
      set to true.
    sample_rate: A `Tensor` of type `int32`.
      How many samples per second the source audio used.
    upper_frequency_limit: An optional `float`. Defaults to `4000`.
      The highest frequency to use when calculating the
      ceptstrum.
    lower_frequency_limit: An optional `float`. Defaults to `20`.
      The lowest frequency to use when calculating the
      ceptstrum.
    filterbank_channel_count: An optional `int`. Defaults to `40`.
      Resolution of the Mel bank used internally.
    dct_coefficient_count: An optional `int`. Defaults to `13`.
      How many output channels to produce per time slice.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `float32`.
  Mfccrd   re   rf   rg   N)rd   re   rf   rg   r   r        (      )rc   rF   rd   re   rf   rg   r   )r   r   r   r   r   r   r    r!   r"   r#   r$   mfcc_eager_fallbackr&   r'   
make_floatr(   r*   r+   r,   get_attrr-   r/   r0   )rc   rF   rd   re   rf   rg   r   r1   r2   r3   r4   r5   r6   r7   r8   r9   s                   r:   mfccrq   d  s1   > 
			0h..0$#\\
11fdK6M68M"$<!6	8g
 n " "--.CE\]""--.CE\]%!%../GIcd""++,ACZ['88K[&;&;)A&;$H!QX QK'""$%s||4K'L%s||4K'L( :;% 78:F ::Lfg/('	.Y && -
##At,,## 
 
{ 5 5#; 5DdL L ## 
s0    "E6 6F=	F$$F=<F=G G+*G+zraw_ops.Mfccc                    |d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }t        j                  | t
        j                        } t        j                  |t
        j                        }| |g}d|d|d|d|f}	t        j                  d	d
||	||      }
t        j                         rt        j                  d||	|
       |
\  }
|
S )Nrj   rd   rk   re   rl   rf   rm   rg   s   Mfccr=   r>   ri   )r'   ro   r(   r"   r@   rA   rB   rb   r   r,   r0   )rc   rF   rd   re   rf   rg   r   r   r9   r8   r3   s              r:   rn   rn     s*   " "--.CE\]""--.CE\]%!%../GIcd""++,ACZ[&&{GOOD+&&{GMMB+{+,#%:02L35JL& WaF!$41'""$fg/('	.rC   )FN)rL   rL   N)N)rj   rk   rl   rm   N)?__doc__collectionstensorflow.pythonr   tensorflow.python.eagerr   r   r   r    r   r'   tensorflow.python.frameworkr   rA   tensorflow.security.fuzzing.pyr   _atypesr	   _op_def_registryr
   r"   r   r*   "tensorflow.python.util.deprecationr   tensorflow.python.utilr   rT    tensorflow.python.util.tf_exportr   typingr   r   r   typing_extensionsr   Float32intboolr;   	to_raw_opr   r%   
namedtuplerM   add_fallback_dispatch_listadd_type_based_api_dispatcherStringrU   rD   _tf_type_based_dispatcherDispatchrO   rQ   Int32r`   r]   r^   r_   floatrq   ri   rn   rK   rC   r:   <module>r      s  
  6 7 1 7 9 F K 3 I C 8 6 % % 'QYsGOO';< Q3 QX[ Qos Q  JS  TW  Y`  Yh  Yh  Th  Ji Qf 9978HY9Z[ Ic7??6J,K Z] gj   @D   T]  ^a  cj  cr  cr  ^r  Ts $ *;))m 
 %%
((
b3#67 b# bbe b  ) &bH +I)*>4>>*+EF	'AAJJ 	#w~~2E(F Z] ps ( %%
((
HiW__ 45 HIcSZS`S`N`Da Hqz{~  AH  AO  AO  |O  rP H  ) &HT +I)*>4>>*+EF	'AAJJ YsGOO/C%D S\]`bibobo]oSp   AJ  KN  PW  P^  P^  K^  A_ UiW__ 45 UIcSZS`S`N`Da Uy~ U  \a U  B U  ]` U  s|  }@  BI  BQ  BQ  }Q  sR Un !y !56YsGOO/C%D S\]`bibobo]oSp   JO   hm   IL   eh   xA  BE  GN  GV  GV  BV  xW rC   