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.
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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe latest version of the \u003ccode\u003eRecognitionAudio\u003c/code\u003e class in the Google Cloud Speech v1 API is 3.8.0, with several previous versions available, ranging down to 2.2.0.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eRecognitionAudio\u003c/code\u003e is used to contain audio data for speech recognition, as specified in the \u003ccode\u003eRecognitionConfig\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAudio data can be provided either through the \u003ccode\u003econtent\u003c/code\u003e property (byte data) or the \u003ccode\u003euri\u003c/code\u003e property (a link to the audio file), but not both simultaneously.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRecognitionAudio\u003c/code\u003e class can be constructed from a variety of sources, including byte arrays, file paths, URIs, and streams, with synchronous and asynchronous methods available for most of them.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eRecognitionAudio\u003c/code\u003e implements multiple interfaces, such as \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, supporting various operations like deep cloning and message handling.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Speech v1 API - Class RecognitionAudio (3.8.0)\n\nVersion latestkeyboard_arrow_down\n\n- [3.8.0 (latest)](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/3.7.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/3.6.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/3.5.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [3.4.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/3.4.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [3.3.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/3.3.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [3.2.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/3.2.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [3.1.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/3.1.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [3.0.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/3.0.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [2.9.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/2.9.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [2.8.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/2.8.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [2.7.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/2.7.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [2.6.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/2.6.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/2.5.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/2.4.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/2.3.0/Google.Cloud.Speech.V1.RecognitionAudio)\n- [2.2.0](/dotnet/docs/reference/Google.Cloud.Speech.V1/2.2.0/Google.Cloud.Speech.V1.RecognitionAudio) \n\n public sealed class RecognitionAudio : IMessage\u003cRecognitionAudio\u003e, IEquatable\u003cRecognitionAudio\u003e, IDeepCloneable\u003cRecognitionAudio\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Google Cloud Speech v1 API class RecognitionAudio.\n\nContains audio data in the encoding specified in the `RecognitionConfig`.\nEither `content` or `uri` must be supplied. Supplying both or neither\nreturns \\[google.rpc.Code.INVALID_ARGUMENT\\]\\[google.rpc.Code.INVALID_ARGUMENT\\].\nSee [content limits](https://cloud.google.com/speech-to-text/quotas#content). \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e RecognitionAudio \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Speech.V1](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Speech.V1.dll\n\nConstructors\n------------\n\n### RecognitionAudio()\n\n public RecognitionAudio()\n\n### RecognitionAudio(RecognitionAudio)\n\n public RecognitionAudio(RecognitionAudio other)\n\nProperties\n----------\n\n### AudioSourceCase\n\n public RecognitionAudio.AudioSourceOneofCase AudioSourceCase { get; }\n\n### Content\n\n public ByteString Content { get; set; }\n\nThe audio data bytes encoded as specified in\n`RecognitionConfig`. Note: as with all bytes fields, proto buffers use a\npure binary representation, whereas JSON representations use base64.\n\n### HasContent\n\n public bool HasContent { get; }\n\nGets whether the \"content\" field is set\n\n### HasUri\n\n public bool HasUri { get; }\n\nGets whether the \"uri\" field is set\n\n### Uri\n\n public string Uri { get; set; }\n\nURI that points to a file that contains audio data bytes as specified in\n`RecognitionConfig`. The file must not be compressed (for example, gzip).\nCurrently, only Google Cloud Storage URIs are\nsupported, which must be specified in the following format:\n`gs://bucket_name/object_name` (other URI formats return\n\\[google.rpc.Code.INVALID_ARGUMENT\\]\\[google.rpc.Code.INVALID_ARGUMENT\\]).\nFor more information, see [Request\nURIs](https://cloud.google.com/storage/docs/reference-uris).\n\nMethods\n-------\n\n### FetchFromUri(string, HttpClient)\n\n public static RecognitionAudio FetchFromUri(string uri, HttpClient httpClient = null)\n\nConstructs a [RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio) by downloading data from the given URI.\n\n### FetchFromUri(Uri, HttpClient)\n\n public static RecognitionAudio FetchFromUri(Uri uri, HttpClient httpClient = null)\n\nConstructs a [RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio) by downloading data from the given URI.\n\n### FetchFromUriAsync(string, HttpClient)\n\n public static Task\u003cRecognitionAudio\u003e FetchFromUriAsync(string uri, HttpClient httpClient = null)\n\nAsynchronously constructs a [RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio) by downloading data from the given URI.\n\n### FetchFromUriAsync(Uri, HttpClient)\n\n public static Task\u003cRecognitionAudio\u003e FetchFromUriAsync(Uri uri, HttpClient httpClient = null)\n\nAsynchronously constructs a [RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio) by downloading data from the given URI.\n\n### FromBytes(byte\\[\\])\n\n public static RecognitionAudio FromBytes(byte[] bytes)\n\nConstructs a [RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio) from the given byte array.\n\n**Remarks** \nThis method copies the data from the byte array; modifications to `bytes`\nafter this method returns will not be reflected in the RecognitionAudio.\n\n### FromBytes(byte\\[\\], int, int)\n\n public static RecognitionAudio FromBytes(byte[] bytes, int offset, int count)\n\nConstructs a [RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio) from a section of the given byte array.\n\n**Remarks** \nThis method copies the data from the byte array; modifications to `bytes`\nafter this method returns will not be reflected in the RecognitionAudio.\n\n### FromFile(string)\n\n public static RecognitionAudio FromFile(string path)\n\nConstructs a [RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio) by loading data from the given file path.\n\n### FromFileAsync(string)\n\n public static Task\u003cRecognitionAudio\u003e FromFileAsync(string path)\n\nAsynchronously constructs a [RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio) by loading data from the given file path.\n\n### FromStorageUri(string)\n\n public static RecognitionAudio FromStorageUri(string storageUri)\n\nConstructs a [RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio) with a [Uri](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio#Google_Cloud_Speech_V1_RecognitionAudio_Uri) property referring to a Google Cloud\nStorage URI.\n\n### FromStream(Stream)\n\n public static RecognitionAudio FromStream(Stream stream)\n\nConstructs a [RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio) by loading data from the given stream.\n\n### FromStreamAsync(Stream)\n\n public static Task\u003cRecognitionAudio\u003e FromStreamAsync(Stream stream)\n\nAsynchronously constructs a [RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1/latest/Google.Cloud.Speech.V1.RecognitionAudio) by loading data from the given stream."]]