google-cloud-speech 0.32.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +4 -1
- data/AUTHENTICATION.md +169 -0
- data/LICENSE.md +201 -0
- data/MIGRATING.md +367 -0
- data/README.md +97 -52
- data/lib/google/cloud/speech/version.rb +22 -0
- data/lib/google/cloud/speech.rb +88 -139
- data/lib/google-cloud-speech.rb +19 -0
- metadata +111 -49
- data/LICENSE +0 -201
- data/lib/google/cloud/speech/v1/cloud_speech_pb.rb +0 -129
- data/lib/google/cloud/speech/v1/cloud_speech_services_pb.rb +0 -56
- data/lib/google/cloud/speech/v1/credentials.rb +0 -41
- data/lib/google/cloud/speech/v1/doc/google/cloud/speech/v1/cloud_speech.rb +0 -482
- data/lib/google/cloud/speech/v1/doc/google/longrunning/operations.rb +0 -93
- data/lib/google/cloud/speech/v1/doc/google/protobuf/any.rb +0 -130
- data/lib/google/cloud/speech/v1/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/speech/v1/doc/google/rpc/status.rb +0 -84
- data/lib/google/cloud/speech/v1/helpers.rb +0 -136
- data/lib/google/cloud/speech/v1/speech_client.rb +0 -331
- data/lib/google/cloud/speech/v1/speech_client_config.json +0 -41
- data/lib/google/cloud/speech/v1/stream.rb +0 -614
- data/lib/google/cloud/speech/v1.rb +0 -157
- data/lib/google/cloud/speech/v1p1beta1/cloud_speech_pb.rb +0 -190
- data/lib/google/cloud/speech/v1p1beta1/cloud_speech_services_pb.rb +0 -56
- data/lib/google/cloud/speech/v1p1beta1/credentials.rb +0 -41
- data/lib/google/cloud/speech/v1p1beta1/doc/google/cloud/speech/v1p1beta1/cloud_speech.rb +0 -719
- data/lib/google/cloud/speech/v1p1beta1/doc/google/longrunning/operations.rb +0 -93
- data/lib/google/cloud/speech/v1p1beta1/doc/google/protobuf/any.rb +0 -130
- data/lib/google/cloud/speech/v1p1beta1/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/speech/v1p1beta1/doc/google/rpc/status.rb +0 -84
- data/lib/google/cloud/speech/v1p1beta1/helpers.rb +0 -136
- data/lib/google/cloud/speech/v1p1beta1/speech_client.rb +0 -331
- data/lib/google/cloud/speech/v1p1beta1/speech_client_config.json +0 -41
- data/lib/google/cloud/speech/v1p1beta1/stream.rb +0 -614
- data/lib/google/cloud/speech/v1p1beta1.rb +0 -157
@@ -1,93 +0,0 @@
|
|
1
|
-
# Copyright 2018 Google LLC
|
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
|
-
# https://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
|
-
|
16
|
-
module Google
|
17
|
-
module Longrunning
|
18
|
-
# This resource represents a long-running operation that is the result of a
|
19
|
-
# network API call.
|
20
|
-
# @!attribute [rw] name
|
21
|
-
# @return [String]
|
22
|
-
# The server-assigned name, which is only unique within the same service that
|
23
|
-
# originally returns it. If you use the default HTTP mapping, the
|
24
|
-
# `name` should have the format of `operations/some/unique/name`.
|
25
|
-
# @!attribute [rw] metadata
|
26
|
-
# @return [Google::Protobuf::Any]
|
27
|
-
# Service-specific metadata associated with the operation. It typically
|
28
|
-
# contains progress information and common metadata such as create time.
|
29
|
-
# Some services might not provide such metadata. Any method that returns a
|
30
|
-
# long-running operation should document the metadata type, if any.
|
31
|
-
# @!attribute [rw] done
|
32
|
-
# @return [true, false]
|
33
|
-
# If the value is `false`, it means the operation is still in progress.
|
34
|
-
# If true, the operation is completed, and either `error` or `response` is
|
35
|
-
# available.
|
36
|
-
# @!attribute [rw] error
|
37
|
-
# @return [Google::Rpc::Status]
|
38
|
-
# The error result of the operation in case of failure or cancellation.
|
39
|
-
# @!attribute [rw] response
|
40
|
-
# @return [Google::Protobuf::Any]
|
41
|
-
# The normal response of the operation in case of success. If the original
|
42
|
-
# method returns no data on success, such as `Delete`, the response is
|
43
|
-
# `google.protobuf.Empty`. If the original method is standard
|
44
|
-
# `Get`/`Create`/`Update`, the response should be the resource. For other
|
45
|
-
# methods, the response should have the type `XxxResponse`, where `Xxx`
|
46
|
-
# is the original method name. For example, if the original method name
|
47
|
-
# is `TakeSnapshot()`, the inferred response type is
|
48
|
-
# `TakeSnapshotResponse`.
|
49
|
-
class Operation; end
|
50
|
-
|
51
|
-
# The request message for {Google::Longrunning::Operations::GetOperation Operations::GetOperation}.
|
52
|
-
# @!attribute [rw] name
|
53
|
-
# @return [String]
|
54
|
-
# The name of the operation resource.
|
55
|
-
class GetOperationRequest; end
|
56
|
-
|
57
|
-
# The request message for {Google::Longrunning::Operations::ListOperations Operations::ListOperations}.
|
58
|
-
# @!attribute [rw] name
|
59
|
-
# @return [String]
|
60
|
-
# The name of the operation collection.
|
61
|
-
# @!attribute [rw] filter
|
62
|
-
# @return [String]
|
63
|
-
# The standard list filter.
|
64
|
-
# @!attribute [rw] page_size
|
65
|
-
# @return [Integer]
|
66
|
-
# The standard list page size.
|
67
|
-
# @!attribute [rw] page_token
|
68
|
-
# @return [String]
|
69
|
-
# The standard list page token.
|
70
|
-
class ListOperationsRequest; end
|
71
|
-
|
72
|
-
# The response message for {Google::Longrunning::Operations::ListOperations Operations::ListOperations}.
|
73
|
-
# @!attribute [rw] operations
|
74
|
-
# @return [Array<Google::Longrunning::Operation>]
|
75
|
-
# A list of operations that matches the specified filter in the request.
|
76
|
-
# @!attribute [rw] next_page_token
|
77
|
-
# @return [String]
|
78
|
-
# The standard List next-page token.
|
79
|
-
class ListOperationsResponse; end
|
80
|
-
|
81
|
-
# The request message for {Google::Longrunning::Operations::CancelOperation Operations::CancelOperation}.
|
82
|
-
# @!attribute [rw] name
|
83
|
-
# @return [String]
|
84
|
-
# The name of the operation resource to be cancelled.
|
85
|
-
class CancelOperationRequest; end
|
86
|
-
|
87
|
-
# The request message for {Google::Longrunning::Operations::DeleteOperation Operations::DeleteOperation}.
|
88
|
-
# @!attribute [rw] name
|
89
|
-
# @return [String]
|
90
|
-
# The name of the operation resource to be deleted.
|
91
|
-
class DeleteOperationRequest; end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,130 +0,0 @@
|
|
1
|
-
# Copyright 2018 Google LLC
|
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
|
-
# https://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
|
-
|
16
|
-
module Google
|
17
|
-
module Protobuf
|
18
|
-
# `Any` contains an arbitrary serialized protocol buffer message along with a
|
19
|
-
# URL that describes the type of the serialized message.
|
20
|
-
#
|
21
|
-
# Protobuf library provides support to pack/unpack Any values in the form
|
22
|
-
# of utility functions or additional generated methods of the Any type.
|
23
|
-
#
|
24
|
-
# Example 1: Pack and unpack a message in C++.
|
25
|
-
#
|
26
|
-
# Foo foo = ...;
|
27
|
-
# Any any;
|
28
|
-
# any.PackFrom(foo);
|
29
|
-
# ...
|
30
|
-
# if (any.UnpackTo(&foo)) {
|
31
|
-
# ...
|
32
|
-
# }
|
33
|
-
#
|
34
|
-
# Example 2: Pack and unpack a message in Java.
|
35
|
-
#
|
36
|
-
# Foo foo = ...;
|
37
|
-
# Any any = Any.pack(foo);
|
38
|
-
# ...
|
39
|
-
# if (any.is(Foo.class)) {
|
40
|
-
# foo = any.unpack(Foo.class);
|
41
|
-
# }
|
42
|
-
#
|
43
|
-
# Example 3: Pack and unpack a message in Python.
|
44
|
-
#
|
45
|
-
# foo = Foo(...)
|
46
|
-
# any = Any()
|
47
|
-
# any.Pack(foo)
|
48
|
-
# ...
|
49
|
-
# if any.Is(Foo.DESCRIPTOR):
|
50
|
-
# any.Unpack(foo)
|
51
|
-
# ...
|
52
|
-
#
|
53
|
-
# Example 4: Pack and unpack a message in Go
|
54
|
-
#
|
55
|
-
# foo := &pb.Foo{...}
|
56
|
-
# any, err := ptypes.MarshalAny(foo)
|
57
|
-
# ...
|
58
|
-
# foo := &pb.Foo{}
|
59
|
-
# if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
60
|
-
# ...
|
61
|
-
# }
|
62
|
-
#
|
63
|
-
# The pack methods provided by protobuf library will by default use
|
64
|
-
# 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
65
|
-
# methods only use the fully qualified type name after the last '/'
|
66
|
-
# in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
67
|
-
# name "y.z".
|
68
|
-
#
|
69
|
-
#
|
70
|
-
# = JSON
|
71
|
-
#
|
72
|
-
# The JSON representation of an `Any` value uses the regular
|
73
|
-
# representation of the deserialized, embedded message, with an
|
74
|
-
# additional field `@type` which contains the type URL. Example:
|
75
|
-
#
|
76
|
-
# package google.profile;
|
77
|
-
# message Person {
|
78
|
-
# string first_name = 1;
|
79
|
-
# string last_name = 2;
|
80
|
-
# }
|
81
|
-
#
|
82
|
-
# {
|
83
|
-
# "@type": "type.googleapis.com/google.profile.Person",
|
84
|
-
# "firstName": <string>,
|
85
|
-
# "lastName": <string>
|
86
|
-
# }
|
87
|
-
#
|
88
|
-
# If the embedded message type is well-known and has a custom JSON
|
89
|
-
# representation, that representation will be embedded adding a field
|
90
|
-
# `value` which holds the custom JSON in addition to the `@type`
|
91
|
-
# field. Example (for message {Google::Protobuf::Duration}):
|
92
|
-
#
|
93
|
-
# {
|
94
|
-
# "@type": "type.googleapis.com/google.protobuf.Duration",
|
95
|
-
# "value": "1.212s"
|
96
|
-
# }
|
97
|
-
# @!attribute [rw] type_url
|
98
|
-
# @return [String]
|
99
|
-
# A URL/resource name that uniquely identifies the type of the serialized
|
100
|
-
# protocol buffer message. The last segment of the URL's path must represent
|
101
|
-
# the fully qualified name of the type (as in
|
102
|
-
# `path/google.protobuf.Duration`). The name should be in a canonical form
|
103
|
-
# (e.g., leading "." is not accepted).
|
104
|
-
#
|
105
|
-
# In practice, teams usually precompile into the binary all types that they
|
106
|
-
# expect it to use in the context of Any. However, for URLs which use the
|
107
|
-
# scheme `http`, `https`, or no scheme, one can optionally set up a type
|
108
|
-
# server that maps type URLs to message definitions as follows:
|
109
|
-
#
|
110
|
-
# * If no scheme is provided, `https` is assumed.
|
111
|
-
# * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
|
112
|
-
# value in binary format, or produce an error.
|
113
|
-
# * Applications are allowed to cache lookup results based on the
|
114
|
-
# URL, or have them precompiled into a binary to avoid any
|
115
|
-
# lookup. Therefore, binary compatibility needs to be preserved
|
116
|
-
# on changes to types. (Use versioned type names to manage
|
117
|
-
# breaking changes.)
|
118
|
-
#
|
119
|
-
# Note: this functionality is not currently available in the official
|
120
|
-
# protobuf release, and it is not used for type URLs beginning with
|
121
|
-
# type.googleapis.com.
|
122
|
-
#
|
123
|
-
# Schemes other than `http`, `https` (or the empty scheme) might be
|
124
|
-
# used with implementation specific semantics.
|
125
|
-
# @!attribute [rw] value
|
126
|
-
# @return [String]
|
127
|
-
# Must be a valid serialized protocol buffer of the above specified type.
|
128
|
-
class Any; end
|
129
|
-
end
|
130
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# Copyright 2018 Google LLC
|
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
|
-
# https://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
|
-
|
16
|
-
module Google
|
17
|
-
module Protobuf
|
18
|
-
# A Duration represents a signed, fixed-length span of time represented
|
19
|
-
# as a count of seconds and fractions of seconds at nanosecond
|
20
|
-
# resolution. It is independent of any calendar and concepts like "day"
|
21
|
-
# or "month". It is related to Timestamp in that the difference between
|
22
|
-
# two Timestamp values is a Duration and it can be added or subtracted
|
23
|
-
# from a Timestamp. Range is approximately +-10,000 years.
|
24
|
-
#
|
25
|
-
# = Examples
|
26
|
-
#
|
27
|
-
# Example 1: Compute Duration from two Timestamps in pseudo code.
|
28
|
-
#
|
29
|
-
# Timestamp start = ...;
|
30
|
-
# Timestamp end = ...;
|
31
|
-
# Duration duration = ...;
|
32
|
-
#
|
33
|
-
# duration.seconds = end.seconds - start.seconds;
|
34
|
-
# duration.nanos = end.nanos - start.nanos;
|
35
|
-
#
|
36
|
-
# if (duration.seconds < 0 && duration.nanos > 0) {
|
37
|
-
# duration.seconds += 1;
|
38
|
-
# duration.nanos -= 1000000000;
|
39
|
-
# } else if (durations.seconds > 0 && duration.nanos < 0) {
|
40
|
-
# duration.seconds -= 1;
|
41
|
-
# duration.nanos += 1000000000;
|
42
|
-
# }
|
43
|
-
#
|
44
|
-
# Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
45
|
-
#
|
46
|
-
# Timestamp start = ...;
|
47
|
-
# Duration duration = ...;
|
48
|
-
# Timestamp end = ...;
|
49
|
-
#
|
50
|
-
# end.seconds = start.seconds + duration.seconds;
|
51
|
-
# end.nanos = start.nanos + duration.nanos;
|
52
|
-
#
|
53
|
-
# if (end.nanos < 0) {
|
54
|
-
# end.seconds -= 1;
|
55
|
-
# end.nanos += 1000000000;
|
56
|
-
# } else if (end.nanos >= 1000000000) {
|
57
|
-
# end.seconds += 1;
|
58
|
-
# end.nanos -= 1000000000;
|
59
|
-
# }
|
60
|
-
#
|
61
|
-
# Example 3: Compute Duration from datetime.timedelta in Python.
|
62
|
-
#
|
63
|
-
# td = datetime.timedelta(days=3, minutes=10)
|
64
|
-
# duration = Duration()
|
65
|
-
# duration.FromTimedelta(td)
|
66
|
-
#
|
67
|
-
# = JSON Mapping
|
68
|
-
#
|
69
|
-
# In JSON format, the Duration type is encoded as a string rather than an
|
70
|
-
# object, where the string ends in the suffix "s" (indicating seconds) and
|
71
|
-
# is preceded by the number of seconds, with nanoseconds expressed as
|
72
|
-
# fractional seconds. For example, 3 seconds with 0 nanoseconds should be
|
73
|
-
# encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
|
74
|
-
# be expressed in JSON format as "3.000000001s", and 3 seconds and 1
|
75
|
-
# microsecond should be expressed in JSON format as "3.000001s".
|
76
|
-
# @!attribute [rw] seconds
|
77
|
-
# @return [Integer]
|
78
|
-
# Signed seconds of the span of time. Must be from -315,576,000,000
|
79
|
-
# to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
80
|
-
# 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
81
|
-
# @!attribute [rw] nanos
|
82
|
-
# @return [Integer]
|
83
|
-
# Signed fractions of a second at nanosecond resolution of the span
|
84
|
-
# of time. Durations less than one second are represented with a 0
|
85
|
-
# `seconds` field and a positive or negative `nanos` field. For durations
|
86
|
-
# of one second or more, a non-zero value for the `nanos` field must be
|
87
|
-
# of the same sign as the `seconds` field. Must be from -999,999,999
|
88
|
-
# to +999,999,999 inclusive.
|
89
|
-
class Duration; end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# Copyright 2018 Google LLC
|
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
|
-
# https://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
|
-
|
16
|
-
module Google
|
17
|
-
module Rpc
|
18
|
-
# The `Status` type defines a logical error model that is suitable for different
|
19
|
-
# programming environments, including REST APIs and RPC APIs. It is used by
|
20
|
-
# [gRPC](https://github.com/grpc). The error model is designed to be:
|
21
|
-
#
|
22
|
-
# * Simple to use and understand for most users
|
23
|
-
# * Flexible enough to meet unexpected needs
|
24
|
-
#
|
25
|
-
# = Overview
|
26
|
-
#
|
27
|
-
# The `Status` message contains three pieces of data: error code, error message,
|
28
|
-
# and error details. The error code should be an enum value of
|
29
|
-
# {Google::Rpc::Code}, but it may accept additional error codes if needed. The
|
30
|
-
# error message should be a developer-facing English message that helps
|
31
|
-
# developers *understand* and *resolve* the error. If a localized user-facing
|
32
|
-
# error message is needed, put the localized message in the error details or
|
33
|
-
# localize it in the client. The optional error details may contain arbitrary
|
34
|
-
# information about the error. There is a predefined set of error detail types
|
35
|
-
# in the package `google.rpc` that can be used for common error conditions.
|
36
|
-
#
|
37
|
-
# = Language mapping
|
38
|
-
#
|
39
|
-
# The `Status` message is the logical representation of the error model, but it
|
40
|
-
# is not necessarily the actual wire format. When the `Status` message is
|
41
|
-
# exposed in different client libraries and different wire protocols, it can be
|
42
|
-
# mapped differently. For example, it will likely be mapped to some exceptions
|
43
|
-
# in Java, but more likely mapped to some error codes in C.
|
44
|
-
#
|
45
|
-
# = Other uses
|
46
|
-
#
|
47
|
-
# The error model and the `Status` message can be used in a variety of
|
48
|
-
# environments, either with or without APIs, to provide a
|
49
|
-
# consistent developer experience across different environments.
|
50
|
-
#
|
51
|
-
# Example uses of this error model include:
|
52
|
-
#
|
53
|
-
# * Partial errors. If a service needs to return partial errors to the client,
|
54
|
-
# it may embed the `Status` in the normal response to indicate the partial
|
55
|
-
# errors.
|
56
|
-
#
|
57
|
-
# * Workflow errors. A typical workflow has multiple steps. Each step may
|
58
|
-
# have a `Status` message for error reporting.
|
59
|
-
#
|
60
|
-
# * Batch operations. If a client uses batch request and batch response, the
|
61
|
-
# `Status` message should be used directly inside batch response, one for
|
62
|
-
# each error sub-response.
|
63
|
-
#
|
64
|
-
# * Asynchronous operations. If an API call embeds asynchronous operation
|
65
|
-
# results in its response, the status of those operations should be
|
66
|
-
# represented directly using the `Status` message.
|
67
|
-
#
|
68
|
-
# * Logging. If some API errors are stored in logs, the message `Status` could
|
69
|
-
# be used directly after any stripping needed for security/privacy reasons.
|
70
|
-
# @!attribute [rw] code
|
71
|
-
# @return [Integer]
|
72
|
-
# The status code, which should be an enum value of {Google::Rpc::Code}.
|
73
|
-
# @!attribute [rw] message
|
74
|
-
# @return [String]
|
75
|
-
# A developer-facing error message, which should be in English. Any
|
76
|
-
# user-facing error message should be localized and sent in the
|
77
|
-
# {Google::Rpc::Status#details} field, or localized by the client.
|
78
|
-
# @!attribute [rw] details
|
79
|
-
# @return [Array<Google::Protobuf::Any>]
|
80
|
-
# A list of messages that carry the error details. There is a common set of
|
81
|
-
# message types for APIs to use.
|
82
|
-
class Status; end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,136 +0,0 @@
|
|
1
|
-
# Copyright 2018 Google LLC
|
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
|
-
# https://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
|
-
|
16
|
-
require "google/cloud/speech/v1p1beta1/speech_client"
|
17
|
-
require "google/cloud/speech/v1p1beta1/stream"
|
18
|
-
|
19
|
-
module Google
|
20
|
-
module Cloud
|
21
|
-
module Speech
|
22
|
-
module V1p1beta1
|
23
|
-
class SpeechClient
|
24
|
-
# Performs bidirectional streaming speech recognition: receive results
|
25
|
-
# while sending audio. This method is only available via the gRPC API
|
26
|
-
# (not REST).
|
27
|
-
#
|
28
|
-
# @param [Google::Cloud::Speech::V1p1beta1::StreamingRecognitionConfig,
|
29
|
-
# Hash] streaming_config
|
30
|
-
# Provides information to the recognizer that specifies how to
|
31
|
-
# process the request.
|
32
|
-
# A hash of the same form as
|
33
|
-
# +Google::Cloud::Speech::V1p1beta1::StreamingRecognitionConfig+
|
34
|
-
# can also be provided.
|
35
|
-
# @param [Google::Gax::CallOptions] options
|
36
|
-
# Overrides the default settings for this call, e.g, timeout,
|
37
|
-
# retries, etc.
|
38
|
-
# @return [Google::Cloud::Speech::V1p1beta1::Stream]
|
39
|
-
# An object that streams the requests and responses.
|
40
|
-
#
|
41
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
42
|
-
#
|
43
|
-
# @example
|
44
|
-
# require "google/cloud/speech"
|
45
|
-
#
|
46
|
-
# speech_client = Google::Cloud::Speech.new version: :v1p1beta1
|
47
|
-
# streaming_config = {
|
48
|
-
# config: {
|
49
|
-
# encoding: :linear16,
|
50
|
-
# language_code: "en-US",
|
51
|
-
# sample_rate_hertz: 16000
|
52
|
-
# }
|
53
|
-
# }
|
54
|
-
# stream = speech_client.streaming_recognize(streaming_config)
|
55
|
-
#
|
56
|
-
# # Stream 5 seconds of audio from the microphone
|
57
|
-
# # Actual implementation of microphone input varies by platform
|
58
|
-
# 5.times do
|
59
|
-
# stream.send MicrophoneInput.read(32000)
|
60
|
-
# end
|
61
|
-
#
|
62
|
-
# stream.stop
|
63
|
-
# stream.wait_until_complete!
|
64
|
-
#
|
65
|
-
# results = stream.results
|
66
|
-
# result = results.first.alternatives.first
|
67
|
-
# result.transcript #=> "how old is the Brooklyn Bridge"
|
68
|
-
# result.confidence #=> 0.9826789498329163
|
69
|
-
#
|
70
|
-
def streaming_recognize streaming_config, options: nil
|
71
|
-
if streaming_config.is_a?(::Hash) &&
|
72
|
-
streaming_config[:config] &&
|
73
|
-
streaming_config[:config][:encoding]
|
74
|
-
streaming_config[:config][:encoding] =
|
75
|
-
streaming_config[:config][:encoding].upcase
|
76
|
-
end
|
77
|
-
V1p1beta1::Stream.new(
|
78
|
-
streaming_config,
|
79
|
-
proc do |reqs|
|
80
|
-
request_protos = reqs.lazy.map do |req|
|
81
|
-
Google::Gax.to_proto(
|
82
|
-
req,
|
83
|
-
Google::Cloud::Speech::V1p1beta1::StreamingRecognizeRequest
|
84
|
-
)
|
85
|
-
end
|
86
|
-
@streaming_recognize.call(request_protos, options)
|
87
|
-
end
|
88
|
-
)
|
89
|
-
end
|
90
|
-
|
91
|
-
##
|
92
|
-
# Gets the latest state of a long-running operation. Clients can use
|
93
|
-
# this method to poll the operation result at intervals as recommended
|
94
|
-
# by the API service.
|
95
|
-
#
|
96
|
-
# @param name [String]
|
97
|
-
# The name of the operation resource.
|
98
|
-
# @param options [Google::Gax::CallOptions]
|
99
|
-
# Overrides the default settings for this call, e.g, timeout,
|
100
|
-
# retries, etc.
|
101
|
-
# @return [Google::Gax::Operation]
|
102
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
103
|
-
# @example
|
104
|
-
# require "google/cloud/speech"
|
105
|
-
#
|
106
|
-
# speech_client = Google::Cloud::Speech.new version: :v1p1beta1
|
107
|
-
#
|
108
|
-
# op = speech_client.get_operation "-"
|
109
|
-
#
|
110
|
-
# # Process error operations.
|
111
|
-
# log_error op.error if op.error?
|
112
|
-
#
|
113
|
-
# if op.done?
|
114
|
-
# # Process completed operations.
|
115
|
-
# log_finished op.response, op.metadata
|
116
|
-
# else
|
117
|
-
# # Process pending operations.
|
118
|
-
# log_pending op.name, op.metadata
|
119
|
-
# end
|
120
|
-
#
|
121
|
-
def get_operation name, options: nil
|
122
|
-
proto_op = @operations_client.get_operation name, options: options
|
123
|
-
|
124
|
-
Google::Gax::Operation.new(
|
125
|
-
proto_op,
|
126
|
-
@operations_client,
|
127
|
-
Google::Cloud::Speech::V1p1beta1::LongRunningRecognizeResponse,
|
128
|
-
Google::Cloud::Speech::V1p1beta1::LongRunningRecognizeMetadata,
|
129
|
-
call_options: options
|
130
|
-
)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|