googlesamples / assistant-sdk-cpp

Example of Google Assistant gRPC in C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

assistant_sdk failed, error: OS Error

sunjunlishi opened this issue · comments

Init ok,and write data ok,but response always "OS Error";Some times ok.
ubuntu

mpChannel->GetState()
when state is GRPC_CHANNEL_IDLE,it is ok.
but when state is GRPC_CHANNEL_READY,the oper result will be bad.

commented

Is there any other information you can provide, such as a way to reproduce this error?

run_assistant.cc

grpc::Status status = stream1->Finish();
if (!status.ok()) {
// Report the RPC failure.
std::cerr << "assistant_sdk failed, error: " <<
status.error_message() << std::endl;
return false;
}****


my use is saving channel state:

	mpChannel = CreateChannel(api_endpoint);
		assistant = std::unique_ptr<EmbeddedAssistant::Stub>(
			EmbeddedAssistant::NewStub(mpChannel));

every time use send and receive:

if (context != NULL)
{
delete context;
context = NULL;
}
context = new grpc::ClientContext;
context->set_fail_fast(false);
context->set_credentials(call_credentials);
stream1 = std::shared_ptr<ClientReaderWriter<ConverseRequest, ConverseResponse>>(std::move(assistant->Converse(context)));

::google::assistant::embedded::v1alpha1::ConverseConfig* converse_config = request1.mutable_config();
converse_config->mutable_audio_in_config()->set_encoding(AudioInConfig::LINEAR16);
converse_config->mutable_audio_in_config()->set_sample_rate_hertz(16000);
converse_config->mutable_audio_out_config()->set_encoding(AudioOutConfig::MP3);
converse_config->mutable_audio_out_config()->set_sample_rate_hertz(16000);

	stream1->Write(request1);
           while (stream1->Read(&response))
	{  
		if ((response.has_error() || response.has_audio_out() ||
			response.event_type() == ConverseResponse_EventType_END_OF_UTTERANCE))
		{
			//printf(" Synchronously stops audio input.");
			//audio_input->Stop();
		}

		if (response.has_audio_out())
		{
		
                      }
             }

it works ok on windows system,but some times error in ubuntu

commented

It looks like you're using an earlier version of the sample, such as using API version v1alpha1. You may want to consider updating to a newer version which uses v1alpha2 and has additional features like text input and output. It may also be slightly more reliable.

I am not familiar with the error that you've been getting.

ok i will have a try