Module: Google::Cloud::Speech
- Defined in:
- lib/google/cloud/speech.rb,
lib/google/cloud/speech/v1.rb,
lib/google/cloud/speech/audio.rb,
lib/google/cloud/speech/result.rb,
lib/google/cloud/speech/stream.rb,
lib/google/cloud/speech/convert.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/doc/overview.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
Overview
Ruby Client for Google Cloud Speech API (Alpha)
Google Cloud Speech API: Google Cloud Speech API.
Quick Start
In order to use this library, you first need to go through the following steps:
- Select or create a Cloud Platform project.
- Enable billing for your project.
- Enable the Google Cloud Speech API.
- Setup Authentication.
Installation
$ gem install google-cloud-speech
Preview
SpeechClient
require "google/cloud/speech"
speech_client = Google::Cloud::Speech.new
language_code = "en-US"
sample_rate_hertz = 44100
encoding = :FLAC
config = {
language_code: language_code,
sample_rate_hertz: sample_rate_hertz,
encoding: encoding
}
uri = "gs://gapic-toolkit/hello.flac"
audio = { uri: uri }
response = speech_client.recognize(config, audio)
Next Steps
- Read the Google Cloud Speech API Product documentation to learn more about the product and see How-to Guides.
- View this repository's main README to see the full list of Cloud APIs that we cover.
Defined Under Namespace
Modules: V1 Classes: Audio, Credentials, InterimResult, Operation, Project, Result, Stream
Constant Summary collapse
- VERSION =
"0.29.0".freeze
Class Method Summary collapse
-
.configure {|Google::Cloud.configure.speech| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud Speech library.
-
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil, project: nil, keyfile: nil) ⇒ Google::Cloud::Speech::Project
Creates a new object for connecting to the Speech service.
Class Method Details
.configure {|Google::Cloud.configure.speech| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud Speech library.
The following Speech configuration parameters are supported:
project_id
- (String) Identifier for a Speech project. (The parameterproject
is considered deprecated, but may also be used.)credentials
- (String, Hash, Google::Auth::Credentials) The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Credentials) (The parameterkeyfile
is considered deprecated, but may also be used.)scope
- (String, Array) The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. timeout
- (Integer) Default timeout to use in requests.client_config
- (Hash) A hash of values to override the default behavior of the API client.
270 271 272 273 274 |
# File 'lib/google/cloud/speech.rb', line 270 def self.configure yield Google::Cloud.configure.speech if block_given? Google::Cloud.configure.speech end |
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil, project: nil, keyfile: 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.
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/google/cloud/speech.rb', line 228 def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil, project: nil, keyfile: nil project_id ||= (project || default_project_id) project_id = project_id.to_s # Always cast to a string raise ArgumentError, "project_id is missing" if project_id.empty? scope ||= configure.scope timeout ||= configure.timeout client_config ||= configure.client_config credentials ||= (keyfile || default_credentials(scope: scope)) unless credentials.is_a? Google::Auth::Credentials credentials = Speech::Credentials.new credentials, scope: scope end Speech::Project.new( Speech::Service.new( project_id, credentials, timeout: timeout, client_config: client_config ) ) end |