Google Cloud Speech v1 API - Class RecognitionAudio (3.7.0)

public sealed class RecognitionAudio : IMessage<RecognitionAudio>, IEquatable<RecognitionAudio>, IDeepCloneable<RecognitionAudio>, IBufferMessage, IMessage

Reference documentation and code samples for the Google Cloud Speech v1 API class RecognitionAudio.

Contains audio data in the encoding specified in the RecognitionConfig. Either content or uri must be supplied. Supplying both or neither returns [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]. See content limits.

Inheritance

object > RecognitionAudio

Namespace

Google.Cloud.Speech.V1

Assembly

Google.Cloud.Speech.V1.dll

Constructors

RecognitionAudio()

public RecognitionAudio()

RecognitionAudio(RecognitionAudio)

public RecognitionAudio(RecognitionAudio other)
Parameter
Name Description
other RecognitionAudio

Properties

AudioSourceCase

public RecognitionAudio.AudioSourceOneofCase AudioSourceCase { get; }
Property Value
Type Description
RecognitionAudioAudioSourceOneofCase

Content

public ByteString Content { get; set; }

The audio data bytes encoded as specified in RecognitionConfig. Note: as with all bytes fields, proto buffers use a pure binary representation, whereas JSON representations use base64.

Property Value
Type Description
ByteString

HasContent

public bool HasContent { get; }

Gets whether the "content" field is set

Property Value
Type Description
bool

HasUri

public bool HasUri { get; }

Gets whether the "uri" field is set

Property Value
Type Description
bool

Uri

public string Uri { get; set; }

URI that points to a file that contains audio data bytes as specified in RecognitionConfig. The file must not be compressed (for example, gzip). Currently, only Google Cloud Storage URIs are supported, which must be specified in the following format: gs://bucket_name/object_name (other URI formats return [google.rpc.Code.INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more information, see Request URIs.

Property Value
Type Description
string

Methods

FetchFromUri(string, HttpClient)

public static RecognitionAudio FetchFromUri(string uri, HttpClient httpClient = null)

Constructs a RecognitionAudio by downloading data from the given URI.

Parameters
Name Description
uri string

The URI to fetch. Must not be null.

httpClient HttpClient

The HttpClient to use to fetch the image, or null to use a default client.

Returns
Type Description
RecognitionAudio

The newly created RecognitionAudio.

FetchFromUri(Uri, HttpClient)

public static RecognitionAudio FetchFromUri(Uri uri, HttpClient httpClient = null)

Constructs a RecognitionAudio by downloading data from the given URI.

Parameters
Name Description
uri Uri

The URI to fetch. Must not be null.

httpClient HttpClient

The HttpClient to use to fetch the image, or null to use a default client.

Returns
Type Description
RecognitionAudio

The newly created RecognitionAudio.

FetchFromUriAsync(string, HttpClient)

public static Task<RecognitionAudio> FetchFromUriAsync(string uri, HttpClient httpClient = null)

Asynchronously constructs a RecognitionAudio by downloading data from the given URI.

Parameters
Name Description
uri string

The URI to fetch. Must not be null.

httpClient HttpClient

The HttpClient to use to fetch the image, or null to use a default client.

Returns
Type Description
TaskRecognitionAudio

A task representing the asynchronous operation. The result will be the newly created RecognitionAudio.

FetchFromUriAsync(Uri, HttpClient)

public static Task<RecognitionAudio> FetchFromUriAsync(Uri uri, HttpClient httpClient = null)

Asynchronously constructs a RecognitionAudio by downloading data from the given URI.

Parameters
Name Description
uri Uri

The URI to fetch. Must not be null.

httpClient HttpClient

The HttpClient to use to fetch the image, or null to use a default client.

Returns
Type Description
TaskRecognitionAudio

A task representing the asynchronous operation. The result will be the newly created RecognitionAudio.

FromBytes(byte[])

public static RecognitionAudio FromBytes(byte[] bytes)

Constructs a RecognitionAudio from the given byte array.

Parameter
Name Description
bytes System.Byte

The bytes representing the raw RecognitionAudio data.

Returns
Type Description
RecognitionAudio

The newly created RecognitionAudio.

Remarks

This method copies the data from the byte array; modifications to bytes after this method returns will not be reflected in the RecognitionAudio.

FromBytes(byte[], int, int)

public static RecognitionAudio FromBytes(byte[] bytes, int offset, int count)

Constructs a RecognitionAudio from a section of the given byte array.

Parameters
Name Description
bytes System.Byte

The bytes representing the raw RecognitionAudio data.

offset int

The offset into the byte array of the start of the data to include in the RecognitionAudio.

count int

The number of bytes to include in the RecognitionAudio.

Returns
Type Description
RecognitionAudio

The newly created RecognitionAudio.

Remarks

This method copies the data from the byte array; modifications to bytes after this method returns will not be reflected in the RecognitionAudio.

FromFile(string)

public static RecognitionAudio FromFile(string path)

Constructs a RecognitionAudio by loading data from the given file path.

Parameter
Name Description
path string

The file path to load RecognitionAudio data from. Must not be null.

Returns
Type Description
RecognitionAudio

The newly created RecognitionAudio.

FromFileAsync(string)

public static Task<RecognitionAudio> FromFileAsync(string path)

Asynchronously constructs a RecognitionAudio by loading data from the given file path.

Parameter
Name Description
path string

The file path to load RecognitionAudio data from. Must not be null.

Returns
Type Description
TaskRecognitionAudio

The newly created RecognitionAudio.

FromStorageUri(string)

public static RecognitionAudio FromStorageUri(string storageUri)

Constructs a RecognitionAudio with a Uri property referring to a Google Cloud Storage URI.

Parameter
Name Description
storageUri string

A Google Cloud Storage URI, of the form gs://bucket-name/object-name. Must not be null.

Returns
Type Description
RecognitionAudio

The newly created RecognitionAudio.

FromStream(Stream)

public static RecognitionAudio FromStream(Stream stream)

Constructs a RecognitionAudio by loading data from the given stream.

Parameter
Name Description
stream Stream

The stream to load RecognitionAudio data from. Must not be null.

Returns
Type Description
RecognitionAudio

The newly created RecognitionAudio.

FromStreamAsync(Stream)

public static Task<RecognitionAudio> FromStreamAsync(Stream stream)

Asynchronously constructs a RecognitionAudio by loading data from the given stream.

Parameter
Name Description
stream Stream

The stream to load RecognitionAudio data from. Must not be null.

Returns
Type Description
TaskRecognitionAudio

The newly created RecognitionAudio.