0

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 "";
 }
Vamsi
  • 35
  • 1
  • 1
  • 7
  • Did you take a look at this bi-directionally streaming gRPC example: https://github.com/grpc/grpc/blob/v1.3.2/examples/cpp/route_guide/route_guide_client.cc#L169, it's for a different API but it can help you to figure out the control flow. – proppy Jun 07 '17 at 18:28

1 Answers1

0

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