aws_transcribe_streaming

Creator: coderz1093

Last updated:

0 purchases

aws_transcribe_streaming Image
aws_transcribe_streaming Images

Languages

Categories

Add to Cart

Description:

aws transcribe streaming

AWS Transcribe Streaming client for producing real-time transcriptions for your media content using HTTP/2.
Getting started #
Add necessary dependencies to pubspec.yaml:
dependencies:
aws_common: ^0.6.0
aws_transcribe_streaming: ^0.1.0
copied to clipboard
Obtain a pair of Access/Secret keys for the AWS IAM user with transcribe:StartStreamTranscription permission.
See details in AWS documentation: Transcribing streaming audio
It is recommended to use Temporary security credentials with session token obtained from the backend just before starting the transcribing process.
See also best practices to improve streaming transcription efficiency.
Usage #

Create a new transcribe streaming client:

import 'package:aws_common/aws_common.dart';
import 'package:aws_transcribe_streaming/aws_transcribe_streaming.dart';

final transcribeStreamingClient = TranscribeStreamingClient(
region: 'eu-central-1',
credentialsProvider: StaticCredentialsProvider(AWSCredentials(
'ASIAIOEXAMPLEEXAMPLE', // accessKeyId
'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', // secretAccessKey
'AQoDYXdzEJr...', // sessionToken
DateTime.now().add(const Duration(hours: 1)), // expiration
)),
);
copied to clipboard

Start a stream transcription:

final (response, audioStreamSink, transcriptEventStream) =
await transcribeStreamingClient.startStreamTranscription(
const StartStreamTranscriptionRequest(
languageCode: LanguageCode.enUs,
mediaSampleRateHertz: 48000,
mediaEncoding: MediaEncoding.pcm,
),
);
copied to clipboard

Subscribe to a raw TranscriptEvent stream:

final transcriptSubscription = transcriptEventStream
.listen((TranscriptEvent event) => print(event));
copied to clipboard
or use a custom strategy to decode TranscriptEvents and build the realtime transcription:
final transcriptSubscription = transcriptEventStream
.transform(const TranscriptEventStreamDecoder(PlainTextTranscriptionStrategy()))
.listen((String message) => print(message));
copied to clipboard

Start sending audio data to the audio stream sink:

// Raw audio data from the microphone in PCM signed 16-bit little-endian audio format
Stream<Uint8List> audioStream;

final audioStreamSubscription = audioStream.listen(
audioStreamSink.add,
onDone: audioStreamSink.close,
);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.