이 페이지에서는 Speech-to-Text V2 API를 사용하여 오디오 파일에서 자막을 SRT 및 VTT 형식으로 자동 생성하는 방법을 설명합니다.
개요
Speech-to-Text V2 API 기능을 사용하여 정확한 자막을 SubRip(.srt) 및 WebVTT(.vtt) 형식으로 자동 생성할 수 있습니다. 이러한 형식은 오디오의 텍스트 및 타이밍 정보를 저장하는 데 사용되며 자막 표시와 자막 방송을 위해 미디어와 동기화된 자막을 표시할 수 있습니다.
V2 API에서만 Google Speech-to-Text로 보낸 요청에서 자막 출력을 사용 설정할 수 있습니다. 특히 BatchRecognize만 사용하여 긴 오디오 파일을 텍스트로 변환할 수 있습니다. 출력을 Cloud Storage 버킷에 저장하거나 인라인으로 반환할 수 있습니다.
Cloud Storage 출력 구성에 여러 형식을 동시에 지정할 수 있으며 이 구성은 서로 다른 파일 확장자로 지정된 버킷에 작성됩니다.
요청에 자막 출력 사용 설정
Google Speech-to-Text를 사용하여 오디오의 SRT 또는 VTT 자막 출력을 생성하려면 다음 단계를 수행하여 스크립트 작성 요청에서 자막 출력을 사용 설정합니다.
output_format_config 필드를 채워서 Speech-to-Text V2 API BatchRecognize 메서드에 요청을 보냅니다. 지정된 값은 다음과 같습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-09(UTC)"],[],[],null,["# Generate WebVTT and SRT captions\n\nThis page describes how to use Speech-to-Text V2 API to automatically generate captions from audio files, in SRT and VTT formats.\n\nOverview\n--------\n\nYou can use the power of Speech-to-Text V2 API to automatically generate accurate captions in both SubRip (.srt) and WebVTT (.vtt) formats. These formats are used to store the text and timing information of audio, making it possible to display subtitles or captions in sync with the media for subtitling and closed captioning.\n\nEnabling caption outputs in your request to Google Speech-to-Text is only supported in the V2 API. Specifically, you can only use `BatchRecognize` to transcribe long audio files. You can save outputs in a Cloud Storage bucket, or they can be returned inline.\nMultiple formats can be specified at the same time for the Cloud Storage output configuration, which is written to the specified bucket with different file extensions.\n\nEnable caption outputs in a request\n-----------------------------------\n\nTo generate SRT or VTT caption outputs for your audio using Google Speech-to-Text, follow the next steps to enable caption outputs in your transcription request:\n\n1. Make a request to the Speech-to-Text V2 API `BatchRecognize` method with the `output_format_config` field populated. Values specified are:\n - `srt`, for the output to follow the [SubRip(.srt) format](https://www.matroska.org/technical/subtitles.html#srt-subtitles).\n - `vtt`, for the output to follow the [WebVTT(.vtt) format](https://www.w3.org/TR/webvtt1/).\n - `native`, which is the default output format if no format is specified as a serialized `BatchRecognizeResults` request.\n2. Since the operation is async, poll the request until it's complete.\n\nMultiple formats can be specified at the same time for the Cloud Storage output configuration. They're written to the specified bucket with different file extensions. Those are `.json` for native, `.srt` for SRT, and `.vtt` for WebVTT support, respectively.\n\nIf multiple formats are specified for the inline output config, each format will be available as a field in the BatchRecognizeFileResult.inline_result message.\n\nThe following code snippet demonstrates how to enable caption outputs in a transcription request to Speech-to-Text using local and remote files: \n\n### API\n\n curl -X POST \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -H \"Authorization: Bearer $(gcloud auth application-default print-access-token)\" \\\n https://speech.googleapis.com/v2/projects/my-project/locations/global/recognizers/_:batchRecognize \\\n --data '{\n \"files\": [{\n \"uri\": \"gs://my-bucket/jfk_and_the_press.wav\"\n }],\n \"config\": {\n \"features\": { \"enableWordTimeOffsets\": true },\n \"autoDecodingConfig\": {},\n \"model\": \"long\",\n \"languageCodes\": [\"en-US\"]\n },\n \"recognitionOutputConfig\": {\n \"gcsOutputConfig\": { \"uri\": \"gs://my-bucket\" },\n \"output_format_config\": { \"srt\": {} }\n }\n }'\n\nWhat's next\n-----------\n\n- Learn how to [transcribe long audio files](/speech-to-text/v2/docs/batch-recognize).\n- Learn how to [choose the best transcription model.](./transcription-model)\n- Transcribe audio files using [Chirp](/speech-to-text/v2/docs/chirp-model).\n- For best performance, accuracy, and other tips, see the [best practices](/speech-to-text/v2/docs/best-practices) documentation."]]