简体   繁体   中英

Google assistant gRPC call hung

Server doesn't reply when a GRPC call is made to "embeddedassistant.googleapis.com". I see the request being received at google server end when I check the Google API web interface. I set the request with proper configuration (when I set wrong configuration I do get error message from server). Is there anything I'm missing here?

  std::string Converse(const std::string& user) {

   AudioInConfig audio_in_config;
   audio_in_config.set_encoding(google::assistant::embedded::v1alpha1::AudioInConfig_Encoding_FLAC);
   audio_in_config.set_sample_rate_hertz(16000);

   AudioOutConfig audio_out_config;
   audio_out_config.set_encoding(google::assistant::embedded::v1alpha1::AudioOutConfig_Encoding_MP3);
   audio_out_config.set_sample_rate_hertz(16000);
   audio_out_config.set_volume_percentage(50);

   ConverseState converse_state;
   const char * conversation_state = "a";
   converse_state.set_conversation_state(conversation_state);

   ConverseConfig config;
   config.set_allocated_audio_in_config(&audio_in_config);
   config.set_allocated_audio_out_config(&audio_out_config);
   config.set_allocated_converse_state(&converse_state);

   ConverseRequest request;
   request.set_allocated_config(&config);

   ConverseResponse reply;

   ClientContext context;

   auto status = stub_->Converse(&context, request, &reply);

   config.release_audio_in_config();
   config.release_audio_out_config();
   config.release_converse_state();
   request.release_config();
   // Act upon its status.
   if (status.ok()) {
     return reply.result().conversation_state();
   } else {
     std::cout << "Error: " << status.error_code() << ": " << status.error_message()
            << std::endl;
     return "RPC failed";
   }
   return "";
 }

Why have you set the conversation_state to "a". It should be in bytes or empty. You also need to send an audio data captured depending upon the situation. You can do that by including the ALSA sound API in C++ in your code.

The conversation_state value returned in the prior ConverseResponse. Omit (do not set the field) if there was no prior ConverseResponse. If there was a prior ConverseResponse, do not omit this field; doing so will end that conversation (and this new request will start a new conversation).

You can see from here:- https://developers.google.com/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM