Enum google_cognitive_apis::api::grpc::google::cloud::speechtotext::v1p1beta1::recognition_config::AudioEncoding
source · [−]#[repr(i32)]
pub enum AudioEncoding {
EncodingUnspecified,
Linear16,
Flac,
Mulaw,
Amr,
AmrWb,
OggOpus,
SpeexWithHeaderByte,
Mp3,
}
Expand description
The encoding of the audio data sent in the request.
All encodings support only 1 channel (mono) audio, unless the
audio_channel_count
and enable_separate_recognition_per_channel
fields
are set.
For best results, the audio source should be captured and transmitted using
a lossless encoding (FLAC
or LINEAR16
). The accuracy of the speech
recognition can be reduced if lossy codecs are used to capture or transmit
audio, particularly if background noise is present. Lossy codecs include
MULAW
, AMR
, AMR_WB
, OGG_OPUS
, SPEEX_WITH_HEADER_BYTE
, MP3
.
The FLAC
and WAV
audio file formats include a header that describes the
included audio content. You can request recognition for WAV
files that
contain either LINEAR16
or MULAW
encoded audio.
If you send FLAC
or WAV
audio file format in
your request, you do not need to specify an AudioEncoding
; the audio
encoding format is determined from the file header. If you specify
an AudioEncoding
when you send send FLAC
or WAV
audio, the
encoding configuration must match the encoding described in the audio
header; otherwise the request returns an
[google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT] error code.
Variants
EncodingUnspecified
Not specified.
Linear16
Uncompressed 16-bit signed little-endian samples (Linear PCM).
Flac
FLAC
(Free Lossless Audio
Codec) is the recommended encoding because it is
lossless–therefore recognition is not compromised–and
requires only about half the bandwidth of LINEAR16
. FLAC
stream
encoding supports 16-bit and 24-bit samples, however, not all fields in
STREAMINFO
are supported.
Mulaw
8-bit samples that compand 14-bit audio samples using G.711 PCMU/mu-law.
Amr
Adaptive Multi-Rate Narrowband codec. sample_rate_hertz
must be 8000.
AmrWb
Adaptive Multi-Rate Wideband codec. sample_rate_hertz
must be 16000.
OggOpus
Opus encoded audio frames in Ogg container
([OggOpus](https://wiki.xiph.org/OggOpus)).
sample_rate_hertz
must be one of 8000, 12000, 16000, 24000, or 48000.
SpeexWithHeaderByte
Although the use of lossy encodings is not recommended, if a very low
bitrate encoding is required, OGG_OPUS
is highly preferred over
Speex encoding. The [Speex](https://speex.org/) encoding supported by
Cloud Speech API has a header byte in each block, as in MIME type
audio/x-speex-with-header-byte
.
It is a variant of the RTP Speex encoding defined in
RFC 5574.
The stream is a sequence of blocks, one block per RTP packet. Each block
starts with a byte containing the length of the block, in bytes, followed
by one or more frames of Speex data, padded to an integral number of
bytes (octets) as specified in RFC 5574. In other words, each RTP header
is replaced with a single byte containing the block length. Only Speex
wideband is supported. sample_rate_hertz
must be 16000.
Mp3
MP3 audio. MP3 encoding is a Beta feature and only available in
v1p1beta1. Support all standard MP3 bitrates (which range from 32-320
kbps). When using this encoding, sample_rate_hertz
has to match the
sample rate of the file being used.
Implementations
sourceimpl AudioEncoding
impl AudioEncoding
sourceimpl AudioEncoding
impl AudioEncoding
sourcepub fn as_str_name(&self) -> &'static str
pub fn as_str_name(&self) -> &'static str
String value of the enum field names used in the ProtoBuf definition.
The values are not transformed in any way and thus are considered stable (if the ProtoBuf definition does not change) and safe for programmatic use.
Trait Implementations
sourceimpl Clone for AudioEncoding
impl Clone for AudioEncoding
sourcefn clone(&self) -> AudioEncoding
fn clone(&self) -> AudioEncoding
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for AudioEncoding
impl Debug for AudioEncoding
sourceimpl Default for AudioEncoding
impl Default for AudioEncoding
sourcefn default() -> AudioEncoding
fn default() -> AudioEncoding
Returns the “default value” for a type. Read more
sourceimpl From<AudioEncoding> for i32
impl From<AudioEncoding> for i32
sourcefn from(value: AudioEncoding) -> i32
fn from(value: AudioEncoding) -> i32
Converts to this type from the input type.
sourceimpl Hash for AudioEncoding
impl Hash for AudioEncoding
sourceimpl Ord for AudioEncoding
impl Ord for AudioEncoding
sourcefn cmp(&self, other: &AudioEncoding) -> Ordering
fn cmp(&self, other: &AudioEncoding) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<AudioEncoding> for AudioEncoding
impl PartialEq<AudioEncoding> for AudioEncoding
sourcefn eq(&self, other: &AudioEncoding) -> bool
fn eq(&self, other: &AudioEncoding) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl PartialOrd<AudioEncoding> for AudioEncoding
impl PartialOrd<AudioEncoding> for AudioEncoding
sourcefn partial_cmp(&self, other: &AudioEncoding) -> Option<Ordering>
fn partial_cmp(&self, other: &AudioEncoding) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for AudioEncoding
impl Eq for AudioEncoding
impl StructuralEq for AudioEncoding
impl StructuralPartialEq for AudioEncoding
Auto Trait Implementations
impl RefUnwindSafe for AudioEncoding
impl Send for AudioEncoding
impl Sync for AudioEncoding
impl Unpin for AudioEncoding
impl UnwindSafe for AudioEncoding
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T
in a tonic::Request