Skip to content

Commit

Permalink
samples: Speech region tag update (#1188)
Browse files Browse the repository at this point in the history
  • Loading branch information
alixhami authored and chingor13 committed Aug 15, 2020
1 parent fc65abd commit 1918b1e
Showing 1 changed file with 40 additions and 28 deletions.
68 changes: 40 additions & 28 deletions speech/snippets/src/main/java/com/example/speech/Recognize.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public static void main(String... args) throws Exception {
}
}

// [START speech_transcribe_sync]
/**
* Performs speech recognition on raw PCM audio and prints the transcription.
*
Expand Down Expand Up @@ -178,6 +179,7 @@ public static void syncRecognizeFile(String fileName) throws Exception {
}
}
}
// [END speech_transcribe_sync]

/**
* Performs sync recognize and prints word time offsets.
Expand Down Expand Up @@ -222,6 +224,7 @@ public static void syncRecognizeWords(String fileName) throws Exception {
}
}

// [START speech_transcribe_sync_gcs]
/**
* Performs speech recognition on remote FLAC file and prints the transcription.
*
Expand Down Expand Up @@ -251,7 +254,9 @@ public static void syncRecognizeGcs(String gcsUri) throws Exception {
}
}
}
// [END speech_transcribe_sync_gcs]

// [START speech_transcribe_async]
/**
* Performs non-blocking speech recognition on raw PCM audio and prints the transcription. Note
* that transcription is limited to 60 seconds audio.
Expand Down Expand Up @@ -294,7 +299,9 @@ public static void asyncRecognizeFile(String fileName) throws Exception {
}
}
}
// [END speech_transcribe_async]

// [START speech_transcribe_async_time_offsets_gcs]
/**
* Performs non-blocking speech recognition on remote FLAC file and prints the transcription as
* well as word time offsets.
Expand Down Expand Up @@ -342,7 +349,9 @@ public static void asyncRecognizeWords(String gcsUri) throws Exception {
}
}
}
// [END speech_transcribe_async_time_offsets_gcs]

// [START speech_transcribe_async_gcs]
/**
* Performs non-blocking speech recognition on remote FLAC file and prints the transcription.
*
Expand Down Expand Up @@ -379,7 +388,9 @@ public static void asyncRecognizeGcs(String gcsUri) throws Exception {
}
}
}
// [END speech_transcribe_async_gcs]

// [START speech_transcribe_streaming]
/**
* Performs streaming speech recognition on raw PCM audio data.
*
Expand Down Expand Up @@ -464,8 +475,9 @@ public SettableFuture<List<T>> future() {
}
}
}
// [END speech_transcribe_streaming]

// [START speech_transcribe_model_selection]
// [START speech_transcribe_model_selection_beta]
/**
* Performs transcription of the given audio file synchronously with the selected model.
*
Expand Down Expand Up @@ -499,10 +511,10 @@ public static void transcribeModelSelection(String fileName) throws Exception {
SpeechRecognitionAlternative alternative = result.getAlternativesList().get(0);
System.out.printf("Transcript : %s\n", alternative.getTranscript());
}
// [END speech_transcribe_model_selection]
// [END speech_transcribe_model_selection_beta]
}

// [START speech_transcribe_model_selection_gcs]
// [START speech_transcribe_model_selection_gcs_beta]
/**
* Performs transcription of the remote audio file asynchronously with the selected model.
*
Expand Down Expand Up @@ -543,7 +555,7 @@ public static void transcribeModelSelectionGcs(String gcsUri) throws Exception {
SpeechRecognitionAlternative alternative = result.getAlternativesList().get(0);
System.out.printf("Transcript : %s\n", alternative.getTranscript());
}
// [END speech_transcribe_model_selection_gcs]
// [END speech_transcribe_model_selection_gcs_beta]
}

// [START speech_sync_recognize_punctuation]
Expand Down Expand Up @@ -586,7 +598,7 @@ public static void transcribeFileWithAutomaticPunctuation(String fileName) throw
}
// [END speech_sync_recognize_punctuation]

// [START speech_async_recognize_gcs_punctuation]
// [START speech_transcribe_auto_punctuation_beta]
/**
* Performs transcription on remote FLAC file and prints the transcription.
*
Expand Down Expand Up @@ -626,7 +638,7 @@ public static void transcribeGcsWithAutomaticPunctuation(String gcsUri) throws E
System.out.printf("Transcript : %s\n", alternative.getTranscript());
}
}
// [END speech_async_recognize_gcs_punctuation]
// [END speech_transcribe_auto_punctuation_beta]

// [START speech_stream_recognize_punctuation]
/**
Expand Down Expand Up @@ -717,7 +729,7 @@ public SettableFuture<List<T>> future() {
}
// [END speech_stream_recognize_punctuation]

// [START speech_streaming_mic_recognize]
// [START speech_transcribe_streaming_mic]
/** Performs microphone streaming speech recognition with a duration of 1 minute. */
public static void streamingMicRecognize() throws Exception {

Expand Down Expand Up @@ -806,9 +818,9 @@ public void onError(Throwable t) {
}
responseObserver.onComplete();
}
// [END speech_streaming_mic_recognize]
// [END speech_transcribe_streaming_mic]

