public sealed class RecognitionAudio : IMessage<RecognitionAudio>, IEquatable<RecognitionAudio>, IDeepCloneable<RecognitionAudio>, IBufferMessage, IMessage
Reference documentation and code samples for the Google Cloud Speech v1p1beta1 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 \u003ccode\u003eRecognitionAudio\u003c/code\u003e class represents audio data used in the Google Cloud Speech v1p1beta1 API, requiring either \u003ccode\u003econtent\u003c/code\u003e or \u003ccode\u003euri\u003c/code\u003e to be specified, but not both.\u003c/p\u003e\n"],["\u003cp\u003eIt offers various methods for constructing a \u003ccode\u003eRecognitionAudio\u003c/code\u003e object, including \u003ccode\u003eFetchFromUri\u003c/code\u003e, \u003ccode\u003eFromBytes\u003c/code\u003e, \u003ccode\u003eFromFile\u003c/code\u003e, \u003ccode\u003eFromStorageUri\u003c/code\u003e, and \u003ccode\u003eFromStream\u003c/code\u003e, as well as their asynchronous counterparts.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eRecognitionAudio\u003c/code\u003e implements interfaces like \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, and inherits members from the base \u003ccode\u003eobject\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eYou can access properties such as \u003ccode\u003eContent\u003c/code\u003e, which holds the raw audio data, \u003ccode\u003eUri\u003c/code\u003e that contains a storage location, \u003ccode\u003eAudioSourceCase\u003c/code\u003e to know which one is being used, and the boolean values \u003ccode\u003eHasContent\u003c/code\u003e or \u003ccode\u003eHasUri\u003c/code\u003e to check if they are set.\u003c/p\u003e\n"],["\u003cp\u003eThe file \u003ccode\u003eRecognitionAudio\u003c/code\u003e uses is from the \u003ccode\u003eGoogle.Cloud.Speech.V1P1Beta1\u003c/code\u003e namespace, and it is contained in the \u003ccode\u003eGoogle.Cloud.Speech.V1P1Beta1.dll\u003c/code\u003e assembly.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Speech v1p1beta1 API - Class RecognitionAudio (3.0.0-beta09)\n\nVersion latestkeyboard_arrow_down\n\n- [3.0.0-beta09 (latest)](/dotnet/docs/reference/Google.Cloud.Speech.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.RecognitionAudio)\n- [3.0.0-beta08](/dotnet/docs/reference/Google.Cloud.Speech.V1P1Beta1/3.0.0-beta08/Google.Cloud.Speech.V1P1Beta1.RecognitionAudio)\n- [2.0.0-beta09](/dotnet/docs/reference/Google.Cloud.Speech.V1P1Beta1/2.0.0-beta09/Google.Cloud.Speech.V1P1Beta1.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 v1p1beta1 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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.RecognitionAudio), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.RecognitionAudio), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[RecognitionAudio](/dotnet/docs/reference/Google.Cloud.Speech.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.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.V1P1Beta1](/dotnet/docs/reference/Google.Cloud.Speech.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1)\n\nAssembly\n--------\n\nGoogle.Cloud.Speech.V1P1Beta1.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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.RecognitionAudio) with a [Uri](/dotnet/docs/reference/Google.Cloud.Speech.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.RecognitionAudio#Google_Cloud_Speech_V1P1Beta1_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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.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.V1P1Beta1/latest/Google.Cloud.Speech.V1P1Beta1.RecognitionAudio) by loading data from the given stream."]]