MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/cpp-samples / main

Function main

speech/api/streaming_transcribe_singlethread.cc:154–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152};
153
154int main(int argc, char** argv) try {
155 // Create a CompletionQueue to demux the I/O and other asynchronous
156 // operations, and dedicate a thread to it.
157 g::CompletionQueue cq;
158 auto runner = std::thread{[](auto cq) { cq.Run(); }, cq};
159 // Shutdown the completion queue and join the thread.
160 std::shared_ptr<void> auto_shutdown(nullptr, [&](void*) {
161 cq.Shutdown();
162 runner.join();
163 });
164
165 // Create a Speech client with the default configuration.
166 auto client = speech::SpeechClient(speech::MakeSpeechConnection(
167 g::Options{}.set<g::GrpcCompletionQueueOption>(cq)));
168
169 // Create a handler for the stream and run it until closed.
170 auto handler = Handler::Create(cq, ParseArguments(argc, argv));
171 auto status = handler->Start(client).get();
172
173 if (!status.ok()) {
174 std::cerr << "Error in transcribe stream: " << status << "\n";
175 return 1;
176 }
177 return 0;
178} catch (std::exception const& ex) {
179 std::cerr << "Standard C++ exception thrown: " << ex.what() << "\n"
180 << kUsage << "\n";
181 return 1;
182}

Callers

nothing calls this directly

Calls 2

ParseArgumentsFunction · 0.70
StartMethod · 0.45

Tested by

no test coverage detected