Asynchrone Sprachdatei erstellen

Erstellt eine asynchrone Sprachdatei.

Codebeispiel

C++

Informationen zum Installieren und Verwenden der Clientbibliothek für Speech-to-Text finden Sie unter Speech-to-Text-Clientbibliotheken.

Richten Sie zur Authentifizierung bei Speech-to-Text Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

// Create a Speech client with the default configuration
auto client = speech::SpeechClient(speech::MakeSpeechConnection());
// Parse command line arguments.
auto args = ParseArguments(argc, argv);
auto const file_path = args.path;
speech::v1::LongRunningRecognizeRequest request;
*request.mutable_config() = args.config;

// Pass the Google Cloud Storage URI to the request.
request.mutable_audio()->set_uri(file_path);
// Call LongRunningRecognize(), and then `.get()` to block until the operation
// completes. The client library polls the operation in the background.
auto response = client.LongRunningRecognize(request).get();
// If the response is an error just report it:
if (!response) {
  std::cerr << "Error in LongRunningRecognize: " << response.status() << "\n";
  return 1;
}
// Dump the transcript of all the results.
for (auto const& result : response->results()) {
  for (auto const& alternative : result.alternatives()) {
    std::cout << alternative.confidence() << "\t" << alternative.transcript()
              << "\n";
  }
}

Nächste Schritte

Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.