google-cloud-speech 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/LICENSE +1 -1
  4. data/README.md +69 -43
  5. data/lib/google/cloud/speech.rb +94 -252
  6. data/lib/google/cloud/speech/v1.rb +11 -1
  7. data/lib/google/cloud/speech/v1/cloud_speech_services_pb.rb +1 -1
  8. data/lib/google/cloud/speech/{version.rb → v1/credentials.rb} +12 -2
  9. data/lib/google/cloud/speech/v1/doc/google/cloud/speech/v1/cloud_speech.rb +2 -2
  10. data/lib/google/cloud/speech/v1/doc/google/longrunning/operations.rb +92 -0
  11. data/lib/google/cloud/speech/v1/doc/google/protobuf/any.rb +1 -1
  12. data/lib/google/cloud/speech/v1/doc/google/protobuf/duration.rb +1 -1
  13. data/lib/google/cloud/speech/v1/doc/google/rpc/status.rb +1 -1
  14. data/lib/google/cloud/speech/v1/doc/overview.rb +1 -1
  15. data/lib/google/cloud/speech/v1/helpers.rb +93 -0
  16. data/lib/google/cloud/speech/v1/speech_client.rb +26 -49
  17. data/lib/google/cloud/speech/v1/speech_client_config.json +5 -5
  18. data/lib/google/cloud/speech/v1/stream.rb +614 -0
  19. data/lib/google/cloud/speech/v1p1beta1.rb +126 -0
  20. data/lib/google/cloud/speech/v1p1beta1/cloud_speech_pb.rb +175 -0
  21. data/lib/google/cloud/speech/v1p1beta1/cloud_speech_services_pb.rb +54 -0
  22. data/lib/google/cloud/speech/v1p1beta1/credentials.rb +32 -0
  23. data/lib/google/cloud/speech/v1p1beta1/doc/google/cloud/speech/v1p1beta1/cloud_speech.rb +625 -0
  24. data/lib/google/cloud/speech/v1p1beta1/doc/google/longrunning/operations.rb +92 -0
  25. data/lib/google/cloud/speech/v1p1beta1/doc/google/protobuf/any.rb +124 -0
  26. data/lib/google/cloud/speech/v1p1beta1/doc/google/protobuf/duration.rb +90 -0
  27. data/lib/google/cloud/speech/v1p1beta1/doc/google/rpc/status.rb +83 -0
  28. data/lib/google/cloud/speech/v1p1beta1/doc/overview.rb +73 -0
  29. data/lib/google/cloud/speech/v1p1beta1/helpers.rb +93 -0
  30. data/lib/google/cloud/speech/v1p1beta1/speech_client.rb +322 -0
  31. data/lib/google/cloud/speech/v1p1beta1/speech_client_config.json +41 -0
  32. data/lib/google/cloud/speech/v1p1beta1/stream.rb +614 -0
  33. metadata +29 -120
  34. data/lib/google-cloud-speech.rb +0 -142
  35. data/lib/google/cloud/speech/audio.rb +0 -330
  36. data/lib/google/cloud/speech/convert.rb +0 -46
  37. data/lib/google/cloud/speech/credentials.rb +0 -57
  38. data/lib/google/cloud/speech/operation.rb +0 -262
  39. data/lib/google/cloud/speech/project.rb +0 -651
  40. data/lib/google/cloud/speech/result.rb +0 -240
  41. data/lib/google/cloud/speech/service.rb +0 -121
  42. data/lib/google/cloud/speech/stream.rb +0 -564
@@ -0,0 +1,92 @@
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
+ module Google
16
+ module Longrunning
17
+ # This resource represents a long-running operation that is the result of a
18
+ # network API call.
19
+ # @!attribute [rw] name
20
+ # @return [String]
21
+ # The server-assigned name, which is only unique within the same service that
22
+ # originally returns it. If you use the default HTTP mapping, the
23
+ # +name+ should have the format of +operations/some/unique/name+.
24
+ # @!attribute [rw] metadata
25
+ # @return [Google::Protobuf::Any]
26
+ # Service-specific metadata associated with the operation. It typically
27
+ # contains progress information and common metadata such as create time.
28
+ # Some services might not provide such metadata. Any method that returns a
29
+ # long-running operation should document the metadata type, if any.
30
+ # @!attribute [rw] done
31
+ # @return [true, false]
32
+ # If the value is +false+, it means the operation is still in progress.
33
+ # If true, the operation is completed, and either +error+ or +response+ is
34
+ # available.
35
+ # @!attribute [rw] error
36
+ # @return [Google::Rpc::Status]
37
+ # The error result of the operation in case of failure or cancellation.
38
+ # @!attribute [rw] response
39
+ # @return [Google::Protobuf::Any]
40
+ # The normal response of the operation in case of success. If the original
41
+ # method returns no data on success, such as +Delete+, the response is
42
+ # +google.protobuf.Empty+. If the original method is standard
43
+ # +Get+/+Create+/+Update+, the response should be the resource. For other
44
+ # methods, the response should have the type +XxxResponse+, where +Xxx+
45
+ # is the original method name. For example, if the original method name
46
+ # is +TakeSnapshot()+, the inferred response type is
47
+ # +TakeSnapshotResponse+.
48
+ class Operation; end
49
+
50
+ # The request message for {Google::Longrunning::Operations::GetOperation Operations::GetOperation}.
51
+ # @!attribute [rw] name
52
+ # @return [String]
53
+ # The name of the operation resource.
54
+ class GetOperationRequest; end
55
+
56
+ # The request message for {Google::Longrunning::Operations::ListOperations Operations::ListOperations}.
57
+ # @!attribute [rw] name
58
+ # @return [String]
59
+ # The name of the operation collection.
60
+ # @!attribute [rw] filter
61
+ # @return [String]
62
+ # The standard list filter.
63
+ # @!attribute [rw] page_size
64
+ # @return [Integer]
65
+ # The standard list page size.
66
+ # @!attribute [rw] page_token
67
+ # @return [String]
68
+ # The standard list page token.
69
+ class ListOperationsRequest; end
70
+
71
+ # The response message for {Google::Longrunning::Operations::ListOperations Operations::ListOperations}.
72
+ # @!attribute [rw] operations
73
+ # @return [Array<Google::Longrunning::Operation>]
74
+ # A list of operations that matches the specified filter in the request.
75
+ # @!attribute [rw] next_page_token
76
+ # @return [String]
77
+ # The standard List next-page token.
78
+ class ListOperationsResponse; end
79
+
80
+ # The request message for {Google::Longrunning::Operations::CancelOperation Operations::CancelOperation}.
81
+ # @!attribute [rw] name
82
+ # @return [String]
83
+ # The name of the operation resource to be cancelled.
84
+ class CancelOperationRequest; end
85
+
86
+ # The request message for {Google::Longrunning::Operations::DeleteOperation Operations::DeleteOperation}.
87
+ # @!attribute [rw] name
88
+ # @return [String]
89
+ # The name of the operation resource to be deleted.
90
+ class DeleteOperationRequest; end
91
+ end
92
+ end
@@ -0,0 +1,124 @@
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
+ 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
+ # Example 3: Pack and unpack a message in Python.
43
+ #
44
+ # foo = Foo(...)
45
+ # any = Any()
46
+ # any.Pack(foo)
47
+ # ...
48
+ # if any.Is(Foo.DESCRIPTOR):
49
+ # any.Unpack(foo)
50
+ # ...
51
+ #
52
+ # Example 4: Pack and unpack a message in Go
53
+ #
54
+ # foo := &pb.Foo{...}
55
+ # any, err := ptypes.MarshalAny(foo)
56
+ # ...
57
+ # foo := &pb.Foo{}
58
+ # if err := ptypes.UnmarshalAny(any, foo); err != nil {
59
+ # ...
60
+ # }
61
+ #
62
+ # The pack methods provided by protobuf library will by default use
63
+ # 'type.googleapis.com/full.type.name' as the type URL and the unpack
64
+ # methods only use the fully qualified type name after the last '/'
65
+ # in the type URL, for example "foo.bar.com/x/y.z" will yield type
66
+ # name "y.z".
67
+ #
68
+ #
69
+ # = JSON
70
+ #
71
+ # The JSON representation of an +Any+ value uses the regular
72
+ # representation of the deserialized, embedded message, with an
73
+ # additional field +@type+ which contains the type URL. Example:
74
+ #
75
+ # package google.profile;
76
+ # message Person {
77
+ # string first_name = 1;
78
+ # string last_name = 2;
79
+ # }
80
+ #
81
+ # {
82
+ # "@type": "type.googleapis.com/google.profile.Person",
83
+ # "firstName": <string>,
84
+ # "lastName": <string>
85
+ # }
86
+ #
87
+ # If the embedded message type is well-known and has a custom JSON
88
+ # representation, that representation will be embedded adding a field
89
+ # +value+ which holds the custom JSON in addition to the +@type+
90
+ # field. Example (for message {Google::Protobuf::Duration}):
91
+ #
92
+ # {
93
+ # "@type": "type.googleapis.com/google.protobuf.Duration",
94
+ # "value": "1.212s"
95
+ # }
96
+ # @!attribute [rw] type_url
97
+ # @return [String]
98
+ # A URL/resource name whose content describes the type of the
99
+ # serialized protocol buffer message.
100
+ #
101
+ # For URLs which use the scheme +http+, +https+, or no scheme, the
102
+ # following restrictions and interpretations apply:
103
+ #
104
+ # * If no scheme is provided, +https+ is assumed.
105
+ # * The last segment of the URL's path must represent the fully
106
+ # qualified name of the type (as in +path/google.protobuf.Duration+).
107
+ # The name should be in a canonical form (e.g., leading "." is
108
+ # not accepted).
109
+ # * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
110
+ # value in binary format, or produce an error.
111
+ # * Applications are allowed to cache lookup results based on the
112
+ # URL, or have them precompiled into a binary to avoid any
113
+ # lookup. Therefore, binary compatibility needs to be preserved
114
+ # on changes to types. (Use versioned type names to manage
115
+ # breaking changes.)
116
+ #
117
+ # Schemes other than +http+, +https+ (or the empty scheme) might be
118
+ # used with implementation specific semantics.
119
+ # @!attribute [rw] value
120
+ # @return [String]
121
+ # Must be a valid serialized protocol buffer of the above specified type.
122
+ class Any; end
123
+ end
124
+ end
@@ -0,0 +1,90 @@
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
+ module Google
16
+ module Protobuf
17
+ # A Duration represents a signed, fixed-length span of time represented
18
+ # as a count of seconds and fractions of seconds at nanosecond
19
+ # resolution. It is independent of any calendar and concepts like "day"
20
+ # or "month". It is related to Timestamp in that the difference between
21
+ # two Timestamp values is a Duration and it can be added or subtracted
22
+ # from a Timestamp. Range is approximately +-10,000 years.
23
+ #
24
+ # = Examples
25
+ #
26
+ # Example 1: Compute Duration from two Timestamps in pseudo code.
27
+ #
28
+ # Timestamp start = ...;
29
+ # Timestamp end = ...;
30
+ # Duration duration = ...;
31
+ #
32
+ # duration.seconds = end.seconds - start.seconds;
33
+ # duration.nanos = end.nanos - start.nanos;
34
+ #
35
+ # if (duration.seconds < 0 && duration.nanos > 0) {
36
+ # duration.seconds += 1;
37
+ # duration.nanos -= 1000000000;
38
+ # } else if (durations.seconds > 0 && duration.nanos < 0) {
39
+ # duration.seconds -= 1;
40
+ # duration.nanos += 1000000000;
41
+ # }
42
+ #
43
+ # Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
44
+ #
45
+ # Timestamp start = ...;
46
+ # Duration duration = ...;
47
+ # Timestamp end = ...;
48
+ #
49
+ # end.seconds = start.seconds + duration.seconds;
50
+ # end.nanos = start.nanos + duration.nanos;
51
+ #
52
+ # if (end.nanos < 0) {
53
+ # end.seconds -= 1;
54
+ # end.nanos += 1000000000;
55
+ # } else if (end.nanos >= 1000000000) {
56
+ # end.seconds += 1;
57
+ # end.nanos -= 1000000000;
58
+ # }
59
+ #
60
+ # Example 3: Compute Duration from datetime.timedelta in Python.
61
+ #
62
+ # td = datetime.timedelta(days=3, minutes=10)
63
+ # duration = Duration()
64
+ # duration.FromTimedelta(td)
65
+ #
66
+ # = JSON Mapping
67
+ #
68
+ # In JSON format, the Duration type is encoded as a string rather than an
69
+ # object, where the string ends in the suffix "s" (indicating seconds) and
70
+ # is preceded by the number of seconds, with nanoseconds expressed as
71
+ # fractional seconds. For example, 3 seconds with 0 nanoseconds should be
72
+ # encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
73
+ # be expressed in JSON format as "3.000000001s", and 3 seconds and 1
74
+ # microsecond should be expressed in JSON format as "3.000001s".
75
+ # @!attribute [rw] seconds
76
+ # @return [Integer]
77
+ # Signed seconds of the span of time. Must be from -315,576,000,000
78
+ # to +315,576,000,000 inclusive. Note: these bounds are computed from:
79
+ # 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
80
+ # @!attribute [rw] nanos
81
+ # @return [Integer]
82
+ # Signed fractions of a second at nanosecond resolution of the span
83
+ # of time. Durations less than one second are represented with a 0
84
+ # +seconds+ field and a positive or negative +nanos+ field. For durations
85
+ # of one second or more, a non-zero value for the +nanos+ field must be
86
+ # of the same sign as the +seconds+ field. Must be from -999,999,999
87
+ # to +999,999,999 inclusive.
88
+ class Duration; end
89
+ end
90
+ end
@@ -0,0 +1,83 @@
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
+ 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+ that 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.
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 is a common set of
80
+ # message types for APIs to use.
81
+ class Status; end
82
+ end
83
+ end
@@ -0,0 +1,73 @@
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
+ module Google
16
+ module Cloud
17
+ # rubocop:disable LineLength
18
+
19
+ ##
20
+ # # Ruby Client for Cloud Speech API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
21
+ #
22
+ # [Cloud Speech API][Product Documentation]:
23
+ # Converts audio to text by applying powerful neural network models.
24
+ # - [Product Documentation][]
25
+ #
26
+ # ## Quick Start
27
+ # In order to use this library, you first need to go through the following
28
+ # steps:
29
+ #
30
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
31
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
32
+ # 3. [Enable the Cloud Speech API.](https://console.cloud.google.com/apis/api/speech)
33
+ # 4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
34
+ #
35
+ # ### Installation
36
+ # ```
37
+ # $ gem install google-cloud-speech
38
+ # ```
39
+ #
40
+ # ### Preview
41
+ # #### SpeechClient
42
+ # ```rb
43
+ # require "google/cloud/speech"
44
+ #
45
+ # speech_client = Google::Cloud::Speech::V1p1beta1.new
46
+ # language_code = "en-US"
47
+ # sample_rate_hertz = 44100
48
+ # encoding = :FLAC
49
+ # config = {
50
+ # language_code: language_code,
51
+ # sample_rate_hertz: sample_rate_hertz,
52
+ # encoding: encoding
53
+ # }
54
+ # uri = "gs://gapic-toolkit/hello.flac"
55
+ # audio = { uri: uri }
56
+ # response = speech_client.recognize(config, audio)
57
+ # ```
58
+ #
59
+ # ### Next Steps
60
+ # - Read the [Cloud Speech API Product documentation][Product Documentation]
61
+ # to learn more about the product and see How-to Guides.
62
+ # - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
63
+ # to see the full list of Cloud APIs that we cover.
64
+ #
65
+ # [Product Documentation]: https://cloud.google.com/speech
66
+ #
67
+ #
68
+ module Speech
69
+ module V1p1beta1
70
+ end
71
+ end
72
+ end
73
+ end