This repository has been archived by the owner on Aug 25, 2022. It is now read-only.
forked from googleapis/google-cloud-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace manual Speech library with GAPIC and helpers (googleapis#1977)
This PR replaces the existing Speech client library with an auto-generated library. The auto-generated code is supplemented with a helper that wraps the auto-generated bidi streaming RPC in the stream class from the old manual library. (Note that this is a divergence from the Python library, but one that should substantially improve the usability of bidi streaming relative to Python.) As such, it substantially changes the public surface.
- Loading branch information
Showing
56 changed files
with
1,163 additions
and
5,216 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,7 @@ jsondoc/* | |
|
||
# Ignore YARD stuffs | ||
.yardoc | ||
|
||
# IDE settings | ||
.idea | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Apache License | ||
Apache License | ||
Version 2.0, January 2004 | ||
https://www.apache.org/licenses/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,49 @@ | ||
# google-cloud-speech | ||
# Ruby Client for Google Cloud Speech API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning)) | ||
|
||
[Google Cloud Speech API](https://cloud.google.com/speech/) ([docs](https://cloud.google.com/speech/docs)) enables developers to convert audio to text by applying powerful neural network models. | ||
|
||
- [google-cloud-speech API documentation](http://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-speech/latest) | ||
- [google-cloud-speech on RubyGems](https://rubygems.org/gems/google-cloud-speech) | ||
- [Google Cloud Speech API documentation](https://cloud.google.com/speech/docs) | ||
[Google Cloud Speech API][Product Documentation]: | ||
Google Cloud Speech API. | ||
- [Client Library Documentation][] | ||
- [Product Documentation][] | ||
|
||
## Quick Start | ||
In order to use this library, you first need to go through the following | ||
steps: | ||
|
||
1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project) | ||
2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project) | ||
3. [Enable the Google Cloud Speech API.](https://console.cloud.google.com/apis/api/speech) | ||
4. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication) | ||
|
||
```sh | ||
### Installation | ||
``` | ||
$ gem install google-cloud-speech | ||
``` | ||
|
||
## Authentication | ||
|
||
This library uses Service Account credentials to connect to Google Cloud services. When running on Compute Engine the credentials will be discovered automatically. When running on other environments the Service Account credentials can be specified by providing the path to the JSON file, or the JSON itself, in environment variables. | ||
|
||
Instructions and configuration options are covered in the [Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-speech/guides/authentication). | ||
|
||
## Example | ||
|
||
```ruby | ||
### Preview | ||
#### SpeechClient | ||
```rb | ||
require "google/cloud/speech" | ||
|
||
speech = Google::Cloud::Speech.new | ||
|
||
audio = speech.audio "path/to/audio.raw", | ||
encoding: :linear16, | ||
language: "en-US", | ||
sample_rate: 16000 | ||
|
||
results = audio.recognize | ||
result = results.first | ||
result.transcript #=> "how old is the Brooklyn Bridge" | ||
result.confidence #=> 0.9826789498329163 | ||
``` | ||
|
||
## Enabling Logging | ||
|
||
To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below, or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger) that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information. | ||
|
||
Configuring a Ruby stdlib logger: | ||
|
||
```ruby | ||
require "logger" | ||
|
||
module MyLogger | ||
LOGGER = Logger.new $stderr, level: Logger::WARN | ||
def logger | ||
LOGGER | ||
end | ||
end | ||
|
||
# Define a gRPC module-level logger method before grpc/logconfig.rb loads. | ||
module GRPC | ||
extend MyLogger | ||
end | ||
speech_client = Google::Cloud::Speech.new | ||
language_code = "en-US" | ||
sample_rate_hertz = 44100 | ||
encoding = :FLAC | ||
config = { | ||
language_code: language_code, | ||
sample_rate_hertz: sample_rate_hertz, | ||
encoding: encoding | ||
} | ||
uri = "gs://gapic-toolkit/hello.flac" | ||
audio = { uri: uri } | ||
response = speech_client.recognize(config, audio) | ||
``` | ||
|
||
## Supported Ruby Versions | ||
|
||
This library is supported on Ruby 2.0+. | ||
|
||
However, Ruby 2.3 or later is strongly recommended, as earlier releases have | ||
reached or are nearing end-of-life. After June 1, 2018, Google will provide | ||
official support only for Ruby versions that are considered current and | ||
supported by Ruby Core (that is, Ruby versions that are either in normal | ||
maintenance or in security maintenance). | ||
See https://www.ruby-lang.org/en/downloads/branches/ for further details. | ||
|
||
## Versioning | ||
|
||
This library follows [Semantic Versioning](http://semver.org/). | ||
|
||
It is currently in major version zero (0.y.z), which means that anything may change at any time and the public API should not be considered stable. | ||
|
||
## Contributing | ||
|
||
Contributions to this library are always welcome and highly encouraged. | ||
|
||
See the [Contributing Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/contributing) for more information on how to get started. | ||
|
||
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct](../CODE_OF_CONDUCT.md) for more information. | ||
|
||
## License | ||
|
||
This library is licensed under Apache 2.0. Full license text is available in [LICENSE](LICENSE). | ||
|
||
## Support | ||
|
||
Please [report bugs at the project on Github](https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues). | ||
Don't hesitate to [ask questions](http://stackoverflow.com/questions/tagged/google-cloud-ruby) about the client or APIs on [StackOverflow](http://stackoverflow.com). | ||
### Next Steps | ||
- Read the [Client Library Documentation][] for Google Cloud Speech API | ||
to see other available methods on the client. | ||
- Read the [Google Cloud Speech API Product documentation][Product Documentation] | ||
to learn more about the product and see How-to Guides. | ||
- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md) | ||
to see the full list of Cloud APIs that we cover. | ||
|
||
[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud-speech/latest/google/cloud/speech/v1 | ||
[Product Documentation]: https://cloud.google.com/speech |
Oops, something went wrong.