Skip to content

Commit

Permalink
chore: update common templates, regenerate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and chingor13 committed Nov 19, 2019
1 parent 8cd1669 commit ad7b7a0
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,19 @@ public class SpeechTranscribeAsync {
* import java.nio.file.Paths;
*/

public static void sampleLongRunningRecognize() {
// TODO(developer): Replace these variables before running the sample.
String localFilePath = "resources/brooklyn_bridge.raw";
sampleLongRunningRecognize(localFilePath);
}

/**
* Transcribe a long audio file using asynchronous speech recognition
*
* @param localFilePath Path to local audio file, e.g. /path/audio.wav
*/
public static void sampleLongRunningRecognize(String localFilePath) {
try (SpeechClient speechClient = SpeechClient.create()) {
// localFilePath = "resources/brooklyn_bridge.raw";

// The language of the supplied audio
String languageCode = "en-US";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,19 @@ public class SpeechTranscribeAsyncGcs {
* import com.google.cloud.speech.v1.SpeechRecognitionResult;
*/

public static void sampleLongRunningRecognize() {
// TODO(developer): Replace these variables before running the sample.
String storageUri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw";
sampleLongRunningRecognize(storageUri);
}

/**
* Transcribe long audio file from Cloud Storage using asynchronous speech recognition
*
* @param storageUri URI for audio file in Cloud Storage, e.g. gs://[BUCKET]/[FILE]
*/
public static void sampleLongRunningRecognize(String storageUri) {
try (SpeechClient speechClient = SpeechClient.create()) {
// storageUri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw";

// Sample rate in Hertz of the audio data sent
int sampleRateHertz = 16000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,19 @@ public class SpeechTranscribeAsyncWordTimeOffsetsGcs {
* import com.google.cloud.speech.v1.WordInfo;
*/

public static void sampleLongRunningRecognize() {
// TODO(developer): Replace these variables before running the sample.
String storageUri = "gs://cloud-samples-data/speech/brooklyn_bridge.flac";
sampleLongRunningRecognize(storageUri);
}

/**
* Print start and end time of each word spoken in audio file from Cloud Storage
*
* @param storageUri URI for audio file in Cloud Storage, e.g. gs://[BUCKET]/[FILE]
*/
public static void sampleLongRunningRecognize(String storageUri) {
try (SpeechClient speechClient = SpeechClient.create()) {
// storageUri = "gs://cloud-samples-data/speech/brooklyn_bridge.flac";

// When enabled, the first result returned by the API will include a list
// of words and the start and end time offsets (timestamps) for those words.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ public class SpeechTranscribeEnhancedModel {
* import java.nio.file.Paths;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String localFilePath = "resources/hello.wav";
sampleRecognize(localFilePath);
}

/**
* Transcribe a short audio file using an enhanced model
*
* @param localFilePath Path to local audio file, e.g. /path/audio.wav
*/
public static void sampleRecognize(String localFilePath) {
try (SpeechClient speechClient = SpeechClient.create()) {
// localFilePath = "resources/hello.wav";

// The enhanced model to use, e.g. phone_call
// Currently phone_call is the only model available as an enhanced model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ public class SpeechTranscribeModelSelection {
* import java.nio.file.Paths;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String localFilePath = "resources/hello.wav";
String model = "phone_call";
sampleRecognize(localFilePath, model);
}

/**
* Transcribe a short audio file using a specified transcription model
*
Expand All @@ -65,8 +72,6 @@ public class SpeechTranscribeModelSelection {
*/
public static void sampleRecognize(String localFilePath, String model) {
try (SpeechClient speechClient = SpeechClient.create()) {
// localFilePath = "resources/hello.wav";
// model = "phone_call";

// The language of the supplied audio
String languageCode = "en-US";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public class SpeechTranscribeModelSelectionGcs {
* import com.google.cloud.speech.v1.SpeechRecognitionResult;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String storageUri = "gs://cloud-samples-data/speech/hello.wav";
String model = "phone_call";
sampleRecognize(storageUri, model);
}

/**
* Transcribe a short audio file from Cloud Storage using a specified transcription model
*
Expand All @@ -57,8 +64,6 @@ public class SpeechTranscribeModelSelectionGcs {
*/
public static void sampleRecognize(String storageUri, String model) {
try (SpeechClient speechClient = SpeechClient.create()) {
// storageUri = "gs://cloud-samples-data/speech/hello.wav";
// model = "phone_call";

// The language of the supplied audio
String languageCode = "en-US";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ public class SpeechTranscribeMultichannel {
* import java.nio.file.Paths;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String localFilePath = "resources/multi.wav";
sampleRecognize(localFilePath);
}

/**
* Transcribe a short audio file with multiple channels
*
* @param localFilePath Path to local audio file, e.g. /path/audio.wav
*/
public static void sampleRecognize(String localFilePath) {
try (SpeechClient speechClient = SpeechClient.create()) {
// localFilePath = "resources/multi.wav";

// The number of channels in the input audio file (optional)
int audioChannelCount = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ public class SpeechTranscribeMultichannelGcs {
* import com.google.cloud.speech.v1.SpeechRecognitionResult;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String storageUri = "gs://cloud-samples-data/speech/multi.wav";
sampleRecognize(storageUri);
}

/**
* Transcribe a short audio file from Cloud Storage with multiple channels
*
* @param storageUri URI for audio file in Cloud Storage, e.g. gs://[BUCKET]/[FILE]
*/
public static void sampleRecognize(String storageUri) {
try (SpeechClient speechClient = SpeechClient.create()) {
// storageUri = "gs://cloud-samples-data/speech/multi.wav";

// The number of channels in the input audio file (optional)
int audioChannelCount = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ public class SpeechTranscribeSync {
* import java.nio.file.Paths;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String localFilePath = "resources/brooklyn_bridge.raw";
sampleRecognize(localFilePath);
}

/**
* Transcribe a short audio file using synchronous speech recognition
*
* @param localFilePath Path to local audio file, e.g. /path/audio.wav
*/
public static void sampleRecognize(String localFilePath) {
try (SpeechClient speechClient = SpeechClient.create()) {
// localFilePath = "resources/brooklyn_bridge.raw";

// The language of the supplied audio
String languageCode = "en-US";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ public class SpeechTranscribeSyncGcs {
* import com.google.cloud.speech.v1.SpeechRecognitionResult;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String storageUri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw";
sampleRecognize(storageUri);
}

/**
* Transcribe short audio file from Cloud Storage using synchronous speech recognition
*
* @param storageUri URI for audio file in Cloud Storage, e.g. gs://[BUCKET]/[FILE]
*/
public static void sampleRecognize(String storageUri) {
try (SpeechClient speechClient = SpeechClient.create()) {
// storageUri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw";

// Sample rate in Hertz of the audio data sent
int sampleRateHertz = 16000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public class SpeechAdaptationBeta {
* import java.util.List;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String storageUri = "gs://cloud-samples-data/speech/brooklyn_bridge.mp3";
String phrase = "Brooklyn Bridge";
sampleRecognize(storageUri, phrase);
}

/**
* Transcribe a short audio file with speech adaptation.
*
Expand All @@ -61,8 +68,6 @@ public class SpeechAdaptationBeta {
*/
public static void sampleRecognize(String storageUri, String phrase) {
try (SpeechClient speechClient = SpeechClient.create()) {
// storageUri = "gs://cloud-samples-data/speech/brooklyn_bridge.mp3";
// phrase = "Brooklyn Bridge";
List<String> phrases = Arrays.asList(phrase);

// Hint Boost. This value increases the probability that a specific
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public class SpeechContextsClassesBeta {
* import java.util.List;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String storageUri = "gs://cloud-samples-data/speech/time.mp3";
String phrase = "$TIME";
sampleRecognize(storageUri, phrase);
}

/**
* Transcribe a short audio file with static context classes.
*
Expand All @@ -63,8 +70,6 @@ public class SpeechContextsClassesBeta {
*/
public static void sampleRecognize(String storageUri, String phrase) {
try (SpeechClient speechClient = SpeechClient.create()) {
// storageUri = "gs://cloud-samples-data/speech/time.mp3";
// phrase = "$TIME";
List<String> phrases = Arrays.asList(phrase);
SpeechContext speechContextsElement =
SpeechContext.newBuilder().addAllPhrases(phrases).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ public class SpeechQuickstartBeta {
* import com.google.cloud.speech.v1p1beta1.SpeechRecognitionResult;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String storageUri = "gs://cloud-samples-data/speech/brooklyn_bridge.mp3";
sampleRecognize(storageUri);
}

/**
* Performs synchronous speech recognition on an audio file
*
* @param storageUri URI for audio file in Cloud Storage, e.g. gs://[BUCKET]/[FILE]
*/
public static void sampleRecognize(String storageUri) {
try (SpeechClient speechClient = SpeechClient.create()) {
// storageUri = "gs://cloud-samples-data/speech/brooklyn_bridge.mp3";

// The language of the supplied audio
String languageCode = "en-US";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ public class SpeechTranscribeAutoPunctuationBeta {
* import java.nio.file.Paths;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String localFilePath = "resources/commercial_mono.wav";
sampleRecognize(localFilePath);
}

/**
* Transcribe a short audio file with punctuation
*
* @param localFilePath Path to local audio file, e.g. /path/audio.wav
*/
public static void sampleRecognize(String localFilePath) {
try (SpeechClient speechClient = SpeechClient.create()) {
// localFilePath = "resources/commercial_mono.wav";

// When enabled, trascription results may include punctuation
// (available for select languages).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public class SpeechTranscribeDiarizationBeta {
* import java.nio.file.Paths;
*/

public static void sampleLongRunningRecognize() {
// TODO(developer): Replace these variables before running the sample.
String localFilePath = "resources/commercial_mono.wav";
sampleLongRunningRecognize(localFilePath);
}

/**
* Print confidence level for individual words in a transcription of a short audio file Separating
* different speakers in an audio file recording
Expand All @@ -70,7 +76,6 @@ public class SpeechTranscribeDiarizationBeta {
*/
public static void sampleLongRunningRecognize(String localFilePath) {
try (SpeechClient speechClient = SpeechClient.create()) {
// localFilePath = "resources/commercial_mono.wav";

// If enabled, each word in the first alternative of each result will be
// tagged with a speaker tag to identify the speaker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,19 @@ public class SpeechTranscribeMultilanguageBeta {
* import java.util.List;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String localFilePath = "resources/brooklyn_bridge.flac";
sampleRecognize(localFilePath);
}

/**
* Transcribe a short audio file with language detected from a list of possible languages
*
* @param localFilePath Path to local audio file, e.g. /path/audio.wav
*/
public static void sampleRecognize(String localFilePath) {
try (SpeechClient speechClient = SpeechClient.create()) {
// localFilePath = "resources/brooklyn_bridge.flac";

// The language of the supplied audio. Even though additional languages are
// provided by alternative_language_codes, a primary language is still required.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@ public class SpeechTranscribeRecognitionMetadataBeta {
* import java.nio.file.Paths;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String localFilePath = "resources/commercial_mono.wav";
sampleRecognize(localFilePath);
}

/**
* Adds additional details short audio file included in this recognition request
*
* @param localFilePath Path to local audio file, e.g. /path/audio.wav
*/
public static void sampleRecognize(String localFilePath) {
try (SpeechClient speechClient = SpeechClient.create()) {
// localFilePath = "resources/commercial_mono.wav";

// The use case of the audio, e.g. PHONE_CALL, DISCUSSION, PRESENTATION, et al.
RecognitionMetadata.InteractionType interactionType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@ public class SpeechTranscribeWordLevelConfidenceBeta {
* import java.nio.file.Paths;
*/

public static void sampleRecognize() {
// TODO(developer): Replace these variables before running the sample.
String localFilePath = "resources/brooklyn_bridge.flac";
sampleRecognize(localFilePath);
}

/**
* Print confidence level for individual words in a transcription of a short audio file.
*
* @param localFilePath Path to local audio file, e.g. /path/audio.wav
*/
public static void sampleRecognize(String localFilePath) {
try (SpeechClient speechClient = SpeechClient.create()) {
// localFilePath = "resources/brooklyn_bridge.flac";

// When enabled, the first result returned by the API will include a list
// of words and the confidence level for each of those words.
Expand Down

0 comments on commit ad7b7a0

Please sign in to comment.