Class: Google::Cloud::Speech::V2::Speech::Rest::Client
- Inherits:
-
Object
- Object
- Google::Cloud::Speech::V2::Speech::Rest::Client
- Includes:
- Paths
- Defined in:
- lib/google/cloud/speech/v2/speech/rest/client.rb
Overview
REST client for the Speech service.
Enables speech transcription and resource management.
Defined Under Namespace
Classes: Configuration
Instance Attribute Summary collapse
-
#location_client ⇒ Google::Cloud::Location::Locations::Rest::Client
readonly
Get the associated client for mix-in of the Locations.
-
#operations_client ⇒ ::Google::Cloud::Speech::V2::Speech::Rest::Operations
readonly
Get the associated client for long-running operations.
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Client::Configuration
Configure the Speech Client class.
Instance Method Summary collapse
-
#batch_recognize(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Performs batch asynchronous speech recognition: send a request with N audio files and receive a long running operation that can be polled to see when the transcriptions are finished.
-
#configure {|config| ... } ⇒ Client::Configuration
Configure the Speech Client instance.
-
#create_custom_class(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Creates a CustomClass.
-
#create_phrase_set(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Creates a PhraseSet.
-
#create_recognizer(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Creates a Recognizer.
-
#delete_custom_class(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Deletes the CustomClass.
-
#delete_phrase_set(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Deletes the PhraseSet.
-
#delete_recognizer(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Deletes the Recognizer.
-
#get_config(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Speech::V2::Config
Returns the requested Config.
-
#get_custom_class(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Speech::V2::CustomClass
Returns the requested CustomClass.
-
#get_phrase_set(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Speech::V2::PhraseSet
Returns the requested PhraseSet.
-
#get_recognizer(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Speech::V2::Recognizer
Returns the requested Recognizer.
-
#initialize {|config| ... } ⇒ Client
constructor
Create a new Speech REST client object.
-
#list_custom_classes(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass>
Lists CustomClasses.
-
#list_phrase_sets(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet>
Lists PhraseSets.
-
#list_recognizers(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer>
Lists Recognizers.
-
#recognize(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Speech::V2::RecognizeResponse
Performs synchronous Speech recognition: receive results after all audio has been sent and processed.
-
#undelete_custom_class(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Undeletes the CustomClass.
-
#undelete_phrase_set(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Undeletes the PhraseSet.
-
#undelete_recognizer(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Undeletes the Recognizer.
-
#update_config(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Speech::V2::Config
Updates the Config.
-
#update_custom_class(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Updates the CustomClass.
-
#update_phrase_set(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Updates the PhraseSet.
-
#update_recognizer(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Operation
Updates the Recognizer.
Methods included from Paths
#config_path, #crypto_key_path, #crypto_key_version_path, #custom_class_path, #location_path, #phrase_set_path, #recognizer_path
Constructor Details
#initialize {|config| ... } ⇒ Client
Create a new Speech REST client object.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 117 def initialize # Create the configuration object @config = Configuration.new Client.configure # Yield the configuration if needed yield @config if block_given? # Create credentials credentials = @config.credentials # Use self-signed JWT if the endpoint is unchanged from default, # but only if the default endpoint does not have a region prefix. enable_self_signed_jwt = @config.endpoint == Configuration::DEFAULT_ENDPOINT && !@config.endpoint.split(".").first.include?("-") credentials ||= Credentials.default scope: @config.scope, enable_self_signed_jwt: enable_self_signed_jwt if credentials.is_a?(::String) || credentials.is_a?(::Hash) credentials = Credentials.new credentials, scope: @config.scope end @quota_project_id = @config.quota_project @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id @operations_client = ::Google::Cloud::Speech::V2::Speech::Rest::Operations.new do |config| config.credentials = credentials config.quota_project = @quota_project_id config.endpoint = @config.endpoint end @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config| config.credentials = credentials config.quota_project = @quota_project_id config.endpoint = @config.endpoint config.bindings_override = @config.bindings_override end @speech_stub = ::Google::Cloud::Speech::V2::Speech::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials end |
Instance Attribute Details
#location_client ⇒ Google::Cloud::Location::Locations::Rest::Client (readonly)
Get the associated client for mix-in of the Locations.
167 168 169 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 167 def location_client @location_client end |
#operations_client ⇒ ::Google::Cloud::Speech::V2::Speech::Rest::Operations (readonly)
Get the associated client for long-running operations.
160 161 162 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 160 def operations_client @operations_client end |
Class Method Details
.configure {|config| ... } ⇒ Client::Configuration
Configure the Speech Client class.
See Configuration for a description of the configuration fields.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 59 def self.configure @configure ||= begin namespace = ["Google", "Cloud", "Speech", "V2"] parent_config = while namespace.any? parent_name = namespace.join "::" parent_const = const_get parent_name break parent_const.configure if parent_const.respond_to? :configure namespace.pop end default_config = Client::Configuration.new parent_config default_config.timeout = 5000.0 default_config.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14] } default_config end yield @configure if block_given? @configure end |
Instance Method Details
#batch_recognize(request, options = nil) ⇒ ::Gapic::Operation #batch_recognize(recognizer: nil, config: nil, config_mask: nil, files: nil, recognition_output_config: nil, processing_strategy: nil) ⇒ ::Gapic::Operation
Performs batch asynchronous speech recognition: send a request with N audio files and receive a long running operation that can be polled to see when the transcriptions are finished.
935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 935 def batch_recognize request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::BatchRecognizeRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.batch_recognize..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.batch_recognize.timeout, metadata: , retry_policy: @config.rpcs.batch_recognize.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.batch_recognize request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#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 configure.
See Configuration for a description of the configuration fields.
96 97 98 99 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 96 def configure yield @config if block_given? @config end |
#create_custom_class(request, options = nil) ⇒ ::Gapic::Operation #create_custom_class(custom_class: nil, validate_only: nil, custom_class_id: nil, parent: nil) ⇒ ::Gapic::Operation
Creates a CustomClass.
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1196 def create_custom_class request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreateCustomClassRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.create_custom_class..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.create_custom_class.timeout, metadata: , retry_policy: @config.rpcs.create_custom_class.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.create_custom_class request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#create_phrase_set(request, options = nil) ⇒ ::Gapic::Operation #create_phrase_set(phrase_set: nil, validate_only: nil, phrase_set_id: nil, parent: nil) ⇒ ::Gapic::Operation
Creates a PhraseSet.
1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1762 def create_phrase_set request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreatePhraseSetRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.create_phrase_set..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.create_phrase_set.timeout, metadata: , retry_policy: @config.rpcs.create_phrase_set.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.create_phrase_set request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#create_recognizer(request, options = nil) ⇒ ::Gapic::Operation #create_recognizer(recognizer: nil, validate_only: nil, recognizer_id: nil, parent: nil) ⇒ ::Gapic::Operation
Creates a Recognizer.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 233 def create_recognizer request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreateRecognizerRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.create_recognizer..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.create_recognizer.timeout, metadata: , retry_policy: @config.rpcs.create_recognizer.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.create_recognizer request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#delete_custom_class(request, options = nil) ⇒ ::Gapic::Operation #delete_custom_class(name: nil, validate_only: nil, allow_missing: nil, etag: nil) ⇒ ::Gapic::Operation
Deletes the CustomClass.
1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1569 def delete_custom_class request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeleteCustomClassRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.delete_custom_class..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.delete_custom_class.timeout, metadata: , retry_policy: @config.rpcs.delete_custom_class.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.delete_custom_class request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#delete_phrase_set(request, options = nil) ⇒ ::Gapic::Operation #delete_phrase_set(name: nil, validate_only: nil, allow_missing: nil, etag: nil) ⇒ ::Gapic::Operation
Deletes the PhraseSet.
2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 2132 def delete_phrase_set request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeletePhraseSetRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.delete_phrase_set..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.delete_phrase_set.timeout, metadata: , retry_policy: @config.rpcs.delete_phrase_set.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.delete_phrase_set request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#delete_recognizer(request, options = nil) ⇒ ::Gapic::Operation #delete_recognizer(name: nil, validate_only: nil, allow_missing: nil, etag: nil) ⇒ ::Gapic::Operation
Deletes the Recognizer.
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 605 def delete_recognizer request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeleteRecognizerRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.delete_recognizer..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.delete_recognizer.timeout, metadata: , retry_policy: @config.rpcs.delete_recognizer.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.delete_recognizer request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#get_config(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::Config #get_config(name: nil) ⇒ ::Google::Cloud::Speech::V2::Config
Returns the requested Config.
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1016 def get_config request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetConfigRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_config..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.get_config.timeout, metadata: , retry_policy: @config.rpcs.get_config.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.get_config request, do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#get_custom_class(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::CustomClass #get_custom_class(name: nil) ⇒ ::Google::Cloud::Speech::V2::CustomClass
Returns the requested CustomClass.
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1376 def get_custom_class request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetCustomClassRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_custom_class..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.get_custom_class.timeout, metadata: , retry_policy: @config.rpcs.get_custom_class.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.get_custom_class request, do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#get_phrase_set(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::PhraseSet #get_phrase_set(name: nil) ⇒ ::Google::Cloud::Speech::V2::PhraseSet
Returns the requested PhraseSet.
1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1941 def get_phrase_set request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetPhraseSetRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_phrase_set..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.get_phrase_set.timeout, metadata: , retry_policy: @config.rpcs.get_phrase_set.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.get_phrase_set request, do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#get_recognizer(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::Recognizer #get_recognizer(name: nil) ⇒ ::Google::Cloud::Speech::V2::Recognizer
Returns the requested Recognizer. Fails with [NOT_FOUND][google.rpc.Code.NOT_FOUND] if the requested Recognizer doesn't exist.
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 414 def get_recognizer request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetRecognizerRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_recognizer..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.get_recognizer.timeout, metadata: , retry_policy: @config.rpcs.get_recognizer.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.get_recognizer request, do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#list_custom_classes(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass> #list_custom_classes(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass>
Lists CustomClasses.
1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1295 def list_custom_classes request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListCustomClassesRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.list_custom_classes..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.list_custom_classes.timeout, metadata: , retry_policy: @config.rpcs.list_custom_classes.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.list_custom_classes request, do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_custom_classes, "custom_classes", request, result, yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#list_phrase_sets(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet> #list_phrase_sets(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet>
Lists PhraseSets.
1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1860 def list_phrase_sets request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListPhraseSetsRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.list_phrase_sets..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.list_phrase_sets.timeout, metadata: , retry_policy: @config.rpcs.list_phrase_sets.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.list_phrase_sets request, do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_phrase_sets, "phrase_sets", request, result, yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#list_recognizers(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer> #list_recognizers(parent: nil, page_size: nil, page_token: nil, show_deleted: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer>
Lists Recognizers.
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 331 def list_recognizers request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListRecognizersRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.list_recognizers..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.list_recognizers.timeout, metadata: , retry_policy: @config.rpcs.list_recognizers.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.list_recognizers request, do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_recognizers, "recognizers", request, result, yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#recognize(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::RecognizeResponse #recognize(recognizer: nil, config: nil, config_mask: nil, content: nil, uri: nil) ⇒ ::Google::Cloud::Speech::V2::RecognizeResponse
Performs synchronous Speech recognition: receive results after all audio has been sent and processed.
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 817 def recognize request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::RecognizeRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.recognize..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.recognize.timeout, metadata: , retry_policy: @config.rpcs.recognize.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.recognize request, do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#undelete_custom_class(request, options = nil) ⇒ ::Gapic::Operation #undelete_custom_class(name: nil, validate_only: nil, etag: nil) ⇒ ::Gapic::Operation
Undeletes the CustomClass.
1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1664 def undelete_custom_class request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeleteCustomClassRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.undelete_custom_class..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.undelete_custom_class.timeout, metadata: , retry_policy: @config.rpcs.undelete_custom_class.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.undelete_custom_class request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#undelete_phrase_set(request, options = nil) ⇒ ::Gapic::Operation #undelete_phrase_set(name: nil, validate_only: nil, etag: nil) ⇒ ::Gapic::Operation
Undeletes the PhraseSet.
2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 2226 def undelete_phrase_set request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeletePhraseSetRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.undelete_phrase_set..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.undelete_phrase_set.timeout, metadata: , retry_policy: @config.rpcs.undelete_phrase_set.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.undelete_phrase_set request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#undelete_recognizer(request, options = nil) ⇒ ::Gapic::Operation #undelete_recognizer(name: nil, validate_only: nil, etag: nil) ⇒ ::Gapic::Operation
Undeletes the Recognizer.
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 699 def undelete_recognizer request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeleteRecognizerRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.undelete_recognizer..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.undelete_recognizer.timeout, metadata: , retry_policy: @config.rpcs.undelete_recognizer.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.undelete_recognizer request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#update_config(request, options = nil) ⇒ ::Google::Cloud::Speech::V2::Config #update_config(config: nil, update_mask: nil) ⇒ ::Google::Cloud::Speech::V2::Config
Updates the Config.
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1099 def update_config request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateConfigRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.update_config..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.update_config.timeout, metadata: , retry_policy: @config.rpcs.update_config.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.update_config request, do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#update_custom_class(request, options = nil) ⇒ ::Gapic::Operation #update_custom_class(custom_class: nil, update_mask: nil, validate_only: nil) ⇒ ::Gapic::Operation
Updates the CustomClass.
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 1471 def update_custom_class request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateCustomClassRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.update_custom_class..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.update_custom_class.timeout, metadata: , retry_policy: @config.rpcs.update_custom_class.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.update_custom_class request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#update_phrase_set(request, options = nil) ⇒ ::Gapic::Operation #update_phrase_set(phrase_set: nil, update_mask: nil, validate_only: nil) ⇒ ::Gapic::Operation
Updates the PhraseSet.
2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 2035 def update_phrase_set request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdatePhraseSetRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.update_phrase_set..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.update_phrase_set.timeout, metadata: , retry_policy: @config.rpcs.update_phrase_set.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.update_phrase_set request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#update_recognizer(request, options = nil) ⇒ ::Gapic::Operation #update_recognizer(recognizer: nil, update_mask: nil, validate_only: nil) ⇒ ::Gapic::Operation
Updates the Recognizer.
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'lib/google/cloud/speech/v2/speech/rest/client.rb', line 508 def update_recognizer request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateRecognizerRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.update_recognizer..to_h # Set x-goog-api-client and x-goog-user-project headers [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Cloud::Speech::V2::VERSION, transports_version_send: [:rest] [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.update_recognizer.timeout, metadata: , retry_policy: @config.rpcs.update_recognizer.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @speech_stub.update_recognizer request, do |result, operation| result = ::Gapic::Operation.new result, @operations_client, options: yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |