Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
AwsTranscribe
✓ import { AwsTranscribe } from 'aws-transcribe'
✗ const AwsTranscribe = require('aws-transcribe')
Default export was also available, but named import is recommended. CommonJS require works but may cause issues in ESM projects.
StreamingClient
✓ import { StreamingClient } from 'aws-transcribe'
✗ const StreamingClient = require('aws-transcribe').StreamingClient
Named import for the streaming client wrapper.
TranscriptEvent
✓ import { TranscriptEvent } from 'aws-transcribe'
TypeScript type for event data. Not needed for JavaScript but useful for type safety.
Shows how to transcribe audio from a file by piping it to a streaming client.
import { AwsTranscribe, StreamingClient, TranscriptEvent } from 'aws-transcribe'
import { createReadStream } from 'fs'
const client = new AwsTranscribe({
accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '',
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? '',
})
const transcribeStream = client
.createStreamingClient({
region: 'us-east-1',
sampleRate: 16000,
languageCode: 'en-US',
})
.on(StreamingClient.EVENTS.OPEN, () => console.log('Connection opened'))
.on(StreamingClient.EVENTS.ERROR, console.error)
.on(StreamingClient.EVENTS.DATA, (data: TranscriptEvent) => {
const results = data.Transcript.Results
if (!results || results.length === 0) return
const result = results[0]
const final = !result.IsPartial
console.log(`${final ? 'Final' : 'Interim'}: ${result.Alternatives[0].Transcript}`)
})
createReadStream('audio.raw').pipe(transcribeStream)
Errors
Common errors & fixes
Cannot find module 'aws-sdk'
aws-sdk is a peer dependency not installed automatically.
fixRun npm install aws-sdk@2 to install the required peer dependency.
TypeError: client.createStreamingClient is not a function
Misconfigured AwsTranscribe instance; missing or incorrect clientConfig.
fixEnsure you pass valid accessKeyId and secretAccessKey.
Error: Region must be one of...
Invalid region code provided.
fixUse a supported region: us-east-1, us-east-2, us-west-2, ap-southeast-2, ca-central-1, eu-west-1.
Audit
Dependencies
aws-sdkrequiredUsed to generate presigned URLs for WebSocket connection