GoogleCloudPlatform / android-docs-samples

Apache License 2.0
375 stars 596 forks source link

How to implement Getting Punctuation ? #74

Closed ardakayaa closed 5 years ago

ardakayaa commented 5 years ago

Hello,

I am trying to implement new Google Speech to Text feature Getting Punctuation. But I couldn t find out how to update library in Android Studio or any google documentation about it. Is there any one achieved that or any one can point me a direction ?

https://cloud.google.com/speech-to-text/docs/automatic-punctuation .setEnableAutomaticPunctuation(true) ---> In google doc in the link above says I need to add this line but there is no such a param in android-docs-samples.

Thanks, Arda Kaya

camaronc commented 5 years ago

The android example is using the v1 proto files which don't have the option for the automatic punctuation. If you want to add support for that you would need to switch over to a more recent proto file like the v1p1beta1. I haven't tested it too throughly, but the example code works if you delete the proto/google/speech/v1 folder and replace it with the v1p1beta1 folder and update your imports. The RecognitionConfig builder should then have the new options for punctuation.

ardakayaa commented 5 years ago

As you said I deleted v1 and put v1p1beta1 . I can see now .setEnableAutomaticPunctuation(true) , but still there is no punctuation. Also there is importing problem in new cloud.speech.proto . screen shot 2018-07-18 at 11 31 00

camaronc commented 5 years ago

The import errors aren't really problems as far as I can tell the v1 proto file uses the same imports and the app compiles and runs fine its probably just complaining about being in the java file structure. But when it comes to the automatic punctuation I don't really know whats going on I used the v1p1beta1 to get the enhanced models and speaker counts.

farhanarrafi commented 5 years ago

Hello, I added the following lines inside "RecognitionConfig" block in proto: message RecognitionConfig { ... bool enable_automatic_punctuation = 9; }

I have made the following modifications in "Speech" service block: rpc Recognize(RecognizeRequest) returns (RecognizeResponse) { option (google.api.http) = { post: "/v1p1beta1/speech:recognize" body: "*" }; } and rpc LongRunningRecognize(LongRunningRecognizeRequest) returns (google.longrunning.Operation) { option (google.api.http) = { post: "/v1p1beta1/speech:longrunningrecognize" body: "*" }; }

After building project I can use the method: setEnableAutomaticPunctuation(true) But I am not getting back any punctuation in either result or alternative results.

farhanarrafi commented 5 years ago

Hello, I added the following lines inside "RecognitionConfig" block in proto: message RecognitionConfig { ... bool enable_automatic_punctuation = 9; }

I have made the following modifications in "Speech" service block: rpc Recognize(RecognizeRequest) returns (RecognizeResponse) { option (google.api.http) = { post: "/v1p1beta1/speech:recognize" body: "*" }; } and rpc LongRunningRecognize(LongRunningRecognizeRequest) returns (google.longrunning.Operation) { option (google.api.http) = { post: "/v1p1beta1/speech:longrunningrecognize" body: "*" }; }

After building project I can use the method: setEnableAutomaticPunctuation(true) But I am not getting back any punctuation in either result or alternative results.

I have successfully integrated auto punctuation. Thanks for the help @camaronc .