Riconoscimento sincrono di Cloud Storage

Crea uno stub connesso al servizio Speech-to-Text.

Esempio di codice

C++

Per scoprire come installare e utilizzare la libreria client per Speech-to-Text, consulta la sezione Librerie client di Speech-to-Text.

Per autenticarti in Speech-to-Text, configura le Credenziali predefinite dell'applicazione. Per ulteriori informazioni, consulta Configura l'autenticazione per un ambiente di sviluppo locale.

// Create a Speech client with the default configuration
auto client = speech::SpeechClient(speech::MakeSpeechConnection());
// Parse command line arguments.
auto const args = ParseArguments(argc, argv);
speech::v1::RecognizeRequest request;
*request.mutable_config() = args.config;
  // Pass the Google Cloud Storage URI to the request.
  request.mutable_audio()->set_uri(args.path);
// Send audio content using Recognize().
auto response = client.Recognize(request);
if (!response) throw std::move(response).status();
// 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";
  }
}

Passaggi successivi

Per cercare e filtrare gli esempi di codice per altri prodotti Google Cloud , consulta il browser degli esempi diGoogle Cloud .