Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speech api changes #264

Closed
wants to merge 14 commits into from
Prev Previous commit
Next Next commit
made sync work
  • Loading branch information
puneith committed Jul 4, 2016
commit a7da37b409e011e4acc73d9dd02f6e06f8d0241a
8 changes: 4 additions & 4 deletions speech/grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ or [homebrew](http://brew.sh/)) to convert audio files to raw format.
You can run the batch client like this:

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

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

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

### Run the streaming client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.cloud.speech.v1beta1.RecognitionAudio;
import com.google.protobuf.ByteString;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
Expand All @@ -43,7 +44,11 @@ public class RecognitionAudioFactory {
*/
public static RecognitionAudio createRecognitionAudio(URI uri)
throws IOException {
if (uri.getScheme() == null || uri.getScheme().equals(FILE_SCHEME)) {
if (uri.getScheme() == null) {
uri = new File(uri.toString()).toURI();
Path path = Paths.get(uri);
return audioFromBytes(Files.readAllBytes(path));
} else if (uri.getScheme().equals(FILE_SCHEME)) {
Path path = Paths.get(uri);
return audioFromBytes(Files.readAllBytes(path));
} else if (uri.getScheme().equals(GS_SCHEME)) {
Expand Down