| 24 | )"""; |
| 25 | |
| 26 | int main(int argc, char** argv) try { |
| 27 | // [START speech_async_recognize_gcs] |
| 28 | // Create a Speech client with the default configuration |
| 29 | auto client = speech::SpeechClient(speech::MakeSpeechConnection()); |
| 30 | // Parse command line arguments. |
| 31 | auto args = ParseArguments(argc, argv); |
| 32 | auto const file_path = args.path; |
| 33 | speech::v1::LongRunningRecognizeRequest request; |
| 34 | *request.mutable_config() = args.config; |
| 35 | |
| 36 | // Pass the Google Cloud Storage URI to the request. |
| 37 | request.mutable_audio()->set_uri(file_path); |
| 38 | // Call LongRunningRecognize(), and then `.get()` to block until the operation |
| 39 | // completes. The client library polls the operation in the background. |
| 40 | auto response = client.LongRunningRecognize(request).get(); |
| 41 | // If the response is an error just report it: |
| 42 | if (!response) { |
| 43 | std::cerr << "Error in LongRunningRecognize: " << response.status() << "\n"; |
| 44 | return 1; |
| 45 | } |
| 46 | // Dump the transcript of all the results. |
| 47 | for (auto const& result : response->results()) { |
| 48 | for (auto const& alternative : result.alternatives()) { |
| 49 | std::cout << alternative.confidence() << "\t" << alternative.transcript() |
| 50 | << "\n"; |
| 51 | } |
| 52 | } |
| 53 | // [END speech_async_recognize_gcs] |
| 54 | return 0; |
| 55 | } catch (std::exception const& ex) { |
| 56 | std::cerr << "Standard C++ exception thrown: " << ex.what() << "\n" |
| 57 | << kUsage << "\n"; |
| 58 | return 1; |
| 59 | } |
nothing calls this directly
no test coverage detected