How to use Google Cloud Speech v1 on Android? -


i updated android google cloud speech code v1beta1 v1. there couple of changes in api, 1 of them new method called getwordslist().

i want use getwordslist() in android project, method doesn't seem visible code:

import com.google.cloud.speech.v1.speechgrpc; import com.google.cloud.speech.v1.speechrecognitionalternative; import com.google.cloud.speech.v1.streamingrecognizeresponse; import com.google.cloud.speech.v1.wordinfo;  ...  public void onnext(streamingrecognizeresponse response) {   int numofresults = response.getresultscount();   if( numofresults > 0 ){     (int i=0;i<numofresults;i++){       streamingrecognitionresult result = response.getresultslist().get(i);       speechrecognitionalternative alternative = result.getalternativeslist().get(0);       (wordinfo wordinfo: alternative.getwordslist()) { //-->>cannot resolve 'method'         system.out.println(wordinfo.getword());         system.out.println(wordinfo.getstarttime().getseconds() + " ");       }       ... 

this code official repo, however, getting following error:

cannot resolve method 'getwordslist()'

here gradle:

apply plugin: 'com.android.application' apply plugin: 'com.google.protobuf'  android {     compilesdkversion 25     buildtoolsversion "25.0.0"     defaultconfig {         applicationid "org.test.test"         minsdkversion 24         targetsdkversion 24         versioncode 1         versionname "1.0"         testinstrumentationrunner "android.support.test.runner.androidjunitrunner"          // enabling multidex support.         multidexenabled true     }     buildtypes {         release {             minifyenabled false             proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'         }     } }  protobuf {     protoc {         artifact = 'com.google.protobuf:protoc:3.0.0'     }     plugins {         grpc {             artifact = 'io.grpc:protoc-gen-grpc-java:1.0.0'         }         javalite {             artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'         }     }     generateprototasks {         all().each {             task ->                 task.builtins {                     remove javanano                     java {                     }                 }                 task.plugins {                     grpc {                     }                 }         }     } }  ext {     supportlibraryversion = '25.0.0'     grpcversion = '1.4.0' }  dependencies {     // generic dependencies     compile filetree(include: ['*.jar'], dir: 'libs')     testcompile 'junit:junit:4.12'     compile 'com.google.cloud:google-cloud-speech:0.23.1-alpha'      // support libraries     compile "com.android.support:appcompat-v7:$supportlibraryversion"     compile "com.android.support:design:$supportlibraryversion"     compile "com.android.support:cardview-v7:$supportlibraryversion"     compile "com.android.support:recyclerview-v7:$supportlibraryversion"     compile 'com.android.support:multidex:1.0.1'      // grpc     compile 'javax.annotation:javax.annotation-api:1.2'     compile("io.grpc:grpc-protobuf:${grpcversion}") {         exclude module: 'jsr305'     }     compile("io.grpc:grpc-stub:${grpcversion}") {         exclude module: 'jsr305'     }     compile("io.grpc:grpc-auth:${grpcversion}") {         exclude module: 'jsr305'     }     compile("io.grpc:grpc-okhttp:${grpcversion}") {         exclude module: 'jsr305'     }     // oauth2 google api     compile('com.google.auth:google-auth-library-oauth2-http:0.3.0') {         exclude module: 'jsr305'         exclude module: 'httpclient'     }  } 

i noticed, cannot use grpc libraries, example following library cannot imported:

import com.google.api.gax.rpc.streamingcallable; 

how can use getwordslist() correctly in android? not using correct build version?

i use instead of getwordlist():

final speechrecognitionalternative alternative = result.getalternatives(0); text = alternative.gettranscript(); 

hope works.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -