Hey All,

I am using C++ to communicate with google speech api server.

I am using the usual approach of setting a deadline for the clientcontext 
to handle timeout functionality.

I have put the *deadlines *like:
void SetContextDeadline(grpc::ClientContext *context, unsigned int 
user_defined_deadline){
context->set_deadline(std::chrono::system_clock::now() + 
std::chrono::seconds(user_defined_deadline));
}

Now, this function is called whenever I want to set the deadline *from 
now(time)*

*int main(){*
  auto creds = grpc::GoogleDefaultCredentials();
  auto channel = grpc::CreateChannel("speech.googleapis.com", creds);
  std::unique_ptr<Speech::Stub> speech(Speech::NewStub(channel));

  grpc::ClientContext context;

// Set timeout of 8 seconds => also this is the timeout which I am not able 
to cancel to set new timer
// Whenever it ends (after 8 seconds) my program is terminated
  SetContextDeadline(&context,8);
  auto streamer = speech->StreamingRecognize(&context);

 // The microphone thread writes the audio content.
  std::thread microphone_thread(&MicrophoneThreadMain, streamer.get(),
                                file_path);
// Read responses.
  StreamingRecognizeResponse response;
  while (streamer->Read(&response)) {  // Returns false when no more to 
read.
    // Now I want to cancel the previous deadline to set this new deadline, 
everytime I enter this loop
    // I am seeing that this is setting the new deadline but the program 
still terminates at the older timeout
    SetContextDeadline(&context,8);

    // Dump the transcript of all the results.
    // Implementation of response display     
  }
}



Thanks in advance for your help


-- 
Matrix Comsec Pvt. Ltd.
#394, GIDC Makarpura - 390010. Dist: Vadodara, 
Gujarat, India
 <http://bit.ly/comsec-esignature>

IP Video Surveillance |  
<http://bit.ly/IPVS-esginature>People Mobility Management |  
<http://bit.ly/cosec-esignature>Unified Communications 
<http://bit.ly/telecom-esignature>
1 Million+ Customers | 2,500+ Partners | 
60+ Products | 50+ Countries
We put more in the box, so your business can 
think more out of the box.
 <https://www.facebook.com/matrixcomsec> 
<http://www.linkedin.com/in/matrixcomsec> 
<https://twitter.com/Matrix_ComSec> 
<https://www.linkedin.com/company/matrix-telecom-solutions/> 
<https://www.youtube.com/user/MatrixComSec>



-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/d8e3fbb2-ef13-4c97-8ed3-57c1c58486c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to