You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to adapt the transcription example to allow an incoming microphone stream to be forwarded to the Transcribe service but can't work out how to pipe the data from the incoming socket to the AudioStream async iterator. NodeJS code:
io.on('connection', function (socket) {
console.log(`Client connected [id=${socket.id}]`);
socket.emit('server-ready', `AWS STT Server ready [id=${socket.id}]`);
socket.on('stt-start', async function () {
await startRecognitionStream();
});
socket.on('stt-end', function () {
stopRecognitionStream();
});
socket.on('stt-data', function (data) {
// Incoming microphone audio data
// How to get this into the transcribe AudioStream???
});
const transcribeIterator = async function* () {
for await (const chunk of ???) {
console.log(chunk);
yield {
AudioEvent: {
AudioChunk: chunk,
},
};
}
};
async function startRecognitionStream() {
speechClient = new TranscribeStreamingClient({
region: process.env.AWS_DEFAULT_REGION,
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
},
});
const startStreamTranscriptionCommand = new StartStreamTranscriptionCommand({
LanguageCode: 'en-GB',
MediaSampleRateHertz: 16000,
MediaEncoding: 'pcm',
AudioStream: transcribeIterator(),
});
const startStreamTranscriptionCommandOutput = await speechClient.send(startStreamTranscriptionCommand);
for await (const transcriptionEvent of startStreamTranscriptionCommandOutput.TranscriptResultStream) {
if (transcriptionEvent.TranscriptEvent.Transcript) {
const results = transcriptionEvent.TranscriptEvent.Transcript.Results;
console.log(results);
}
}
}
Can anyone help?
The text was updated successfully, but these errors were encountered:
I'm trying to adapt the transcription example to allow an incoming microphone stream to be forwarded to the Transcribe service but can't work out how to pipe the data from the incoming socket to the AudioStream async iterator. NodeJS code:
Can anyone help?
The text was updated successfully, but these errors were encountered: