google-cloud-speech 0.22.0 → 0.22.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/google/cloud/speech/credentials.rb +1 -1
- data/lib/google/cloud/speech/job.rb +8 -22
- data/lib/google/cloud/speech/project.rb +1 -1
- data/lib/google/cloud/speech/service.rb +6 -6
- data/lib/google/cloud/speech/v1beta1.rb +1 -5
- data/lib/google/cloud/speech/v1beta1/doc/google/cloud/speech/v1beta1/cloud_speech.rb +3 -3
- data/lib/google/cloud/speech/v1beta1/doc/google/protobuf/any.rb +104 -0
- data/lib/google/cloud/speech/v1beta1/doc/google/rpc/status.rb +83 -0
- data/lib/google/cloud/speech/v1beta1/{speech_api.rb → speech_client.rb} +94 -26
- data/lib/google/cloud/speech/v1beta1/speech_client_config.json +6 -6
- data/lib/google/cloud/speech/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2abdbcc3991e8cf808b4980e10f2a0b45404b195
|
4
|
+
data.tar.gz: f980fa98af93e927c5282b8e6ad3935a5f85a8d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7df4960e5303c8a9a46740e30900830512c995602d9603e3da7fe8f3f9adeeb31f943489df59303ddb83af4333aaf0391dc6eb442738cd4b4bbfa5474b282a06
|
7
|
+
data.tar.gz: bbe6f4e877db3c19a33e2211d929a02980231f4fb6c2c5b47730332020e585501fe3cb537d0fb099e1c93dc2beef00e60e5f0a9dc7e0ae0dcd439d10b0b2ca2d
|
@@ -22,7 +22,7 @@ module Google
|
|
22
22
|
##
|
23
23
|
# @private Represents the OAuth 2.0 signing logic for Speech.
|
24
24
|
class Credentials < Google::Cloud::Credentials
|
25
|
-
SCOPE = V1beta1::
|
25
|
+
SCOPE = V1beta1::SpeechClient::ALL_SCOPES
|
26
26
|
PATH_ENV_VARS = %w(SPEECH_KEYFILE GOOGLE_CLOUD_KEYFILE GCLOUD_KEYFILE)
|
27
27
|
JSON_ENV_VARS = %w(SPEECH_KEYFILE_JSON GOOGLE_CLOUD_KEYFILE_JSON
|
28
28
|
GCLOUD_KEYFILE_JSON)
|
@@ -47,18 +47,13 @@ module Google
|
|
47
47
|
#
|
48
48
|
class Job
|
49
49
|
##
|
50
|
-
# @private The Google::
|
50
|
+
# @private The Google::Gax::Operation gRPC object.
|
51
51
|
attr_accessor :grpc
|
52
52
|
|
53
53
|
##
|
54
|
-
# @private
|
55
|
-
attr_accessor :service
|
56
|
-
|
57
|
-
##
|
58
|
-
# @private Creates a new Annotation instance.
|
54
|
+
# @private Creates a new Job instance.
|
59
55
|
def initialize
|
60
56
|
@grpc = nil
|
61
|
-
@service = nil
|
62
57
|
end
|
63
58
|
|
64
59
|
##
|
@@ -79,10 +74,8 @@ module Google
|
|
79
74
|
# results = job.results
|
80
75
|
#
|
81
76
|
def results
|
82
|
-
return nil unless
|
83
|
-
|
84
|
-
resp = V1beta1::AsyncRecognizeResponse.decode(@grpc.response.value)
|
85
|
-
resp.results.map do |result_grpc|
|
77
|
+
return nil unless @grpc.response?
|
78
|
+
@grpc.response.results.map do |result_grpc|
|
86
79
|
Result.from_grpc result_grpc
|
87
80
|
end
|
88
81
|
# TODO: Ensure we are raising the proper error
|
@@ -107,7 +100,7 @@ module Google
|
|
107
100
|
# job.done? #=> false
|
108
101
|
#
|
109
102
|
def done?
|
110
|
-
@grpc.done
|
103
|
+
@grpc.done?
|
111
104
|
end
|
112
105
|
|
113
106
|
##
|
@@ -127,7 +120,7 @@ module Google
|
|
127
120
|
# job.done? #=> true
|
128
121
|
#
|
129
122
|
def reload!
|
130
|
-
@grpc
|
123
|
+
@grpc.reload!
|
131
124
|
self
|
132
125
|
end
|
133
126
|
alias_method :refresh!, :reload!
|
@@ -149,22 +142,15 @@ module Google
|
|
149
142
|
# job.done? #=> true
|
150
143
|
#
|
151
144
|
def wait_until_done!
|
152
|
-
|
153
|
-
retries = 0
|
154
|
-
until done?
|
155
|
-
backoff.call retries
|
156
|
-
retries += 1
|
157
|
-
reload!
|
158
|
-
end
|
145
|
+
@grpc.wait_until_done!
|
159
146
|
end
|
160
147
|
|
161
148
|
##
|
162
149
|
# @private New Result::Job from a Google::Longrunning::Operation
|
163
150
|
# object.
|
164
|
-
def self.from_grpc grpc
|
151
|
+
def self.from_grpc grpc
|
165
152
|
new.tap do |job|
|
166
153
|
job.instance_variable_set :@grpc, grpc
|
167
|
-
job.instance_variable_set :@service, service
|
168
154
|
end
|
169
155
|
end
|
170
156
|
end
|
@@ -33,7 +33,7 @@ module Google
|
|
33
33
|
client_config: nil
|
34
34
|
@project = project
|
35
35
|
@credentials = credentials
|
36
|
-
@host = host || V1beta1::
|
36
|
+
@host = host || V1beta1::SpeechClient::SERVICE_ADDRESS
|
37
37
|
@timeout = timeout
|
38
38
|
@client_config = client_config || {}
|
39
39
|
end
|
@@ -53,13 +53,13 @@ module Google
|
|
53
53
|
def service
|
54
54
|
return mocked_service if mocked_service
|
55
55
|
@service ||= \
|
56
|
-
V1beta1::
|
56
|
+
V1beta1::SpeechClient.new(
|
57
57
|
service_path: host,
|
58
58
|
channel: channel,
|
59
59
|
timeout: timeout,
|
60
60
|
client_config: client_config,
|
61
|
-
|
62
|
-
|
61
|
+
lib_name: "gccl",
|
62
|
+
lib_version: Google::Cloud::Speech::VERSION)
|
63
63
|
end
|
64
64
|
attr_accessor :mocked_service
|
65
65
|
|
@@ -71,8 +71,8 @@ module Google
|
|
71
71
|
channel: channel,
|
72
72
|
timeout: timeout,
|
73
73
|
client_config: client_config,
|
74
|
-
|
75
|
-
|
74
|
+
lib_name: "gccl",
|
75
|
+
lib_version: Google::Cloud::Speech::VERSION)
|
76
76
|
end
|
77
77
|
attr_accessor :mocked_ops
|
78
78
|
|
@@ -12,8 +12,4 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
require "google/cloud/speech/v1beta1/
|
16
|
-
require "google/longrunning/operations_client"
|
17
|
-
# Load the protobufs so code can see these classes
|
18
|
-
require "google/cloud/speech/v1beta1/cloud_speech_pb"
|
19
|
-
require "google/longrunning/operations_pb"
|
15
|
+
require "google/cloud/speech/v1beta1/speech_client"
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
5
5
|
# You may obtain a copy of the License at
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
8
|
#
|
9
9
|
# Unless required by applicable law or agreed to in writing, software
|
10
10
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -105,7 +105,7 @@ module Google
|
|
105
105
|
# [Optional] The language of the supplied audio as a BCP-47 language tag.
|
106
106
|
# Example: "en-GB" https://www.rfc-editor.org/rfc/bcp/bcp47.txt
|
107
107
|
# If omitted, defaults to "en-US". See
|
108
|
-
# {Language Support}[https://cloud.google.com/speech/docs/
|
108
|
+
# {Language Support}[https://cloud.google.com/speech/docs/best-practices#language_support]
|
109
109
|
# for a list of the currently supported language codes.
|
110
110
|
# @!attribute [rw] max_alternatives
|
111
111
|
# @return [Integer]
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Protobuf
|
17
|
+
# +Any+ contains an arbitrary serialized protocol buffer message along with a
|
18
|
+
# URL that describes the type of the serialized message.
|
19
|
+
#
|
20
|
+
# Protobuf library provides support to pack/unpack Any values in the form
|
21
|
+
# of utility functions or additional generated methods of the Any type.
|
22
|
+
#
|
23
|
+
# Example 1: Pack and unpack a message in C++.
|
24
|
+
#
|
25
|
+
# Foo foo = ...;
|
26
|
+
# Any any;
|
27
|
+
# any.PackFrom(foo);
|
28
|
+
# ...
|
29
|
+
# if (any.UnpackTo(&foo)) {
|
30
|
+
# ...
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# Example 2: Pack and unpack a message in Java.
|
34
|
+
#
|
35
|
+
# Foo foo = ...;
|
36
|
+
# Any any = Any.pack(foo);
|
37
|
+
# ...
|
38
|
+
# if (any.is(Foo.class)) {
|
39
|
+
# foo = any.unpack(Foo.class);
|
40
|
+
# }
|
41
|
+
#
|
42
|
+
# The pack methods provided by protobuf library will by default use
|
43
|
+
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
44
|
+
# methods only use the fully qualified type name after the last '/'
|
45
|
+
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
46
|
+
# name "y.z".
|
47
|
+
#
|
48
|
+
#
|
49
|
+
# = JSON
|
50
|
+
#
|
51
|
+
# The JSON representation of an +Any+ value uses the regular
|
52
|
+
# representation of the deserialized, embedded message, with an
|
53
|
+
# additional field +@type+ which contains the type URL. Example:
|
54
|
+
#
|
55
|
+
# package google.profile;
|
56
|
+
# message Person {
|
57
|
+
# string first_name = 1;
|
58
|
+
# string last_name = 2;
|
59
|
+
# }
|
60
|
+
#
|
61
|
+
# {
|
62
|
+
# "@type": "type.googleapis.com/google.profile.Person",
|
63
|
+
# "firstName": <string>,
|
64
|
+
# "lastName": <string>
|
65
|
+
# }
|
66
|
+
#
|
67
|
+
# If the embedded message type is well-known and has a custom JSON
|
68
|
+
# representation, that representation will be embedded adding a field
|
69
|
+
# +value+ which holds the custom JSON in addition to the +@type+
|
70
|
+
# field. Example (for message Google::Protobuf::Duration):
|
71
|
+
#
|
72
|
+
# {
|
73
|
+
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
74
|
+
# "value": "1.212s"
|
75
|
+
# }
|
76
|
+
# @!attribute [rw] type_url
|
77
|
+
# @return [String]
|
78
|
+
# A URL/resource name whose content describes the type of the
|
79
|
+
# serialized protocol buffer message.
|
80
|
+
#
|
81
|
+
# For URLs which use the schema +http+, +https+, or no schema, the
|
82
|
+
# following restrictions and interpretations apply:
|
83
|
+
#
|
84
|
+
# * If no schema is provided, +https+ is assumed.
|
85
|
+
# * The last segment of the URL's path must represent the fully
|
86
|
+
# qualified name of the type (as in +path/google.protobuf.Duration+).
|
87
|
+
# The name should be in a canonical form (e.g., leading "." is
|
88
|
+
# not accepted).
|
89
|
+
# * An HTTP GET on the URL must yield a Google::Protobuf::Type
|
90
|
+
# value in binary format, or produce an error.
|
91
|
+
# * Applications are allowed to cache lookup results based on the
|
92
|
+
# URL, or have them precompiled into a binary to avoid any
|
93
|
+
# lookup. Therefore, binary compatibility needs to be preserved
|
94
|
+
# on changes to types. (Use versioned type names to manage
|
95
|
+
# breaking changes.)
|
96
|
+
#
|
97
|
+
# Schemas other than +http+, +https+ (or the empty schema) might be
|
98
|
+
# used with implementation specific semantics.
|
99
|
+
# @!attribute [rw] value
|
100
|
+
# @return [String]
|
101
|
+
# Must be a valid serialized protocol buffer of the above specified type.
|
102
|
+
class Any; end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Google
|
16
|
+
module Rpc
|
17
|
+
# The +Status+ type defines a logical error model that is suitable for different
|
18
|
+
# programming environments, including REST APIs and RPC APIs. It is used by
|
19
|
+
# {gRPC}[https://github.com/grpc]. The error model is designed to be:
|
20
|
+
#
|
21
|
+
# - Simple to use and understand for most users
|
22
|
+
# - Flexible enough to meet unexpected needs
|
23
|
+
#
|
24
|
+
# = Overview
|
25
|
+
#
|
26
|
+
# The +Status+ message contains three pieces of data: error code, error message,
|
27
|
+
# and error details. The error code should be an enum value of
|
28
|
+
# Google::Rpc::Code, but it may accept additional error codes if needed. The
|
29
|
+
# error message should be a developer-facing English message that helps
|
30
|
+
# developers *understand* and *resolve* the error. If a localized user-facing
|
31
|
+
# error message is needed, put the localized message in the error details or
|
32
|
+
# localize it in the client. The optional error details may contain arbitrary
|
33
|
+
# information about the error. There is a predefined set of error detail types
|
34
|
+
# in the package +google.rpc+ which can be used for common error conditions.
|
35
|
+
#
|
36
|
+
# = Language mapping
|
37
|
+
#
|
38
|
+
# The +Status+ message is the logical representation of the error model, but it
|
39
|
+
# is not necessarily the actual wire format. When the +Status+ message is
|
40
|
+
# exposed in different client libraries and different wire protocols, it can be
|
41
|
+
# mapped differently. For example, it will likely be mapped to some exceptions
|
42
|
+
# in Java, but more likely mapped to some error codes in C.
|
43
|
+
#
|
44
|
+
# = Other uses
|
45
|
+
#
|
46
|
+
# The error model and the +Status+ message can be used in a variety of
|
47
|
+
# environments, either with or without APIs, to provide a
|
48
|
+
# consistent developer experience across different environments.
|
49
|
+
#
|
50
|
+
# Example uses of this error model include:
|
51
|
+
#
|
52
|
+
# - Partial errors. If a service needs to return partial errors to the client,
|
53
|
+
# it may embed the +Status+ in the normal response to indicate the partial
|
54
|
+
# errors.
|
55
|
+
#
|
56
|
+
# - Workflow errors. A typical workflow has multiple steps. Each step may
|
57
|
+
# have a +Status+ message for error reporting purpose.
|
58
|
+
#
|
59
|
+
# - Batch operations. If a client uses batch request and batch response, the
|
60
|
+
# +Status+ message should be used directly inside batch response, one for
|
61
|
+
# each error sub-response.
|
62
|
+
#
|
63
|
+
# - Asynchronous operations. If an API call embeds asynchronous operation
|
64
|
+
# results in its response, the status of those operations should be
|
65
|
+
# represented directly using the +Status+ message.
|
66
|
+
#
|
67
|
+
# - Logging. If some API errors are stored in logs, the message +Status+ could
|
68
|
+
# be used directly after any stripping needed for security/privacy reasons.
|
69
|
+
# @!attribute [rw] code
|
70
|
+
# @return [Integer]
|
71
|
+
# The status code, which should be an enum value of Google::Rpc::Code.
|
72
|
+
# @!attribute [rw] message
|
73
|
+
# @return [String]
|
74
|
+
# A developer-facing error message, which should be in English. Any
|
75
|
+
# user-facing error message should be localized and sent in the
|
76
|
+
# Google::Rpc::Status#details field, or localized by the client.
|
77
|
+
# @!attribute [rw] details
|
78
|
+
# @return [Array<Google::Protobuf::Any>]
|
79
|
+
# A list of messages that carry the error details. There will be a
|
80
|
+
# common set of message types for APIs to use.
|
81
|
+
class Status; end
|
82
|
+
end
|
83
|
+
end
|
@@ -26,6 +26,9 @@ require "json"
|
|
26
26
|
require "pathname"
|
27
27
|
|
28
28
|
require "google/gax"
|
29
|
+
require "google/gax/operation"
|
30
|
+
require "google/longrunning/operations_client"
|
31
|
+
|
29
32
|
require "google/cloud/speech/v1beta1/cloud_speech_pb"
|
30
33
|
|
31
34
|
module Google
|
@@ -36,7 +39,7 @@ module Google
|
|
36
39
|
#
|
37
40
|
# @!attribute [r] speech_stub
|
38
41
|
# @return [Google::Cloud::Speech::V1beta1::Speech::Stub]
|
39
|
-
class
|
42
|
+
class SpeechClient
|
40
43
|
attr_reader :speech_stub
|
41
44
|
|
42
45
|
# The default address of the service.
|
@@ -45,8 +48,6 @@ module Google
|
|
45
48
|
# The default port of the service.
|
46
49
|
DEFAULT_SERVICE_PORT = 443
|
47
50
|
|
48
|
-
CODE_GEN_NAME_VERSION = "gapic/0.1.0".freeze
|
49
|
-
|
50
51
|
DEFAULT_TIMEOUT = 30
|
51
52
|
|
52
53
|
# The scopes needed to make gRPC calls to all of the methods defined in
|
@@ -70,10 +71,6 @@ module Google
|
|
70
71
|
# or the specified config is missing data points.
|
71
72
|
# @param timeout [Numeric]
|
72
73
|
# The default timeout, in seconds, for calls made through this client.
|
73
|
-
# @param app_name [String]
|
74
|
-
# The codename of the calling service.
|
75
|
-
# @param app_version [String]
|
76
|
-
# The version of the calling service.
|
77
74
|
def initialize \
|
78
75
|
service_path: SERVICE_ADDRESS,
|
79
76
|
port: DEFAULT_SERVICE_PORT,
|
@@ -82,17 +79,40 @@ module Google
|
|
82
79
|
scopes: ALL_SCOPES,
|
83
80
|
client_config: {},
|
84
81
|
timeout: DEFAULT_TIMEOUT,
|
85
|
-
app_name:
|
86
|
-
app_version:
|
82
|
+
app_name: nil,
|
83
|
+
app_version: nil,
|
84
|
+
lib_name: nil,
|
85
|
+
lib_version: ""
|
87
86
|
# These require statements are intentionally placed here to initialize
|
88
87
|
# the gRPC module only when it's required.
|
89
88
|
# See https://github.com/googleapis/toolkit/issues/446
|
90
89
|
require "google/gax/grpc"
|
91
90
|
require "google/cloud/speech/v1beta1/cloud_speech_services_pb"
|
92
91
|
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
@operations_client = Google::Longrunning::OperationsClient.new(
|
93
|
+
service_path: service_path,
|
94
|
+
port: port,
|
95
|
+
channel: channel,
|
96
|
+
chan_creds: chan_creds,
|
97
|
+
scopes: scopes,
|
98
|
+
client_config: client_config,
|
99
|
+
timeout: timeout,
|
100
|
+
app_name: app_name,
|
101
|
+
app_version: app_version,
|
102
|
+
lib_name: lib_name,
|
103
|
+
lib_version: lib_version,
|
104
|
+
)
|
105
|
+
|
106
|
+
if app_name || app_version
|
107
|
+
warn "`app_name` and `app_version` are no longer being used in the request headers."
|
108
|
+
end
|
109
|
+
|
110
|
+
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
111
|
+
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
112
|
+
google_api_client << " gapic/ gax/#{Google::Gax::VERSION}"
|
113
|
+
google_api_client << " grpc/#{GRPC::VERSION}"
|
114
|
+
google_api_client.freeze
|
115
|
+
|
96
116
|
headers = { :"x-goog-api-client" => google_api_client }
|
97
117
|
client_config_file = Pathname.new(__dir__).join(
|
98
118
|
"speech_client_config.json"
|
@@ -147,16 +167,23 @@ module Google
|
|
147
167
|
# @return [Google::Cloud::Speech::V1beta1::SyncRecognizeResponse]
|
148
168
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
149
169
|
# @example
|
150
|
-
# require "google/cloud/speech/v1beta1/
|
170
|
+
# require "google/cloud/speech/v1beta1/speech_client"
|
151
171
|
#
|
172
|
+
# AudioEncoding = Google::Cloud::Speech::V1beta1::RecognitionConfig::AudioEncoding
|
152
173
|
# RecognitionAudio = Google::Cloud::Speech::V1beta1::RecognitionAudio
|
153
174
|
# RecognitionConfig = Google::Cloud::Speech::V1beta1::RecognitionConfig
|
154
|
-
#
|
175
|
+
# SpeechClient = Google::Cloud::Speech::V1beta1::SpeechClient
|
155
176
|
#
|
156
|
-
#
|
177
|
+
# speech_client = SpeechClient.new
|
178
|
+
# encoding = AudioEncoding::FLAC
|
179
|
+
# sample_rate = 44100
|
157
180
|
# config = RecognitionConfig.new
|
181
|
+
# config.encoding = encoding
|
182
|
+
# config.sample_rate = sample_rate
|
183
|
+
# uri = "gs://bucket_name/file_name.flac"
|
158
184
|
# audio = RecognitionAudio.new
|
159
|
-
#
|
185
|
+
# audio.uri = uri
|
186
|
+
# response = speech_client.sync_recognize(config, audio)
|
160
187
|
|
161
188
|
def sync_recognize \
|
162
189
|
config,
|
@@ -182,19 +209,52 @@ module Google
|
|
182
209
|
# @param options [Google::Gax::CallOptions]
|
183
210
|
# Overrides the default settings for this call, e.g, timeout,
|
184
211
|
# retries, etc.
|
185
|
-
# @return [Google::
|
212
|
+
# @return [Google::Gax::Operation]
|
186
213
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
187
214
|
# @example
|
188
|
-
# require "google/cloud/speech/v1beta1/
|
215
|
+
# require "google/cloud/speech/v1beta1/speech_client"
|
189
216
|
#
|
217
|
+
# AudioEncoding = Google::Cloud::Speech::V1beta1::RecognitionConfig::AudioEncoding
|
190
218
|
# RecognitionAudio = Google::Cloud::Speech::V1beta1::RecognitionAudio
|
191
219
|
# RecognitionConfig = Google::Cloud::Speech::V1beta1::RecognitionConfig
|
192
|
-
#
|
220
|
+
# SpeechClient = Google::Cloud::Speech::V1beta1::SpeechClient
|
193
221
|
#
|
194
|
-
#
|
222
|
+
# speech_client = SpeechClient.new
|
223
|
+
# encoding = AudioEncoding::FLAC
|
224
|
+
# sample_rate = 44100
|
195
225
|
# config = RecognitionConfig.new
|
226
|
+
# config.encoding = encoding
|
227
|
+
# config.sample_rate = sample_rate
|
228
|
+
# uri = "gs://bucket_name/file_name.flac"
|
196
229
|
# audio = RecognitionAudio.new
|
197
|
-
#
|
230
|
+
# audio.uri = uri
|
231
|
+
#
|
232
|
+
# # Register a callback during the method call.
|
233
|
+
# operation = speech_client.async_recognize(config, audio) do |op|
|
234
|
+
# raise op.results.message if op.error?
|
235
|
+
# op_results = op.results
|
236
|
+
# # Process the results.
|
237
|
+
#
|
238
|
+
# metadata = op.metadata
|
239
|
+
# # Process the metadata.
|
240
|
+
# end
|
241
|
+
#
|
242
|
+
# # Or use the return value to register a callback.
|
243
|
+
# operation.on_done do |op|
|
244
|
+
# raise op.results.message if op.error?
|
245
|
+
# op_results = op.results
|
246
|
+
# # Process the results.
|
247
|
+
#
|
248
|
+
# metadata = op.metadata
|
249
|
+
# # Process the metadata.
|
250
|
+
# end
|
251
|
+
#
|
252
|
+
# # Manually reload the operation.
|
253
|
+
# operation.reload!
|
254
|
+
#
|
255
|
+
# # Or block until the operation completes, triggering callbacks on
|
256
|
+
# # completion.
|
257
|
+
# operation.wait_until_done!
|
198
258
|
|
199
259
|
def async_recognize \
|
200
260
|
config,
|
@@ -204,7 +264,15 @@ module Google
|
|
204
264
|
config: config,
|
205
265
|
audio: audio
|
206
266
|
}.delete_if { |_, v| v.nil? })
|
207
|
-
|
267
|
+
operation = Google::Gax::Operation.new(
|
268
|
+
@async_recognize.call(req, options),
|
269
|
+
@operations_client,
|
270
|
+
Google::Cloud::Speech::V1beta1::AsyncRecognizeResponse,
|
271
|
+
Google::Cloud::Speech::V1beta1::AsyncRecognizeMetadata,
|
272
|
+
call_options: options
|
273
|
+
)
|
274
|
+
operation.on_done { |operation| yield(operation) } if block_given?
|
275
|
+
operation
|
208
276
|
end
|
209
277
|
|
210
278
|
# Perform bidirectional streaming speech-recognition: receive results while
|
@@ -226,15 +294,15 @@ module Google
|
|
226
294
|
# This method interface might change in the future.
|
227
295
|
#
|
228
296
|
# @example
|
229
|
-
# require "google/cloud/speech/v1beta1/
|
297
|
+
# require "google/cloud/speech/v1beta1/speech_client"
|
230
298
|
#
|
231
|
-
#
|
299
|
+
# SpeechClient = Google::Cloud::Speech::V1beta1::SpeechClient
|
232
300
|
# StreamingRecognizeRequest = Google::Cloud::Speech::V1beta1::StreamingRecognizeRequest
|
233
301
|
#
|
234
|
-
#
|
302
|
+
# speech_client = SpeechClient.new
|
235
303
|
# request = StreamingRecognizeRequest.new
|
236
304
|
# requests = [request]
|
237
|
-
#
|
305
|
+
# speech_client.streaming_recognize(requests).each do |element|
|
238
306
|
# # Process element.
|
239
307
|
# end
|
240
308
|
|
@@ -2,11 +2,11 @@
|
|
2
2
|
"interfaces": {
|
3
3
|
"google.cloud.speech.v1beta1.Speech": {
|
4
4
|
"retry_codes": {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
"idempotent": [
|
6
|
+
"DEADLINE_EXCEEDED",
|
7
|
+
"UNAVAILABLE"
|
8
|
+
],
|
9
|
+
"non_idempotent": []
|
10
10
|
},
|
11
11
|
"retry_params": {
|
12
12
|
"default": {
|
@@ -31,7 +31,7 @@
|
|
31
31
|
"retry_params_name": "default"
|
32
32
|
},
|
33
33
|
"StreamingRecognize": {
|
34
|
-
"timeout_millis":
|
34
|
+
"timeout_millis": 190000,
|
35
35
|
"retry_codes_name": "non_idempotent",
|
36
36
|
"retry_params_name": "default"
|
37
37
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-speech
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.22.
|
4
|
+
version: 0.22.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.8.
|
34
|
+
version: 0.8.1
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.8.
|
41
|
+
version: 0.8.1
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: minitest
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,7 +189,9 @@ files:
|
|
189
189
|
- lib/google/cloud/speech/v1beta1/cloud_speech_pb.rb
|
190
190
|
- lib/google/cloud/speech/v1beta1/cloud_speech_services_pb.rb
|
191
191
|
- lib/google/cloud/speech/v1beta1/doc/google/cloud/speech/v1beta1/cloud_speech.rb
|
192
|
-
- lib/google/cloud/speech/v1beta1/
|
192
|
+
- lib/google/cloud/speech/v1beta1/doc/google/protobuf/any.rb
|
193
|
+
- lib/google/cloud/speech/v1beta1/doc/google/rpc/status.rb
|
194
|
+
- lib/google/cloud/speech/v1beta1/speech_client.rb
|
193
195
|
- lib/google/cloud/speech/v1beta1/speech_client_config.json
|
194
196
|
- lib/google/cloud/speech/version.rb
|
195
197
|
homepage: http://googlecloudplatform.github.io/google-cloud-ruby/
|