Reference documentation and code samples for the Cloud Speech-to-Text V1p1beta1 API class Google::Cloud::Speech::V1p1beta1::Speech::Rest::Client.
REST client for the Speech service.
Service that implements Google Cloud Speech API.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all Speech clients ::Google::Cloud::Speech::V1p1beta1::Speech::Rest::Client.configure do |config| config.timeout = 10.0 end
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the Speech Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#initialize
def initialize() { |config| ... } -> Client
Create a new Speech REST client object.
- (config) — Configure the Speech client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::Speech::V1p1beta1::Speech::Rest::Client.new # Create a client using a custom configuration client = ::Google::Cloud::Speech::V1p1beta1::Speech::Rest::Client.new do |config| config.timeout = 10.0 end
#long_running_recognize
def long_running_recognize(request, options = nil) -> ::Gapic::Operation
def long_running_recognize(config: nil, audio: nil, output_config: nil) -> ::Gapic::Operation
Performs asynchronous speech recognition: receive results via the
google.longrunning.Operations interface. Returns either an
Operation.error
or an Operation.response
which contains
a LongRunningRecognizeResponse
message.
For more information on asynchronous speech recognition, see the
how-to.
def long_running_recognize(request, options = nil) -> ::Gapic::Operation
long_running_recognize
via a request object, either of type
LongRunningRecognizeRequest or an equivalent Hash.
- request (::Google::Cloud::Speech::V1p1beta1::LongRunningRecognizeRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def long_running_recognize(config: nil, audio: nil, output_config: nil) -> ::Gapic::Operation
long_running_recognize
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- config (::Google::Cloud::Speech::V1p1beta1::RecognitionConfig, ::Hash) — Required. Provides information to the recognizer that specifies how to process the request.
- audio (::Google::Cloud::Speech::V1p1beta1::RecognitionAudio, ::Hash) — Required. The audio data to be recognized.
- output_config (::Google::Cloud::Speech::V1p1beta1::TranscriptOutputConfig, ::Hash) — Optional. Specifies an optional destination for the recognition results.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Gapic::Operation)
- operation (::Gapic::Rest::TransportOperation)
- (::Gapic::Operation)
- (::Google::Cloud::Error) — if the REST call is aborted.
Basic example
require "google/cloud/speech/v1p1beta1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Speech::V1p1beta1::Speech::Rest::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Speech::V1p1beta1::LongRunningRecognizeRequest.new # Call the long_running_recognize method. result = client.long_running_recognize request # The returned object is of type Gapic::Operation. You can use it to # check the status of an operation, cancel it, or wait for results. # Here is how to wait for a response. result.wait_until_done! timeout: 60 if result.response? p result.response else puts "No response received." end
#operations_client
def operations_client() -> ::Google::Cloud::Speech::V1p1beta1::Speech::Rest::Operations
Get the associated client for long-running operations.
#recognize
def recognize(request, options = nil) -> ::Google::Cloud::Speech::V1p1beta1::RecognizeResponse
def recognize(config: nil, audio: nil) -> ::Google::Cloud::Speech::V1p1beta1::RecognizeResponse
Performs synchronous speech recognition: receive results after all audio has been sent and processed.
def recognize(request, options = nil) -> ::Google::Cloud::Speech::V1p1beta1::RecognizeResponse
recognize
via a request object, either of type
RecognizeRequest or an equivalent Hash.
- request (::Google::Cloud::Speech::V1p1beta1::RecognizeRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def recognize(config: nil, audio: nil) -> ::Google::Cloud::Speech::V1p1beta1::RecognizeResponse
recognize
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- config (::Google::Cloud::Speech::V1p1beta1::RecognitionConfig, ::Hash) — Required. Provides information to the recognizer that specifies how to process the request.
- audio (::Google::Cloud::Speech::V1p1beta1::RecognitionAudio, ::Hash) — Required. The audio data to be recognized.
- (result, operation) — Access the result along with the TransportOperation object
- result (::Google::Cloud::Speech::V1p1beta1::RecognizeResponse)
- operation (::Gapic::Rest::TransportOperation)
- (::Google::Cloud::Error) — if the REST call is aborted.
Basic example
require "google/cloud/speech/v1p1beta1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Speech::V1p1beta1::Speech::Rest::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Speech::V1p1beta1::RecognizeRequest.new # Call the recognize method. result = client.recognize request # The returned object is of type Google::Cloud::Speech::V1p1beta1::RecognizeResponse. p result