This repository was archived by the owner on Dec 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed
samples/snippets/src/main/java/com/example/speech Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change @@ -39,12 +39,7 @@ public static void main(String... args) throws Exception {
3939 try (SpeechClient speechClient = SpeechClient .create ()) {
4040
4141 // The path to the audio file to transcribe
42- String fileName = "./resources/audio.raw" ;
43-
44- // Reads the audio file into memory
45- Path path = Paths .get (fileName );
46- byte [] data = Files .readAllBytes (path );
47- ByteString audioBytes = ByteString .copyFrom (data );
42+ String gcsUri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw" ;
4843
4944 // Builds the sync recognize request
5045 RecognitionConfig config =
@@ -53,7 +48,7 @@ public static void main(String... args) throws Exception {
5348 .setSampleRateHertz (16000 )
5449 .setLanguageCode ("en-US" )
5550 .build ();
56- RecognitionAudio audio = RecognitionAudio .newBuilder ().setContent ( audioBytes ).build ();
51+ RecognitionAudio audio = RecognitionAudio .newBuilder ().setUri ( gcsUri ).build ();
5752
5853 // Performs speech recognition on the audio file
5954 RecognizeResponse response = speechClient .recognize (config , audio );
You can’t perform that action at this time.
0 commit comments