public void AsyncRecognize_RequestObject()
        {
            // Snippet: AsyncRecognize(AsyncRecognizeRequest,CallSettings)
            // Create client
            SpeechClient speechClient = SpeechClient.Create();
            // Initialize request argument(s)
            AsyncRecognizeRequest request = new AsyncRecognizeRequest
            {
                Config = new RecognitionConfig(),
                Audio  = new RecognitionAudio(),
            };
            // Make the request
            Operation <AsyncRecognizeResponse> response =
                speechClient.AsyncRecognize(request);

            // Poll until the returned long-running operation is complete
            Operation <AsyncRecognizeResponse> completedResponse =
                response.PollUntilCompleted();
            // Retrieve the operation result
            AsyncRecognizeResponse result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <AsyncRecognizeResponse> retrievedResponse =
                speechClient.PollOnceAsyncRecognize(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                AsyncRecognizeResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Пример #2
0
 /// <summary>
 /// Perform asynchronous speech-recognition: receive results via the
 /// google.longrunning.Operations interface. Returns either an
 /// `Operation.error` or an `Operation.response` which contains
 /// an `AsyncRecognizeResponse` message.
 /// </summary>
 /// <param name="request">
 /// The request object containing all of the parameters for the API call.
 /// </param>
 /// <param name="callSettings">
 /// If not null, applies overrides to this RPC call.
 /// </param>
 /// <returns>
 /// The RPC response.
 /// </returns>
 public override Operation <AsyncRecognizeResponse> AsyncRecognize(
     AsyncRecognizeRequest request,
     CallSettings callSettings = null)
 {
     Modify_AsyncRecognizeRequest(ref request, ref callSettings);
     return(new Operation <AsyncRecognizeResponse>(
                _callAsyncRecognize.Sync(request, callSettings), LongRunningOperationsClient));
 }
Пример #3
0
        /// <summary>
        /// Perform asynchronous speech-recognition: receive results via the
        /// google.longrunning.Operations interface. Returns either an
        /// `Operation.error` or an `Operation.response` which contains
        /// an `AsyncRecognizeResponse` message.
        /// </summary>
        /// <param name="config">
        /// [Required] The `config` message provides information to the recognizer
        /// that specifies how to process the request.
        /// </param>
        /// <param name="audio">
        /// [Required] The audio data to be recognized.
        /// </param>
        /// <param name="callSettings">
        /// If not null, applies overrides to this RPC call.
        /// </param>
        /// <returns>
        /// The RPC response.
        /// </returns>
        public override Operation AsyncRecognize(
            RecognitionConfig config,
            RecognitionAudio audio,
            CallSettings callSettings = null)
        {
            AsyncRecognizeRequest request = new AsyncRecognizeRequest
            {
                Config = config,
                Audio  = audio,
            };

            Modify_AsyncRecognizeRequest(ref request, ref callSettings);
            return(_callAsyncRecognize.Sync(request, callSettings));
        }
Пример #4
0
        public async Task AsyncRecognizeAsync_RequestObject()
        {
            // Snippet: AsyncRecognizeAsync(AsyncRecognizeRequest,CallSettings)
            // Create client
            SpeechClient speechClient = await SpeechClient.CreateAsync();

            // Initialize request argument(s)
            AsyncRecognizeRequest request = new AsyncRecognizeRequest
            {
                Config = new RecognitionConfig
                {
                    Encoding   = RecognitionConfig.Types.AudioEncoding.Flac,
                    SampleRate = 44100,
                },
                Audio = new RecognitionAudio
                {
                    Uri = "gs://bucket_name/file_name.flac",
                },
            };
            // Make the request
            Operation <AsyncRecognizeResponse> response =
                await speechClient.AsyncRecognizeAsync(request);

            // Poll until the returned long-running operation is complete
            Operation <AsyncRecognizeResponse> completedResponse =
                await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            AsyncRecognizeResponse result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <AsyncRecognizeResponse> retrievedResponse =
                await speechClient.PollOnceAsyncRecognizeAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                AsyncRecognizeResponse retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
Пример #5
0
        /// <summary>
        /// Performs asynchronous speech recognition: receive results via the[google.longrunning.Operations](/speech/reference/rest/v1beta1/operations#Operation)interface. Returns either an`Operation.error` or an `Operation.response` which containsan `AsyncRecognizeResponse` message.
        /// Documentation https://developers.google.com/speech/v1beta1/reference/speech/asyncrecognize
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Speech service.</param>
        /// <param name="body">A valid Speech v1beta1 body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Asyncrecognize(SpeechService service, AsyncRecognizeRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }

                // Make the request.
                return(service.Speech.Asyncrecognize(body).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Speech.Asyncrecognize failed.", ex);
            }
        }
Пример #6
0
 partial void Modify_AsyncRecognizeRequest(ref AsyncRecognizeRequest request, ref CallSettings settings);
Пример #7
0
 /// <summary>
 /// Perform asynchronous speech-recognition: receive results via the
 /// google.longrunning.Operations interface. Returns either an
 /// `Operation.error` or an `Operation.response` which contains
 /// an `AsyncRecognizeResponse` message.
 /// </summary>
 /// <param name="request">
 /// The request object containing all of the parameters for the API call.
 /// </param>
 /// <param name="callSettings">
 /// If not null, applies overrides to this RPC call.
 /// </param>
 /// <returns>
 /// The RPC response.
 /// </returns>
 public virtual Operation <AsyncRecognizeResponse> AsyncRecognize(
     AsyncRecognizeRequest request,
     CallSettings callSettings = null)
 {
     throw new NotImplementedException();
 }