import{s as Et,n as St,o as Ot}from"../chunks/scheduler.25b97de1.js";import{S as Ut,i as At,g as a,s as o,r as _,A as Vt,h as s,f as r,c as n,j as q,u as b,x as l,k as $,y as t,a as d,v,d as w,t as x,w as y}from"../chunks/index.d9030fc9.js";import{D as F}from"../chunks/Docstring.ffac8efa.js";import{H as Bt,E as jt}from"../chunks/EditOnGithub.91d95064.js";function Wt(dt){let C,we,be,xe,L,ye,P,ct="This page lists all the utility functions that can be used by the audio <code>FeatureExtractor</code> in order to compute special features from a raw audio using common algorithms such as <em>Short Time Fourier Transform</em> or <em>log mel spectrogram</em>.",Te,D,mt="Most of those are only useful if you are studying the code of the audio processors in the library.",qe,I,$e,k,N,Ee,W,ut="Convert frequency from hertz to mels.",Ce,z,B,Se,G,pt="Convert frequency from mels to hertz.",ke,u,E,Oe,K,ft=`Creates a frequency bin conversion matrix used to obtain a mel spectrogram. This is called a <em>mel filter bank</em>, and
various implementation exist, which differ in the number of filters, the shape of the filters, the way the filters
are spaced, the bandwidth of the filters, and the manner in which the spectrum is warped. The goal of these
features is to approximate the non-linear human perception of the variation in pitch with respect to the frequency.`,Ue,R,ht="Different banks of mel filters were introduced in the literature. The following variations are supported:",Ae,J,gt=`<li>MFCC FB-20: introduced in 1980 by Davis and Mermelstein, it assumes a sampling frequency of 10 kHz and a speech
bandwidth of <code>[0, 4600]</code> Hz.</li> <li>MFCC FB-24 HTK: from the Cambridge HMM Toolkit (HTK) (1995) uses a filter bank of 24 filters for a speech
bandwidth of <code>[0, 8000]</code> Hz. This assumes sampling rate ≥ 16 kHz.</li> <li>MFCC FB-40: from the Auditory Toolbox for MATLAB written by Slaney in 1998, assumes a sampling rate of 16 kHz and
speech bandwidth of <code>[133, 6854]</code> Hz. This version also includes area normalization.</li> <li>HFCC-E FB-29 (Human Factor Cepstral Coefficients) of Skowronski and Harris (2004), assumes a sampling rate of
12.5 kHz and speech bandwidth of <code>[0, 6250]</code> Hz.</li>`,Ve,Q,_t=`This code is adapted from <em>torchaudio</em> and <em>librosa</em>. Note that the default parameters of torchaudio’s
<code>melscale_fbanks</code> implement the <code>&quot;htk&quot;</code> filters while librosa uses the <code>&quot;slaney&quot;</code> implementation.`,ze,h,S,je,X,bt=`Finds the best FFT input size for a given <code>window_length</code>. This function takes a given window length and, if not
already a power of two, rounds it up to the next power or two.`,We,Y,vt=`The FFT algorithm works fastest when the length of the input is a power of two, which may be larger than the size
of the window or analysis frame. For example, if the window is 400 samples, using an FFT input size of 512 samples
is more optimal than an FFT size of 400 samples. Using a larger FFT size does not affect the detected frequencies,
it simply gives a higher frequency resolution (i.e. the frequency bins are smaller).`,He,p,O,Ge,Z,wt="Returns an array containing the specified window. This window is intended to be used with <code>stft</code>.",Ke,ee,xt="The following window types are supported:",Re,te,yt="<li><code>&quot;boxcar&quot;</code>: a rectangular window</li> <li><code>&quot;hamming&quot;</code>: the Hamming window</li> <li><code>&quot;hann&quot;</code>: the Hann window</li> <li><code>&quot;povey&quot;</code>: the Povey window</li>",Me,c,U,Je,oe,Tt="Calculates a spectrogram over one waveform using the Short-Time Fourier Transform.",Qe,ne,qt="This function can create the following kinds of spectrograms:",Xe,re,$t="<li>amplitude spectrogram (<code>power = 1.0</code>)</li> <li>power spectrogram (<code>power = 2.0</code>)</li> <li>complex-valued spectrogram (<code>power = None</code>)</li> <li>log spectrogram (use <code>log_mel</code> argument)</li> <li>mel spectrogram (provide <code>mel_filters</code>)</li> <li>log-mel spectrogram (provide <code>mel_filters</code> and <code>log_mel</code>)</li>",Ye,ae,Ct="How this works:",Ze,se,kt="<li>The input waveform is split into frames of size <code>frame_length</code> that are partially overlapping by `frame_length<ul><li>hop_length` samples.</li></ul></li> <li>Each frame is multiplied by the window and placed into a buffer of size <code>fft_length</code>.</li> <li>The DFT is taken of each windowed frame.</li> <li>The results are stacked into a spectrogram.</li>",et,ie,zt="We make a distinction between the following “blocks” of sample data, each of which may have a different lengths:",tt,le,Ht="<li>The analysis frame. This is the size of the time slices that the input waveform is split into.</li> <li>The window. Each analysis frame is multiplied by the window to avoid spectral leakage.</li> <li>The FFT input buffer. The length of this determines how many frequency bins are in the spectrogram.</li>",ot,de,Mt=`In this implementation, the window is assumed to be zero-padded to have the same size as the analysis frame. A
padded window can be obtained from <code>window_function()</code>. The FFT input buffer may be larger than the analysis frame,
typically the next power of two.`,nt,ce,Ft=`Note: This function is not optimized for speed yet. It should be mostly compatible with <code>librosa.stft</code> and
<code>torchaudio.functional.transforms.Spectrogram</code>, although it is more flexible due to the different ways spectrograms
can be constructed.`,Fe,f,A,rt,me,Lt=`Converts a power spectrogram to the decibel scale. This computes <code>10 * log10(spectrogram / reference)</code>, using basic
logarithm properties for numerical stability.`,at,ue,Pt=`The motivation behind applying the log function on the (mel) spectrogram is that humans do not hear loudness on a
linear scale. Generally to double the perceived volume of a sound we need to put 8 times as much energy into it.
This means that large variations in energy may not sound all that different if the sound is loud to begin with.
This compression operation makes the (mel) spectrogram features match more closely what humans actually hear.`,st,pe,Dt="Based on the implementation of <code>librosa.power_to_db</code>.",Le,g,V,it,fe,It=`Converts an amplitude spectrogram to the decibel scale. This computes <code>20 * log10(spectrogram / reference)</code>, using
basic logarithm properties for numerical stability.`,lt,he,Nt=`The motivation behind applying the log function on the (mel) spectrogram is that humans do not hear loudness on a
linear scale. Generally to double the perceived volume of a sound we need to put 8 times as much energy into it.
This means that large variations in energy may not sound all that different if the sound is loud to begin with.
This compression operation makes the (mel) spectrogram features match more closely what humans actually hear.`,Pe,j,De,ve,Ie;return L=new Bt({props:{title:"Utilities for FeatureExtractors",local:"utilities-for-featureextractors",headingTag:"h1"}}),I=new Bt({props:{title:"Audio Transformations",local:"transformers.audio_utils.hertz_to_mel",headingTag:"h2"}}),N=new F({props:{name:"transformers.audio_utils.hertz_to_mel",anchor:"transformers.audio_utils.hertz_to_mel",parameters:[{name:"freq",val:": Union"},{name:"mel_scale",val:": str = 'htk'"}],parametersDescription:[{anchor:"transformers.audio_utils.hertz_to_mel.freq",description:`<strong>freq</strong> (<code>float</code> or <code>np.ndarray</code>) &#x2014;
The frequency, or multiple frequencies, in hertz (Hz).`,name:"freq"},{anchor:"transformers.audio_utils.hertz_to_mel.mel_scale",description:`<strong>mel_scale</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;htk&quot;</code>) &#x2014;
The mel frequency scale to use, <code>&quot;htk&quot;</code>, <code>&quot;kaldi&quot;</code> or <code>&quot;slaney&quot;</code>.`,name:"mel_scale"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/audio_utils.py#L26",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The frequencies on the mel scale.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>float</code> or <code>np.ndarray</code></p>
`}}),B=new F({props:{name:"transformers.audio_utils.mel_to_hertz",anchor:"transformers.audio_utils.mel_to_hertz",parameters:[{name:"mels",val:": Union"},{name:"mel_scale",val:": str = 'htk'"}],parametersDescription:[{anchor:"transformers.audio_utils.mel_to_hertz.mels",description:`<strong>mels</strong> (<code>float</code> or <code>np.ndarray</code>) &#x2014;
The frequency, or multiple frequencies, in mels.`,name:"mels"},{anchor:"transformers.audio_utils.mel_to_hertz.mel_scale",description:`<strong>mel_scale</strong> (<code>str</code>, <em>optional</em>, <code>&quot;htk&quot;</code>) &#x2014;
The mel frequency scale to use, <code>&quot;htk&quot;</code>, <code>&quot;kaldi&quot;</code> or <code>&quot;slaney&quot;</code>.`,name:"mel_scale"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/audio_utils.py#L62",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The frequencies in hertz.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>float</code> or <code>np.ndarray</code></p>
`}}),E=new F({props:{name:"transformers.audio_utils.mel_filter_bank",anchor:"transformers.audio_utils.mel_filter_bank",parameters:[{name:"num_frequency_bins",val:": int"},{name:"num_mel_filters",val:": int"},{name:"min_frequency",val:": float"},{name:"max_frequency",val:": float"},{name:"sampling_rate",val:": int"},{name:"norm",val:": Optional = None"},{name:"mel_scale",val:": str = 'htk'"},{name:"triangularize_in_mel_space",val:": bool = False"}],parametersDescription:[{anchor:"transformers.audio_utils.mel_filter_bank.num_frequency_bins",description:`<strong>num_frequency_bins</strong> (<code>int</code>) &#x2014;
Number of frequencies used to compute the spectrogram (should be the same as in <code>stft</code>).`,name:"num_frequency_bins"},{anchor:"transformers.audio_utils.mel_filter_bank.num_mel_filters",description:`<strong>num_mel_filters</strong> (<code>int</code>) &#x2014;
Number of mel filters to generate.`,name:"num_mel_filters"},{anchor:"transformers.audio_utils.mel_filter_bank.min_frequency",description:`<strong>min_frequency</strong> (<code>float</code>) &#x2014;
Lowest frequency of interest in Hz.`,name:"min_frequency"},{anchor:"transformers.audio_utils.mel_filter_bank.max_frequency",description:`<strong>max_frequency</strong> (<code>float</code>) &#x2014;
Highest frequency of interest in Hz. This should not exceed <code>sampling_rate / 2</code>.`,name:"max_frequency"},{anchor:"transformers.audio_utils.mel_filter_bank.sampling_rate",description:`<strong>sampling_rate</strong> (<code>int</code>) &#x2014;
Sample rate of the audio waveform.`,name:"sampling_rate"},{anchor:"transformers.audio_utils.mel_filter_bank.norm",description:`<strong>norm</strong> (<code>str</code>, <em>optional</em>) &#x2014;
If <code>&quot;slaney&quot;</code>, divide the triangular mel weights by the width of the mel band (area normalization).`,name:"norm"},{anchor:"transformers.audio_utils.mel_filter_bank.mel_scale",description:`<strong>mel_scale</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;htk&quot;</code>) &#x2014;
The mel frequency scale to use, <code>&quot;htk&quot;</code>, <code>&quot;kaldi&quot;</code> or <code>&quot;slaney&quot;</code>.`,name:"mel_scale"},{anchor:"transformers.audio_utils.mel_filter_bank.triangularize_in_mel_space",description:`<strong>triangularize_in_mel_space</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If this option is enabled, the triangular filter is applied in mel space rather than frequency space. This
should be set to <code>true</code> in order to get the same results as <code>torchaudio</code> when computing mel filters.`,name:"triangularize_in_mel_space"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/audio_utils.py#L218",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Triangular filter bank matrix. This is a
projection matrix to go from a spectrogram to a mel spectrogram.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>np.ndarray</code> of shape (<code>num_frequency_bins</code>, <code>num_mel_filters</code>)</p>
`}}),S=new F({props:{name:"transformers.audio_utils.optimal_fft_length",anchor:"transformers.audio_utils.optimal_fft_length",parameters:[{name:"window_length",val:": int"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/audio_utils.py#L306"}}),O=new F({props:{name:"transformers.audio_utils.window_function",anchor:"transformers.audio_utils.window_function",parameters:[{name:"window_length",val:": int"},{name:"name",val:": str = 'hann'"},{name:"periodic",val:": bool = True"},{name:"frame_length",val:": Optional = None"},{name:"center",val:": bool = True"}],parametersDescription:[{anchor:"transformers.audio_utils.window_function.window_length",description:`<strong>window_length</strong> (<code>int</code>) &#x2014;
The length of the window in samples.`,name:"window_length"},{anchor:"transformers.audio_utils.window_function.name",description:`<strong>name</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;hann&quot;</code>) &#x2014;
The name of the window function.`,name:"name"},{anchor:"transformers.audio_utils.window_function.periodic",description:`<strong>periodic</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether the window is periodic or symmetric.`,name:"periodic"},{anchor:"transformers.audio_utils.window_function.frame_length",description:`<strong>frame_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The length of the analysis frames in samples. Provide a value for <code>frame_length</code> if the window is smaller
than the frame length, so that it will be zero-padded.`,name:"frame_length"},{anchor:"transformers.audio_utils.window_function.center",description:`<strong>center</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to center the window inside the FFT buffer. Only used when <code>frame_length</code> is provided.`,name:"center"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/audio_utils.py#L319",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>np.ndarray</code> of shape <code>(window_length,)</code> or <code>(frame_length,)</code> containing the window.</p>
`}}),U=new F({props:{name:"transformers.audio_utils.spectrogram",anchor:"transformers.audio_utils.spectrogram",parameters:[{name:"waveform",val:": ndarray"},{name:"window",val:": ndarray"},{name:"frame_length",val:": int"},{name:"hop_length",val:": int"},{name:"fft_length",val:": Optional = None"},{name:"power",val:": Optional = 1.0"},{name:"center",val:": bool = True"},{name:"pad_mode",val:": str = 'reflect'"},{name:"onesided",val:": bool = True"},{name:"preemphasis",val:": Optional = None"},{name:"mel_filters",val:": Optional = None"},{name:"mel_floor",val:": float = 1e-10"},{name:"log_mel",val:": Optional = None"},{name:"reference",val:": float = 1.0"},{name:"min_value",val:": float = 1e-10"},{name:"db_range",val:": Optional = None"},{name:"remove_dc_offset",val:": Optional = None"},{name:"dtype",val:": dtype = <class 'numpy.float32'>"}],parametersDescription:[{anchor:"transformers.audio_utils.spectrogram.waveform",description:`<strong>waveform</strong> (<code>np.ndarray</code> of shape <code>(length,)</code>) &#x2014;
The input waveform. This must be a single real-valued, mono waveform.`,name:"waveform"},{anchor:"transformers.audio_utils.spectrogram.window",description:`<strong>window</strong> (<code>np.ndarray</code> of shape <code>(frame_length,)</code>) &#x2014;
The windowing function to apply, including zero-padding if necessary. The actual window length may be
shorter than <code>frame_length</code>, but we&#x2019;re assuming the array has already been zero-padded.`,name:"window"},{anchor:"transformers.audio_utils.spectrogram.frame_length",description:`<strong>frame_length</strong> (<code>int</code>) &#x2014;
The length of the analysis frames in samples. With librosa this is always equal to <code>fft_length</code> but we also
allow smaller sizes.`,name:"frame_length"},{anchor:"transformers.audio_utils.spectrogram.hop_length",description:`<strong>hop_length</strong> (<code>int</code>) &#x2014;
The stride between successive analysis frames in samples.`,name:"hop_length"},{anchor:"transformers.audio_utils.spectrogram.fft_length",description:`<strong>fft_length</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The size of the FFT buffer in samples. This determines how many frequency bins the spectrogram will have.
For optimal speed, this should be a power of two. If <code>None</code>, uses <code>frame_length</code>.`,name:"fft_length"},{anchor:"transformers.audio_utils.spectrogram.power",description:`<strong>power</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
If 1.0, returns the amplitude spectrogram. If 2.0, returns the power spectrogram. If <code>None</code>, returns
complex numbers.`,name:"power"},{anchor:"transformers.audio_utils.spectrogram.center",description:`<strong>center</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to pad the waveform so that frame <code>t</code> is centered around time <code>t * hop_length</code>. If <code>False</code>, frame
<code>t</code> will start at time <code>t * hop_length</code>.`,name:"center"},{anchor:"transformers.audio_utils.spectrogram.pad_mode",description:`<strong>pad_mode</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;reflect&quot;</code>) &#x2014;
Padding mode used when <code>center</code> is <code>True</code>. Possible values are: <code>&quot;constant&quot;</code> (pad with zeros), <code>&quot;edge&quot;</code>
(pad with edge values), <code>&quot;reflect&quot;</code> (pads with mirrored values).`,name:"pad_mode"},{anchor:"transformers.audio_utils.spectrogram.onesided",description:`<strong>onesided</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
If True, only computes the positive frequencies and returns a spectrogram containing <code>fft_length // 2 + 1</code>
frequency bins. If False, also computes the negative frequencies and returns <code>fft_length</code> frequency bins.`,name:"onesided"},{anchor:"transformers.audio_utils.spectrogram.preemphasis",description:`<strong>preemphasis</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Coefficient for a low-pass filter that applies pre-emphasis before the DFT.`,name:"preemphasis"},{anchor:"transformers.audio_utils.spectrogram.mel_filters",description:`<strong>mel_filters</strong> (<code>np.ndarray</code> of shape <code>(num_freq_bins, num_mel_filters)</code>, <em>optional</em>) &#x2014;
The mel filter bank. If supplied, applies a this filter bank to create a mel spectrogram.`,name:"mel_filters"},{anchor:"transformers.audio_utils.spectrogram.mel_floor",description:`<strong>mel_floor</strong> (<code>float</code>, <em>optional</em>, defaults to 1e-10) &#x2014;
Minimum value of mel frequency banks.`,name:"mel_floor"},{anchor:"transformers.audio_utils.spectrogram.log_mel",description:`<strong>log_mel</strong> (<code>str</code>, <em>optional</em>) &#x2014;
How to convert the spectrogram to log scale. Possible options are: <code>None</code> (don&#x2019;t convert), <code>&quot;log&quot;</code> (take
the natural logarithm) <code>&quot;log10&quot;</code> (take the base-10 logarithm), <code>&quot;dB&quot;</code> (convert to decibels). Can only be
used when <code>power</code> is not <code>None</code>.`,name:"log_mel"},{anchor:"transformers.audio_utils.spectrogram.reference",description:`<strong>reference</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Sets the input spectrogram value that corresponds to 0 dB. For example, use <code>np.max(spectrogram)</code> to set
the loudest part to 0 dB. Must be greater than zero.`,name:"reference"},{anchor:"transformers.audio_utils.spectrogram.min_value",description:`<strong>min_value</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-10</code>) &#x2014;
The spectrogram will be clipped to this minimum value before conversion to decibels, to avoid taking
<code>log(0)</code>. For a power spectrogram, the default of <code>1e-10</code> corresponds to a minimum of -100 dB. For an
amplitude spectrogram, the value <code>1e-5</code> corresponds to -100 dB. Must be greater than zero.`,name:"min_value"},{anchor:"transformers.audio_utils.spectrogram.db_range",description:`<strong>db_range</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Sets the maximum dynamic range in decibels. For example, if <code>db_range = 80</code>, the difference between the
peak value and the smallest value will never be more than 80 dB. Must be greater than zero.`,name:"db_range"},{anchor:"transformers.audio_utils.spectrogram.remove_dc_offset",description:`<strong>remove_dc_offset</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Subtract mean from waveform on each frame, applied before pre-emphasis. This should be set to <code>true</code> in
order to get the same results as <code>torchaudio.compliance.kaldi.fbank</code> when computing mel filters.`,name:"remove_dc_offset"},{anchor:"transformers.audio_utils.spectrogram.dtype",description:`<strong>dtype</strong> (<code>np.dtype</code>, <em>optional</em>, defaults to <code>np.float32</code>) &#x2014;
Data type of the spectrogram tensor. If <code>power</code> is None, this argument is ignored and the dtype will be
<code>np.complex64</code>.`,name:"dtype"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/audio_utils.py#L383",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>nd.array</code> containing a spectrogram of shape <code>(num_frequency_bins, length)</code> for a regular spectrogram or shape
<code>(num_mel_filters, length)</code> for a mel spectrogram.</p>
`}}),A=new F({props:{name:"transformers.audio_utils.power_to_db",anchor:"transformers.audio_utils.power_to_db",parameters:[{name:"spectrogram",val:": ndarray"},{name:"reference",val:": float = 1.0"},{name:"min_value",val:": float = 1e-10"},{name:"db_range",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.audio_utils.power_to_db.spectrogram",description:`<strong>spectrogram</strong> (<code>np.ndarray</code>) &#x2014;
The input power (mel) spectrogram. Note that a power spectrogram has the amplitudes squared!`,name:"spectrogram"},{anchor:"transformers.audio_utils.power_to_db.reference",description:`<strong>reference</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Sets the input spectrogram value that corresponds to 0 dB. For example, use <code>np.max(spectrogram)</code> to set
the loudest part to 0 dB. Must be greater than zero.`,name:"reference"},{anchor:"transformers.audio_utils.power_to_db.min_value",description:`<strong>min_value</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-10</code>) &#x2014;
The spectrogram will be clipped to this minimum value before conversion to decibels, to avoid taking
<code>log(0)</code>. The default of <code>1e-10</code> corresponds to a minimum of -100 dB. Must be greater than zero.`,name:"min_value"},{anchor:"transformers.audio_utils.power_to_db.db_range",description:`<strong>db_range</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Sets the maximum dynamic range in decibels. For example, if <code>db_range = 80</code>, the difference between the
peak value and the smallest value will never be more than 80 dB. Must be greater than zero.`,name:"db_range"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/audio_utils.py#L791",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>the spectrogram in decibels</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>np.ndarray</code></p>
`}}),V=new F({props:{name:"transformers.audio_utils.amplitude_to_db",anchor:"transformers.audio_utils.amplitude_to_db",parameters:[{name:"spectrogram",val:": ndarray"},{name:"reference",val:": float = 1.0"},{name:"min_value",val:": float = 1e-05"},{name:"db_range",val:": Optional = None"}],parametersDescription:[{anchor:"transformers.audio_utils.amplitude_to_db.spectrogram",description:`<strong>spectrogram</strong> (<code>np.ndarray</code>) &#x2014;
The input amplitude (mel) spectrogram.`,name:"spectrogram"},{anchor:"transformers.audio_utils.amplitude_to_db.reference",description:`<strong>reference</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Sets the input spectrogram value that corresponds to 0 dB. For example, use <code>np.max(spectrogram)</code> to set
the loudest part to 0 dB. Must be greater than zero.`,name:"reference"},{anchor:"transformers.audio_utils.amplitude_to_db.min_value",description:`<strong>min_value</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-5</code>) &#x2014;
The spectrogram will be clipped to this minimum value before conversion to decibels, to avoid taking
<code>log(0)</code>. The default of <code>1e-5</code> corresponds to a minimum of -100 dB. Must be greater than zero.`,name:"min_value"},{anchor:"transformers.audio_utils.amplitude_to_db.db_range",description:`<strong>db_range</strong> (<code>float</code>, <em>optional</em>) &#x2014;
Sets the maximum dynamic range in decibels. For example, if <code>db_range = 80</code>, the difference between the
peak value and the smallest value will never be more than 80 dB. Must be greater than zero.`,name:"db_range"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/audio_utils.py#L891",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>the spectrogram in decibels</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>np.ndarray</code></p>
`}}),j=new jt({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/internal/audio_utils.md"}}),{c(){C=a("meta"),we=o(),be=a("p"),xe=o(),_(L.$$.fragment),ye=o(),P=a("p"),P.innerHTML=ct,Te=o(),D=a("p"),D.textContent=mt,qe=o(),_(I.$$.fragment),$e=o(),k=a("div"),_(N.$$.fragment),Ee=o(),W=a("p"),W.textContent=ut,Ce=o(),z=a("div"),_(B.$$.fragment),Se=o(),G=a("p"),G.textContent=pt,ke=o(),u=a("div"),_(E.$$.fragment),Oe=o(),K=a("p"),K.innerHTML=ft,Ue=o(),R=a("p"),R.textContent=ht,Ae=o(),J=a("ul"),J.innerHTML=gt,Ve=o(),Q=a("p"),Q.innerHTML=_t,ze=o(),h=a("div"),_(S.$$.fragment),je=o(),X=a("p"),X.innerHTML=bt,We=o(),Y=a("p"),Y.textContent=vt,He=o(),p=a("div"),_(O.$$.fragment),Ge=o(),Z=a("p"),Z.innerHTML=wt,Ke=o(),ee=a("p"),ee.textContent=xt,Re=o(),te=a("ul"),te.innerHTML=yt,Me=o(),c=a("div"),_(U.$$.fragment),Je=o(),oe=a("p"),oe.textContent=Tt,Qe=o(),ne=a("p"),ne.textContent=qt,Xe=o(),re=a("ul"),re.innerHTML=$t,Ye=o(),ae=a("p"),ae.textContent=Ct,Ze=o(),se=a("ol"),se.innerHTML=kt,et=o(),ie=a("p"),ie.textContent=zt,tt=o(),le=a("ul"),le.innerHTML=Ht,ot=o(),de=a("p"),de.innerHTML=Mt,nt=o(),ce=a("p"),ce.innerHTML=Ft,Fe=o(),f=a("div"),_(A.$$.fragment),rt=o(),me=a("p"),me.innerHTML=Lt,at=o(),ue=a("p"),ue.textContent=Pt,st=o(),pe=a("p"),pe.innerHTML=Dt,Le=o(),g=a("div"),_(V.$$.fragment),it=o(),fe=a("p"),fe.innerHTML=It,lt=o(),he=a("p"),he.textContent=Nt,Pe=o(),_(j.$$.fragment),De=o(),ve=a("p"),this.h()},l(e){const i=Vt("svelte-u9bgzb",document.head);C=s(i,"META",{name:!0,content:!0}),i.forEach(r),we=n(e),be=s(e,"P",{}),q(be).forEach(r),xe=n(e),b(L.$$.fragment,e),ye=n(e),P=s(e,"P",{"data-svelte-h":!0}),l(P)!=="svelte-sdayy0"&&(P.innerHTML=ct),Te=n(e),D=s(e,"P",{"data-svelte-h":!0}),l(D)!=="svelte-1o3lpho"&&(D.textContent=mt),qe=n(e),b(I.$$.fragment,e),$e=n(e),k=s(e,"DIV",{class:!0});var Ne=q(k);b(N.$$.fragment,Ne),Ee=n(Ne),W=s(Ne,"P",{"data-svelte-h":!0}),l(W)!=="svelte-cxvipk"&&(W.textContent=ut),Ne.forEach(r),Ce=n(e),z=s(e,"DIV",{class:!0});var Be=q(z);b(B.$$.fragment,Be),Se=n(Be),G=s(Be,"P",{"data-svelte-h":!0}),l(G)!=="svelte-zjf634"&&(G.textContent=pt),Be.forEach(r),ke=n(e),u=s(e,"DIV",{class:!0});var T=q(u);b(E.$$.fragment,T),Oe=n(T),K=s(T,"P",{"data-svelte-h":!0}),l(K)!=="svelte-ke4v6b"&&(K.innerHTML=ft),Ue=n(T),R=s(T,"P",{"data-svelte-h":!0}),l(R)!=="svelte-1qgwg3t"&&(R.textContent=ht),Ae=n(T),J=s(T,"UL",{"data-svelte-h":!0}),l(J)!=="svelte-hp9cn6"&&(J.innerHTML=gt),Ve=n(T),Q=s(T,"P",{"data-svelte-h":!0}),l(Q)!=="svelte-7p7meu"&&(Q.innerHTML=_t),T.forEach(r),ze=n(e),h=s(e,"DIV",{class:!0});var ge=q(h);b(S.$$.fragment,ge),je=n(ge),X=s(ge,"P",{"data-svelte-h":!0}),l(X)!=="svelte-7kwh1t"&&(X.innerHTML=bt),We=n(ge),Y=s(ge,"P",{"data-svelte-h":!0}),l(Y)!=="svelte-iy5srj"&&(Y.textContent=vt),ge.forEach(r),He=n(e),p=s(e,"DIV",{class:!0});var H=q(p);b(O.$$.fragment,H),Ge=n(H),Z=s(H,"P",{"data-svelte-h":!0}),l(Z)!=="svelte-1ws351k"&&(Z.innerHTML=wt),Ke=n(H),ee=s(H,"P",{"data-svelte-h":!0}),l(ee)!=="svelte-tutl6h"&&(ee.textContent=xt),Re=n(H),te=s(H,"UL",{"data-svelte-h":!0}),l(te)!=="svelte-1wr1sb5"&&(te.innerHTML=yt),H.forEach(r),Me=n(e),c=s(e,"DIV",{class:!0});var m=q(c);b(U.$$.fragment,m),Je=n(m),oe=s(m,"P",{"data-svelte-h":!0}),l(oe)!=="svelte-10mwufd"&&(oe.textContent=Tt),Qe=n(m),ne=s(m,"P",{"data-svelte-h":!0}),l(ne)!=="svelte-zfp2ya"&&(ne.textContent=qt),Xe=n(m),re=s(m,"UL",{"data-svelte-h":!0}),l(re)!=="svelte-14mziv8"&&(re.innerHTML=$t),Ye=n(m),ae=s(m,"P",{"data-svelte-h":!0}),l(ae)!=="svelte-axepee"&&(ae.textContent=Ct),Ze=n(m),se=s(m,"OL",{"data-svelte-h":!0}),l(se)!=="svelte-op5gf3"&&(se.innerHTML=kt),et=n(m),ie=s(m,"P",{"data-svelte-h":!0}),l(ie)!=="svelte-12asmlu"&&(ie.textContent=zt),tt=n(m),le=s(m,"UL",{"data-svelte-h":!0}),l(le)!=="svelte-6jlau3"&&(le.innerHTML=Ht),ot=n(m),de=s(m,"P",{"data-svelte-h":!0}),l(de)!=="svelte-ugu4qd"&&(de.innerHTML=Mt),nt=n(m),ce=s(m,"P",{"data-svelte-h":!0}),l(ce)!=="svelte-1jpjddx"&&(ce.innerHTML=Ft),m.forEach(r),Fe=n(e),f=s(e,"DIV",{class:!0});var M=q(f);b(A.$$.fragment,M),rt=n(M),me=s(M,"P",{"data-svelte-h":!0}),l(me)!=="svelte-1m05y0g"&&(me.innerHTML=Lt),at=n(M),ue=s(M,"P",{"data-svelte-h":!0}),l(ue)!=="svelte-12zo44d"&&(ue.textContent=Pt),st=n(M),pe=s(M,"P",{"data-svelte-h":!0}),l(pe)!=="svelte-1bxqqp"&&(pe.innerHTML=Dt),M.forEach(r),Le=n(e),g=s(e,"DIV",{class:!0});var _e=q(g);b(V.$$.fragment,_e),it=n(_e),fe=s(_e,"P",{"data-svelte-h":!0}),l(fe)!=="svelte-lpto01"&&(fe.innerHTML=It),lt=n(_e),he=s(_e,"P",{"data-svelte-h":!0}),l(he)!=="svelte-12zo44d"&&(he.textContent=Nt),_e.forEach(r),Pe=n(e),b(j.$$.fragment,e),De=n(e),ve=s(e,"P",{}),q(ve).forEach(r),this.h()},h(){$(C,"name","hf:doc:metadata"),$(C,"content",Gt),$(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),$(g,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,i){t(document.head,C),d(e,we,i),d(e,be,i),d(e,xe,i),v(L,e,i),d(e,ye,i),d(e,P,i),d(e,Te,i),d(e,D,i),d(e,qe,i),v(I,e,i),d(e,$e,i),d(e,k,i),v(N,k,null),t(k,Ee),t(k,W),d(e,Ce,i),d(e,z,i),v(B,z,null),t(z,Se),t(z,G),d(e,ke,i),d(e,u,i),v(E,u,null),t(u,Oe),t(u,K),t(u,Ue),t(u,R),t(u,Ae),t(u,J),t(u,Ve),t(u,Q),d(e,ze,i),d(e,h,i),v(S,h,null),t(h,je),t(h,X),t(h,We),t(h,Y),d(e,He,i),d(e,p,i),v(O,p,null),t(p,Ge),t(p,Z),t(p,Ke),t(p,ee),t(p,Re),t(p,te),d(e,Me,i),d(e,c,i),v(U,c,null),t(c,Je),t(c,oe),t(c,Qe),t(c,ne),t(c,Xe),t(c,re),t(c,Ye),t(c,ae),t(c,Ze),t(c,se),t(c,et),t(c,ie),t(c,tt),t(c,le),t(c,ot),t(c,de),t(c,nt),t(c,ce),d(e,Fe,i),d(e,f,i),v(A,f,null),t(f,rt),t(f,me),t(f,at),t(f,ue),t(f,st),t(f,pe),d(e,Le,i),d(e,g,i),v(V,g,null),t(g,it),t(g,fe),t(g,lt),t(g,he),d(e,Pe,i),v(j,e,i),d(e,De,i),d(e,ve,i),Ie=!0},p:St,i(e){Ie||(w(L.$$.fragment,e),w(I.$$.fragment,e),w(N.$$.fragment,e),w(B.$$.fragment,e),w(E.$$.fragment,e),w(S.$$.fragment,e),w(O.$$.fragment,e),w(U.$$.fragment,e),w(A.$$.fragment,e),w(V.$$.fragment,e),w(j.$$.fragment,e),Ie=!0)},o(e){x(L.$$.fragment,e),x(I.$$.fragment,e),x(N.$$.fragment,e),x(B.$$.fragment,e),x(E.$$.fragment,e),x(S.$$.fragment,e),x(O.$$.fragment,e),x(U.$$.fragment,e),x(A.$$.fragment,e),x(V.$$.fragment,e),x(j.$$.fragment,e),Ie=!1},d(e){e&&(r(we),r(be),r(xe),r(ye),r(P),r(Te),r(D),r(qe),r($e),r(k),r(Ce),r(z),r(ke),r(u),r(ze),r(h),r(He),r(p),r(Me),r(c),r(Fe),r(f),r(Le),r(g),r(Pe),r(De),r(ve)),r(C),y(L,e),y(I,e),y(N),y(B),y(E),y(S),y(O),y(U),y(A),y(V),y(j,e)}}}const Gt='{"title":"Utilities for FeatureExtractors","local":"utilities-for-featureextractors","sections":[{"title":"Audio Transformations","local":"transformers.audio_utils.hertz_to_mel","sections":[],"depth":2}],"depth":1}';function Kt(dt){return Ot(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Yt extends Ut{constructor(C){super(),At(this,C,Kt,Wt,Et,{})}}export{Yt as component};
