https://github.com/javer/aws_transcribe_streaming
AWS Transcribe Streaming client for producing real-time transcriptions for your media content using HTTP/2.
https://github.com/javer/aws_transcribe_streaming
Last synced: about 2 months ago
JSON representation
AWS Transcribe Streaming client for producing real-time transcriptions for your media content using HTTP/2.
- Host: GitHub
- URL: https://github.com/javer/aws_transcribe_streaming
- Owner: javer
- License: mit
- Created: 2023-12-05T18:03:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-05T18:09:50.000Z (over 1 year ago)
- Last Synced: 2025-01-29T09:18:01.855Z (4 months ago)
- Language: Dart
- Size: 22.5 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
AWS Transcribe Streaming client for producing real-time transcriptions for your media content using HTTP/2.
## Getting started
Add necessary dependencies to `pubspec.yaml`:
```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](https://docs.aws.amazon.com/transcribe/latest/dg/streaming.html)It is recommended to use [Temporary security credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html) with session token obtained from the backend just before starting the transcribing process.
See also [best practices](https://docs.aws.amazon.com/transcribe/latest/dg/streaming.html#best-practices) to improve streaming transcription efficiency.
## Usage
1. Create a new transcribe streaming client:
```dart
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
)),
);
```2. Start a stream transcription:
```dart
final (response, audioStreamSink, transcriptEventStream) =
await transcribeStreamingClient.startStreamTranscription(
const StartStreamTranscriptionRequest(
languageCode: LanguageCode.enUs,
mediaSampleRateHertz: 48000,
mediaEncoding: MediaEncoding.pcm,
),
);
```3. Subscribe to a raw TranscriptEvent stream:
```dart
final transcriptSubscription = transcriptEventStream
.listen((TranscriptEvent event) => print(event));
```
or use a custom strategy to decode TranscriptEvents and build the realtime transcription:
```dart
final transcriptSubscription = transcriptEventStream
.transform(const TranscriptEventStreamDecoder(PlainTextTranscriptionStrategy()))
.listen((String message) => print(message));
```4. Start sending audio data to the audio stream sink:
```dart
// Raw audio data from the microphone in PCM signed 16-bit little-endian audio format
Stream audioStream;final audioStreamSubscription = audioStream.listen(
audioStreamSink.add,
onDone: audioStreamSink.close,
);
```