What is @aws-sdk/client-transcribe-streaming?
@aws-sdk/client-transcribe-streaming is an AWS SDK for JavaScript package that allows developers to use Amazon Transcribe Streaming, a service that provides real-time speech-to-text capabilities. This package enables applications to transcribe audio streams into text in real-time, which can be useful for various applications such as live captioning, real-time transcription, and voice command processing.
What are @aws-sdk/client-transcribe-streaming's main functionalities?
Real-time Transcription
This feature allows you to start a real-time transcription session. The code sample demonstrates how to set up a TranscribeStreamingClient, create an audio stream, and start the transcription process. The transcription results are logged to the console as they are received.
const { TranscribeStreamingClient, StartStreamTranscriptionCommand } = require('@aws-sdk/client-transcribe-streaming');
const { Readable } = require('stream');
const client = new TranscribeStreamingClient({ region: 'us-west-2' });
const audioStream = new Readable();
audioStream._read = () => {}; // No-op
const command = new StartStreamTranscriptionCommand({
LanguageCode: 'en-US',
MediaSampleRateHertz: 16000,
MediaEncoding: 'pcm',
AudioStream: audioStream
});
const response = await client.send(command);
response.TranscriptResultStream.on('data', (event) => {
console.log(event.TranscriptEvent.Transcript.Results);
});
audioStream.push(audioBuffer); // Push audio data to the stream
Handling Transcription Events
This feature demonstrates how to handle transcription events. The code sample shows how to process partial and final transcription results from the TranscriptResultStream.
response.TranscriptResultStream.on('data', (event) => {
event.TranscriptEvent.Transcript.Results.forEach(result => {
if (result.IsPartial) {
console.log('Partial transcript:', result.Alternatives[0].Transcript);
} else {
console.log('Final transcript:', result.Alternatives[0].Transcript);
}
});
});
Stopping the Transcription
This feature shows how to stop the transcription process by signaling the end of the audio stream. The code sample demonstrates how to push a null value to the audio stream to indicate that no more audio data will be sent.
audioStream.push(null); // Signal the end of the audio stream
Other packages similar to @aws-sdk/client-transcribe-streaming
google-cloud/speech
The @google-cloud/speech package provides real-time and batch speech-to-text capabilities using Google Cloud's Speech-to-Text API. It offers similar functionalities to @aws-sdk/client-transcribe-streaming, such as real-time transcription and handling transcription events. However, it is specific to Google Cloud services and may have different pricing and feature sets.
watson-developer-cloud/speech-to-text
The watson-developer-cloud/speech-to-text package allows developers to use IBM Watson's Speech to Text service for real-time and batch transcription. It offers similar functionalities to @aws-sdk/client-transcribe-streaming, including real-time transcription and event handling. This package is specific to IBM Watson services and may offer different language support and pricing.
microsoft-cognitiveservices-speech-sdk
The microsoft-cognitiveservices-speech-sdk package provides real-time and batch speech-to-text capabilities using Microsoft's Azure Cognitive Services. It offers similar functionalities to @aws-sdk/client-transcribe-streaming, such as real-time transcription and handling transcription events. This package is specific to Azure services and may have different features and pricing.