@rxtk/stt-gcp
π An RxJS operator for real-time speech-to-text (STT/S2T) streaming using the GCP speech-to-text API.
π If you are using an Apple Silicon (ARM) machine, this package only works in node >15.x
yarn add @rxtk/stt-gcp
GOOGLE_APPLICATION_CREDENTIALS
. You can set this as an environment variable or pass it in.
API
toGCPSpeech
Stream audio speech data to AWS Transcribe via WebSocket and get transcripts back:
import {map} from 'rxjs/operators';
import {toGCPSpeech} from '@rxtk/stt-gcp';
// The pipeline can take a stream of audio chunks encoded as
// LINEAR16 (PCM encoded as 16-bit integers) in the form of a Buffer
const buffer$ = pcmChunkEncodedAs16BitIntegers$.pipe(
map(chunk => Buffer.from(chunk, 'base64')),
toGCPSpeech({
sampleRate: 16000, // optional
contentType: 'audio/l16', // optional
googleCreds: process.env.GOOGLE_APPLICATION_CREDENTIALS, // required
useSpeakerLabels: true, // optional
useWordConfidence: true, // optional
usePunctuation: true, // optional
})
);
buffer$.subscribe(console.log); // log transcript output