forked from googleapis/java-talent
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update repo-metadata and regenerate README from templates (goo…
…gleapis#88) * chore: update repo-metadata and regenerate README from templates * restore examples * fix pretty name
- Loading branch information
Showing
5 changed files
with
184 additions
and
153 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
custom_content: | | ||
### Recognizing speech | ||
The following code sample shows how to recognize speech using an audio file from a Cloud Storage bucket as input. | ||
First, add the following imports at the top of your file: | ||
```java | ||
import com.google.cloud.speech.v1.SpeechClient; | ||
import com.google.cloud.speech.v1.RecognitionAudio; | ||
import com.google.cloud.speech.v1.RecognitionConfig; | ||
import com.google.cloud.speech.v1.RecognitionConfig.AudioEncoding; | ||
import com.google.cloud.speech.v1.RecognizeResponse; | ||
``` | ||
Then add the following code to do the speech recognization: | ||
```java | ||
try (SpeechClient speechClient = SpeechClient.create()) { | ||
RecognitionConfig.AudioEncoding encoding = RecognitionConfig.AudioEncoding.FLAC; | ||
int sampleRateHertz = 44100; | ||
String languageCode = "en-US"; | ||
RecognitionConfig config = RecognitionConfig.newBuilder() | ||
.setEncoding(encoding) | ||
.setSampleRateHertz(sampleRateHertz) | ||
.setLanguageCode(languageCode) | ||
.build(); | ||
String uri = "gs://bucket_name/file_name.flac"; | ||
RecognitionAudio audio = RecognitionAudio.newBuilder() | ||
.setUri(uri) | ||
.build(); | ||
RecognizeResponse response = speechClient.recognize(config, audio); | ||
} | ||
``` | ||
#### Complete source code | ||
In [RecognizeSpeech.java](https://github.com/googleapis/google-cloud-java/blob/master/google-cloud-examples/src/main/java/com/google/cloud/examples/speech/snippets/RecognizeSpeech.java) we put a quick start example, which shows how you can use Google Speech API to automatically recognize speech based on a local file. | ||
For an example audio file, you can use the [audio.raw](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/speech/cloud-client/resources/audio.raw) file from the samples repository. | ||
Note, to play the file on Unix-like system you may use the following command: `play -t raw -r 16k -e signed -b 16 -c 1 audio.raw` |
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,9 +1,16 @@ | ||
{ | ||
"name": "google-cloud-speech", | ||
"name_pretty": "Google Cloud Speech", | ||
"release_level": "ga", | ||
"language": "java", | ||
"repo": "googleapis/java-speech", | ||
"repo_short": "java-speech", | ||
"distribution_name": "google-cloud-speech" | ||
} | ||
"name": "google-cloud-speech", | ||
"name_pretty": "Cloud Speech", | ||
"release_level": "ga", | ||
"language": "java", | ||
"repo": "googleapis/java-speech", | ||
"repo_short": "java-speech", | ||
"distribution_name": "com.google.cloud:google-cloud-speech", | ||
"client_documentation": "https://googleapis.dev/java/google-cloud-speech/latest/", | ||
"transport": "grpc", | ||
"issue_tracker": "https://issuetracker.google.com/savedsearches/559758", | ||
"requires_billing": false, | ||
"api_id": "speech.googleapis.com", | ||
"product_documentation": "https://cloud.google.com/speech-to-text/docs/", | ||
"api_description": "enables easy integration of Google speech recognition technologies into developer applications. Send audio and receive a text transcription from the Speech-to-Text API service." | ||
} |
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
Oops, something went wrong.