googlesamples / assistant-sdk-cpp

Example of Google Assistant gRPC in C++
Apache License 2.0
96 stars 45 forks source link

assistant_sdk failed, error: OS Error #23

Open sunjunlishi opened 6 years ago

sunjunlishi commented 6 years ago

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

sunjunlishi commented 6 years ago

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

Fleker commented 6 years ago

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

sunjunlishi commented 6 years ago

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; }****

sunjunlishi commented 6 years ago

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

Fleker commented 6 years ago

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.

sunjunlishi commented 6 years ago

ok i will have a try