Class: Google::Cloud::Speech::Service
- Inherits:
-
Object
- Object
- Google::Cloud::Speech::Service
- Defined in:
- lib/google/cloud/speech/service.rb
Overview
methods.
Instance Attribute Summary collapse
-
#client_config ⇒ Object
Returns the value of attribute client_config.
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#host ⇒ Object
Returns the value of attribute host.
-
#mocked_ops ⇒ Object
Returns the value of attribute mocked_ops.
-
#mocked_service ⇒ Object
Returns the value of attribute mocked_service.
-
#project ⇒ Object
Returns the value of attribute project.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #chan_creds ⇒ Object
- #channel ⇒ Object
- #get_op(name) ⇒ Object
-
#initialize(project, credentials, host: nil, timeout: nil, client_config: nil) ⇒ Service
constructor
Creates a new Service instance.
- #insecure? ⇒ Boolean
- #inspect ⇒ Object
- #ops ⇒ Object
- #recognize_async(audio, config) ⇒ Object
- #recognize_stream(request_enum) ⇒ Object
- #recognize_sync(audio, config) ⇒ Object
- #service ⇒ Object
Constructor Details
#initialize(project, credentials, host: nil, timeout: nil, client_config: nil) ⇒ Service
Creates a new Service instance.
32 33 34 35 36 37 38 39 |
# File 'lib/google/cloud/speech/service.rb', line 32 def initialize project, credentials, host: nil, timeout: nil, client_config: nil @project = project @credentials = credentials @host = host || V1beta1::SpeechApi::SERVICE_ADDRESS @timeout = timeout @client_config = client_config || {} end |
Instance Attribute Details
#client_config ⇒ Object
Returns the value of attribute client_config.
28 29 30 |
# File 'lib/google/cloud/speech/service.rb', line 28 def client_config @client_config end |
#credentials ⇒ Object
Returns the value of attribute credentials.
28 29 30 |
# File 'lib/google/cloud/speech/service.rb', line 28 def credentials @credentials end |
#host ⇒ Object
Returns the value of attribute host.
28 29 30 |
# File 'lib/google/cloud/speech/service.rb', line 28 def host @host end |
#mocked_ops ⇒ Object
Returns the value of attribute mocked_ops.
77 78 79 |
# File 'lib/google/cloud/speech/service.rb', line 77 def mocked_ops @mocked_ops end |
#mocked_service ⇒ Object
Returns the value of attribute mocked_service.
64 65 66 |
# File 'lib/google/cloud/speech/service.rb', line 64 def mocked_service @mocked_service end |
#project ⇒ Object
Returns the value of attribute project.
28 29 30 |
# File 'lib/google/cloud/speech/service.rb', line 28 def project @project end |
#timeout ⇒ Object
Returns the value of attribute timeout.
28 29 30 |
# File 'lib/google/cloud/speech/service.rb', line 28 def timeout @timeout end |
Instance Method Details
#chan_creds ⇒ Object
46 47 48 49 50 51 |
# File 'lib/google/cloud/speech/service.rb', line 46 def chan_creds return credentials if insecure? require "grpc" GRPC::Core::ChannelCredentials.new.compose \ GRPC::Core::CallCredentials.new credentials.client.updater_proc end |
#channel ⇒ Object
41 42 43 44 |
# File 'lib/google/cloud/speech/service.rb', line 41 def channel require "grpc" GRPC::Core::Channel.new host, nil, chan_creds end |
#get_op(name) ⇒ Object
99 100 101 |
# File 'lib/google/cloud/speech/service.rb', line 99 def get_op name execute { ops.get_operation name } end |
#insecure? ⇒ Boolean
79 80 81 |
# File 'lib/google/cloud/speech/service.rb', line 79 def insecure? credentials == :this_channel_is_insecure end |
#inspect ⇒ Object
103 104 105 |
# File 'lib/google/cloud/speech/service.rb', line 103 def inspect "#{self.class}(#{@project})" end |
#ops ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/google/cloud/speech/service.rb', line 66 def ops return mocked_ops if mocked_ops @ops ||= \ Google::Longrunning::OperationsApi.new( service_path: host, channel: channel, timeout: timeout, client_config: client_config, app_name: "gcloud-ruby", app_version: Google::Cloud::Speech::VERSION) end |
#recognize_async(audio, config) ⇒ Object
89 90 91 92 93 |
# File 'lib/google/cloud/speech/service.rb', line 89 def recognize_async audio, config execute do service.async_recognize config, audio, options: end end |
#recognize_stream(request_enum) ⇒ Object
95 96 97 |
# File 'lib/google/cloud/speech/service.rb', line 95 def recognize_stream request_enum service.speech_stub.streaming_recognize request_enum end |
#recognize_sync(audio, config) ⇒ Object
83 84 85 86 87 |
# File 'lib/google/cloud/speech/service.rb', line 83 def recognize_sync audio, config execute do service.sync_recognize config, audio, options: end end |
#service ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/google/cloud/speech/service.rb', line 53 def service return mocked_service if mocked_service @service ||= \ V1beta1::SpeechApi.new( service_path: host, channel: channel, timeout: timeout, client_config: client_config, app_name: "gcloud-ruby", app_version: Google::Cloud::Speech::VERSION) end |