Hello there I am implementing google Assistant SDK in C++ Can you check my 
code please whats wrong
#include <chrono>
#include <iostream>
#include <memory>
#include <random>
#include <string>
#include <thread>
#include <vector>
#include <math.h>
//RTaudio headers
//#include "RtAudio.h"
//#include <cstdlib>
//#include <cstring>
//grpc headers
#include <grpc++/grpc++.h>
#include <grpc++/channel.h>
#include <grpc++/client_context.h>
#include <grpc++/create_channel.h>
#include <grpc++/security/credentials.h>

#include "embedded_assistant.grpc.pb.h"

using grpc::Channel;
using grpc::ClientContext;
using grpc::ClientReader;
using grpc::ClientReaderWriter;
using grpc::ClientWriter;
using grpc::Status;

using google::assistant::embedded::v1alpha1::ConverseConfig;
using google::assistant::embedded::v1alpha1::AudioInConfig;
using google::assistant::embedded::v1alpha1::AudioOutConfig;
using google::assistant::embedded::v1alpha1::ConverseState;
using google::assistant::embedded::v1alpha1::AudioOut;
using google::assistant::embedded::v1alpha1::ConverseResult;
using google::assistant::embedded::v1alpha1::ConverseRequest;
using google::assistant::embedded::v1alpha1::ConverseResponse;
using google::assistant::embedded::v1alpha1::EmbeddedAssistant;
//RTaudio...
//typedef signed short MY_TYPE;
#define FORMAT RTAUDIO_SINT16

AudioInConfig MakeAudioInConfig(){
  AudioInConfig aic;
  aic.set_encoding("LINEAR16");
  aic.set_sample_rate_hertz(16000);
  return aic;
}

//Encoding MakeEncoding(){

//}

AudioOutConfig MakeAudioOutConfig(){
  AudioOutConfig aoc;
  
aoc.set_encoding(google::assistant::embedded::v1alpha1::AudioOutConfig_Encoding_LINEAR16);
  aoc.set_sample_rate_hertz(16000);
  aoc.set_volume_percentage(100);
  return aoc;
}

ConverseConfig MakeConverseConfig(){
  ConverseConfig cc;
  cc.mutable_audio_in_config()->CopyFrom(MakeAudioInConfig());
  cc.mutable_audio_out_config()->CopyFrom(MakeAudioOutConfig());
  //cc.mutable_converse_state()->CopyFrom();
  return cc;
}

//ConverseState MakeConverseState(void *conversation_state){
//  ConverseState cs;
//}



//ConverseResult MakeConverseResult(){

//}

//auto creds = grpc::GoogleDefaultCredentials();
// Create a channel, stub and make RPC calls (same as in the previous 
example)
//auto channel = grpc::CreateChannel("embeddedassistant.googleapis.com", 
creds);
  //auto channel = 
grpc::CreateChannel("embeddedassistant.googleapis.com",grpc::GoogleDefaultCredentials());
class EmbeddedAssistantClient {
 public:

  EmbeddedAssistantClient(std::shared_ptr<Channel> channel) : 
stub_(EmbeddedAssistant::NewStub(channel)) {}

  
 void Converse() {
   ClientContext context;
 
 std::shared_ptr<ClientReaderWriter<ConverseRequest, ConverseResponse> > 
stream(stub_->Converse(&context));
 std::cout << "Got message " << std::endl;
 std::thread writer([stream]() {
   stream->Write(ConverseConfig& MakeCOnverseConfig());
   stream->WritesDone();
 });

     ConverseResponse converse_response;
     while (stream->Read(&converse_response)) {
       std::cout << "Got message " << std::endl;
     }
     writer.join();
     Status status = stream->Finish();
     if (!status.ok()) {
       std::cout << "RouteChat rpc failed." << std::endl;
     }

 }
 std::unique_ptr<EmbeddedAssistant::Stub> stub_;
};



int main(int argc, char** argv) {
  // Instantiate the client. It requires a channel.
  //auto creds = grpc::GoogleDefaultCredentials();

  EmbeddedAssistantClient 
embeddedassistant(grpc::CreateChannel("embeddedassistant.googleapis.com", 
grpc::GoogleDefaultCredentials()));
  
  std::cout << "Conversation started!: " << std::endl;
  embeddedassistant.Converse(); 
  return 0;
}

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to