// [START speech_transcribe_file_with_enhanced_model]
// [START speech_transcribe_enhanced_model_beta]
/**
* Transcribe the given audio file using an enhanced model.
*
Expand Down Expand Up @@ -848,9 +860,9 @@ public static void transcribeFileWithEnhancedModel(String fileName) throws Excep
}
}
}
// [END speech_transcribe_file_with_enhanced_model]
// [END speech_transcribe_enhanced_model_beta]

// [START speech_transcribe_file_with_metadata]
// [START speech_transcribe_recognition_metadata_beta]
/**
* Transcribe the given audio file and include recognition metadata in the request.
*
Expand Down Expand Up @@ -900,9 +912,9 @@ public static void transcribeFileWithMetadata(String fileName) throws Exception
}
}
}
// [END speech_transcribe_file_with_metadata]
// [END speech_transcribe_recognition_metadata_beta]

// [START speech_transcribe_diarization]
// [START speech_transcribe_diarization_beta]
/**
* Transcribe the given audio file using speaker diarization.
*
Expand Down Expand Up @@ -945,9 +957,9 @@ public static void transcribeDiarization(String fileName) throws Exception {
}
}
}
// [END speech_transcribe_diarization]
// [END speech_transcribe_diarization_beta]

// [START speech_transcribe_diarization_gcs]
// [START speech_transcribe_diarization_gcs_beta]
/**
* Transcribe a remote audio file using speaker diarization.
*
Expand Down Expand Up @@ -991,9 +1003,9 @@ public static void transcribeDiarizationGcs(String gcsUri) throws Exception {
}
}

// [END speech_transcribe_diarization_gcs]
// [END speech_transcribe_diarization_gcs_beta]

// [START speech_transcribe_multichannel]
// [START speech_transcribe_multichannel_beta]

/**
* Transcribe a local audio file with multi-channel recognition
Expand Down Expand Up @@ -1032,9 +1044,9 @@ public static void transcribeMultiChannel(String fileName) throws Exception {
}
}
}
// [END speech_transcribe_multichannel]
// [END speech_transcribe_multichannel_beta]

// [START speech_transcribe_multichannel_gcs]
// [START speech_transcribe_multichannel_gcs_beta]

/**
* Transcribe a remote audio file with multi-channel recognition
Expand Down Expand Up @@ -1079,9 +1091,9 @@ public static void transcribeMultiChannelGcs(String gcsUri) throws Exception {
}
}
}
// [END speech_transcribe_multichannel_gcs]
// [END speech_transcribe_multichannel_gcs_beta]

// [START speech_transcribe_multilang]
// [START speech_transcribe_multilanguage_beta]

/**
* Transcribe a local audio file with multi-language recognition
Expand Down Expand Up @@ -1121,9 +1133,9 @@ public static void transcribeMultiLanguage(String fileName) throws Exception {
}
}
}
// [END speech_transcribe_multilang]
// [END speech_transcribe_multilanguage_beta]

// [START speech_transcribe_multilang_gcs]
// [START speech_transcribe_multilanguage_gcs_beta]

/**
* Transcribe a remote audio file with multi-language recognition
Expand Down Expand Up @@ -1169,9 +1181,9 @@ public static void transcribeMultiLanguageGcs(String gcsUri) throws Exception {
}
}
}
// [END speech_transcribe_multilang_gcs]
// [END speech_transcribe_multilanguage_gcs_beta]

// [START speech_transcribe_word_level_confidence]
// [START speech_transcribe_word_level_confidence_beta]

/**
* Transcribe a local audio file with word level confidence
Expand Down Expand Up @@ -1208,9 +1220,9 @@ public static void transcribeWordLevelConfidence(String fileName) throws Excepti
}
}
}
// [END speech_transcribe_word_level_confidence]
// [END speech_transcribe_word_level_confidence_beta]

// [START speech_transcribe_word_level_confidence_gcs]
// [START speech_transcribe_word_level_confidence_gcs_beta]

/**
* Transcribe a remote audio file with word level confidence
Expand Down Expand Up @@ -1253,5 +1265,5 @@ public static void transcribeWordLevelConfidenceGcs(String gcsUri) throws Except
alternative.getWords(0).getWord(), alternative.getWords(0).getConfidence());
}
}
// [END speech_transcribe_word_level_confidence_gcs]
// [END speech_transcribe_word_level_confidence_gcs_beta]
}

0 comments on commit 1918b1e

Please sign in to comment.