Module: Google::Cloud

Defined in:
lib/google-cloud-speech.rb,
lib/google/cloud/speech.rb,
lib/google/cloud/speech/audio.rb,
lib/google/cloud/speech/result.rb,
lib/google/cloud/speech/stream.rb,
lib/google/cloud/speech/project.rb,
lib/google/cloud/speech/service.rb,
lib/google/cloud/speech/version.rb,
lib/google/cloud/speech/operation.rb,
lib/google/cloud/speech/credentials.rb,
lib/google/cloud/speech/v1/speech_client.rb,
lib/google/cloud/speech/v1/cloud_speech_pb.rb,
lib/google/cloud/speech/v1/cloud_speech_services_pb.rb,
lib/google/cloud/speech/v1/doc/google/cloud/speech/v1/cloud_speech.rb

Defined Under Namespace

Modules: Speech

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.speech(project = nil, keyfile = nil, scope: nil, timeout: nil, client_config: nil) ⇒ Google::Cloud::Speech::Project

Creates a new object for connecting to the Speech service. Each call creates a new connection.

For more information on connecting to Google Cloud see the Authentication Guide.

Examples:

require "google/cloud"

speech = Google::Cloud.speech

audio = speech.audio "path/to/audio.raw",
                     encoding: :linear16,
                     language: "en-US",
                     sample_rate: 16000

Parameters:

  • project (String) (defaults to: nil)

    Project identifier for the Speech service you are connecting to.

  • keyfile (String, Hash) (defaults to: nil)

    Keyfile downloaded from Google Cloud. If file path the file must be readable.

  • scope (String, Array<String>)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/speech
  • timeout (Integer)

    Default timeout to use in requests. Optional.

  • client_config (Hash)

    A hash of values to override the default behavior of the API client. Optional.

Returns:



106
107
108
109
110
111
112
# File 'lib/google-cloud-speech.rb', line 106

def self.speech project = nil, keyfile = nil, scope: nil, timeout: nil,
                client_config: nil
  require "google/cloud/speech"
  Google::Cloud::Speech.new project: project, keyfile: keyfile,
                            scope: scope, timeout: timeout,
                            client_config: client_config
end

Instance Method Details

#speech(scope: nil, timeout: nil, client_config: nil) ⇒ Google::Cloud::Speech::Project

Creates a new object for connecting to the Speech service. Each call creates a new connection.

For more information on connecting to Google Cloud see the Authentication Guide.

Examples:

require "google/cloud"

gcloud = Google::Cloud.new
speech = gcloud.speech

audio = speech.audio "path/to/audio.raw",
                     encoding: :linear16,
                     language: "en-US",
                     sample_rate: 16000

The default scope can be overridden with the scope option:

require "google/cloud"

gcloud  = Google::Cloud.new
platform_scope = "https://www.googleapis.com/auth/cloud-platform"
speech = gcloud.speech scope: platform_scope

Parameters:

  • scope (String, Array<String>)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/speech
  • timeout (Integer)

    Default timeout to use in requests. Optional.

  • client_config (Hash)

    A hash of values to override the default behavior of the API client. Optional.

Returns:



65
66
67
68
69
# File 'lib/google-cloud-speech.rb', line 65

def speech scope: nil, timeout: nil, client_config: nil
  Google::Cloud.speech @project, @keyfile, scope: scope,
                                           timeout: (timeout || @timeout),
                                           client_config: client_config
end