비동기 음성 파일 만들기

비동기 음성 파일을 만듭니다.

코드 샘플

C++

Speech-to-Text용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Speech-to-Text 클라이언트 라이브러리를 참조하세요.

Speech-to-Text에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저 참조하기