Skip to content

Instantly share code, notes, and snippets.

@seatedro
Created September 16, 2022 18:24
Show Gist options
  • Save seatedro/cb27f64548df9d4496b6a99d48569379 to your computer and use it in GitHub Desktop.
Save seatedro/cb27f64548df9d4496b6a99d48569379 to your computer and use it in GitHub Desktop.
import { io, Socket } from 'socket.io-client';
import {AudioStreamer} from 'src/app/app.service';
constructor(private audioStreamer: AudioStreamer) {
this.liveTranscription = '';
this.socket = io('https://localhost:3000');
this.socket.on('connect', () => {
console.log('Socket Connection: ', this.socket?.connected);
})
this.audioStreamer._socket = this.socket;
}
startRecording() {
console.log('startRecording');
if (!this.isRecording) {
this.liveTranscription = '';
}
this.isRecording = true;
this.audioStreamer.initRecording((data: string) => {
this.liveTranscription += ( data + '. ');
}, (error) => {
console.error('Error when processing audio');
})
}
stopRecording() {
this.isRecording = false;
console.log('stopRecording');
this.audioStreamer.stopRecording();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment