File tree 1 file changed +2
-7
lines changed
speech/snippets/src/main/java/com/example/speech
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 {
39
39
try (SpeechClient speechClient = SpeechClient .create ()) {
40
40
41
41
// 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" ;
48
43
49
44
// Builds the sync recognize request
50
45
RecognitionConfig config =
@@ -53,7 +48,7 @@ public static void main(String... args) throws Exception {
53
48
.setSampleRateHertz (16000 )
54
49
.setLanguageCode ("en-US" )
55
50
.build ();
56
- RecognitionAudio audio = RecognitionAudio .newBuilder ().setContent ( audioBytes ).build ();
51
+ RecognitionAudio audio = RecognitionAudio .newBuilder ().setUri ( gcsUri ).build ();
57
52
58
53
// Performs speech recognition on the audio file
59
54
RecognizeResponse response = speechClient .recognize (config , audio );
You can’t perform that action at this time.
0 commit comments