How to Use the SDK to Enable Automatic Language Identification in AWS Transcribe Streaming ?

0

As the title suggests, I am trying to use the Python SDK to utilize the Transcribe service. I found that the console allows the use of automatic language identification during streaming, but I can't find any parameter settings to use this feature in the SDK. Is there a way to enable automatic language identification in Transcribe streaming using the SDK?

Below are the parameters I have found:

language_code: str,
media_sample_rate_hz: int,
media_encoding: str,
vocabulary_name: Optional[str] = None,
session_id: Optional[str] = None,
vocab_filter_method: Optional[str] = None,
vocab_filter_name: Optional[str] = None,
show_speaker_label: Optional[bool] = None,
enable_channel_identification: Optional[bool] = None,
number_of_channels: Optional[int] = None,
enable_partial_results_stabilization: Optional[bool] = None,
partial_results_stability: Optional[str] = None,
language_model_name: Optional[str] = None
asked 2 months ago118 views
1 Answer
0

Here's a sample Python script that demonstrates how to enable automatic language identification:

`import boto3 import json import os

Define the required parameters

language_options = ['en-US', 'es-US'] # Define the possible languages you want to identify media_sample_rate_hz = 16000 # Common sample rate for streaming audio media_encoding = 'pcm' # Encoding type for the audio stream

Create a client for the Transcribe service

transcribe_client = boto3.client('transcribe')

Start the transcription stream with automatic language identification enabled

response = transcribe_client.start_stream_transcription( LanguageCode='auto', MediaSampleRateHertz=media_sample_rate_hz, MediaEncoding=media_encoding, IdentifyLanguage=True, # Enable automatic language identification LanguageOptions=language_options, # Provide a list of potential languages VocabularyName=None, SessionId='my-session-id', EnablePartialResultsStabilization=True, PartialResultsStability='medium', ShowSpeakerLabel=False, EnableChannelIdentification=False, NumberOfChannels=1, VocabularyFilterMethod='mask', VocabularyFilterName=None, LanguageModelName=None )

Print the response to check the status of the transcription stream

print(json.dumps(response, indent=4)) `

answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions