aws_transcribe_streaming 0.1.0 copy "aws_transcribe_streaming: ^0.1.0" to clipboard
aws_transcribe_streaming: ^0.1.0 copied to clipboard

AWS Transcribe Streaming client for producing real-time transcriptions for your media content using HTTP/2.

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

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 #

  1. 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
  )),
);
  1. Start a stream transcription:
final (response, audioStreamSink, transcriptEventStream) =
    await transcribeStreamingClient.startStreamTranscription(
  const StartStreamTranscriptionRequest(
    languageCode: LanguageCode.enUs,
    mediaSampleRateHertz: 48000,
    mediaEncoding: MediaEncoding.pcm,
  ),
);
  1. Subscribe to a raw TranscriptEvent stream:
final transcriptSubscription = transcriptEventStream
    .listen((TranscriptEvent event) => print(event));

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));
  1. 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,
);
0
likes
130
pub points
49%
popularity

Publisher

unverified uploader

AWS Transcribe Streaming client for producing real-time transcriptions for your media content using HTTP/2.

Repository (GitHub)
View/report issues

Topics

#aws #transcribe #streaming #client #audio

Documentation

API reference

License

MIT (LICENSE)

Dependencies

archive, aws_common, aws_signature_v4, convert, crypto, http2, uuid

More

Packages that depend on aws_transcribe_streaming