123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- type: com.google.api.codegen.samplegen.v1p2.SampleConfigProto
- schema_version: 1.2.0
- samples:
- - region_tag: speech_transcribe_diarization_beta
- title: Separating different speakers (Local File) (LRO) (Beta)
- description: |
- Print confidence level for individual words in a transcription of a short audio file
- Separating different speakers in an audio file recording
- rpc: LongRunningRecognize
- service: google.cloud.speech.v1p1beta1.Speech
- request:
- - field: audio.content
- value: "resources/commercial_mono.wav"
- input_parameter: local_file_path
- comment: Path to local audio file, e.g. /path/audio.wav
- value_is_file: true
- - field: config.enable_speaker_diarization
- value: true
- comment: |
- If enabled, each word in the first alternative of each result will be
- tagged with a speaker tag to identify the speaker.
- - field: config.diarization_speaker_count
- value: 2
- comment: Optional. Specifies the estimated number of speakers in the conversation.
- - field: config.language_code
- value: "en-US"
- comment: The language of the supplied audio
- response:
- - loop:
- collection: $resp.results
- variable: result
- body:
- - comment:
- - First alternative has words tagged with speakers
- - define: alternative = result.alternatives[0]
- - print:
- - "Transcript: %s"
- - alternative.transcript
- - comment:
- - Print the %s of each word
- - speaker_tag
- - loop:
- collection: alternative.words
- variable: word
- body:
- - print:
- - 'Word: %s'
- - word.word
- - print:
- - 'Speaker tag: %s'
- - word.speaker_tag
|