Skip to content

Commit 20e6b88

Browse files
committed
made sync work
Author: puneith <puneith@google.com>
1 parent ed629b6 commit 20e6b88

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

speech/grpc/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ or [homebrew](http://brew.sh/)) to convert audio files to raw format.
7878
You can run the batch client like this:
7979

8080
```sh
81-
$ bin/speech-sample-nonstreaming.sh --host=speech.googleapis.com --port=443 \
82-
--file=<audio file path> --sampling=<sample rate>
81+
$ bin/speech-sample-sync.sh --host=speech.googleapis.com --port=443 \
82+
--uri=<audio file uri> --sampling=<sample rate>
8383
```
8484

8585
Try a streaming rate of 16000 and the included sample audio file, as follows:
8686

8787
```sh
88-
$ bin/speech-sample-nonstreaming.sh --host=speech.googleapis.com --port=443 \
89-
--file=resources/audio.raw --sampling=16000
88+
$ bin/speech-sample-sync.sh --host=speech.googleapis.com --port=443 \
89+
--uri=resources/audio.raw --sampling=16000
9090
```
9191

9292
### Run the streaming client

speech/grpc/src/main/java/com/google/cloud/speech/grpc/demos/RecognitionAudioFactory.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.cloud.speech.v1beta1.RecognitionAudio;
2121
import com.google.protobuf.ByteString;
2222

23+
import java.io.File;
2324
import java.io.IOException;
2425
import java.net.URI;
2526
import java.nio.file.Files;
@@ -43,7 +44,11 @@ public class RecognitionAudioFactory {
4344
*/
4445
public static RecognitionAudio createRecognitionAudio(URI uri)
4546
throws IOException {
46-
if (uri.getScheme() == null || uri.getScheme().equals(FILE_SCHEME)) {
47+
if (uri.getScheme() == null) {
48+
uri = new File(uri.toString()).toURI();
49+
Path path = Paths.get(uri);
50+
return audioFromBytes(Files.readAllBytes(path));
51+
} else if (uri.getScheme().equals(FILE_SCHEME)) {
4752
Path path = Paths.get(uri);
4853
return audioFromBytes(Files.readAllBytes(path));
4954
} else if (uri.getScheme().equals(GS_SCHEME)) {

0 commit comments

Comments
 (0)