Mengenali Cloud Storage secara sinkron

Membuat stub yang terhubung ke layanan Speech-to-Text.

Contoh kode

C++

Untuk mempelajari cara menginstal dan menggunakan library klien untuk Speech-to-Text, lihat Library klien Speech-to-Text.

Untuk mengautentikasi ke Speech-to-Text, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

// 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";
  }
}

Langkah berikutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat Google Cloud browser contoh.