Skip to content

Commit 44e33a8

Browse files
committed
clear eventHistory + removed console.log
1 parent fb84ba3 commit 44e33a8

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

frontend/src/routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ const wssUpgrade = (req, socket, head) => {
886886
const wss1 = new WebSocketServer({ noServer: true })
887887
wss1.on('connection', async (ws) => {
888888
stream.events.on('data', async (data) => {
889-
if (data.err) console.log(data)
889+
if (data.err) debug(data)
890890
data.streamDuration = ((new Date() - stream.dateTimeStart) / 1000).toFixed(3)
891891
ws.send(JSON.stringify(data))
892892
})

frontend/src/stt/awstranscribe.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class AwsTranscribeSTT {
7878
applyIfExists(request, req, 'req.body.awstranscribe.config.streaming')
7979

8080
const events = new EventEmitter()
81-
const eventHistory = []
81+
let eventHistory = []
8282
try {
8383
const cmdResponse = await transcribeClient.send(new StartStreamTranscriptionCommand(request))
8484
setTimeout(async () => {
@@ -132,6 +132,7 @@ class AwsTranscribeSTT {
132132
audioInputStream.destroy()
133133
}
134134
audioInputStream = null
135+
eventHistory = null
135136
},
136137
triggerHistoryEmit: () => {
137138
for (const eh of eventHistory) {

frontend/src/stt/azure.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class AzureSTT {
5252
const recognizer = new SpeechRecognizer(speechConfig, audioConfig)
5353

5454
const events = new EventEmitter()
55-
const eventHistory = []
55+
let eventHistory = []
5656

5757
const recognizedHandler = (s, e) => {
5858
if (e.result.reason === ResultReason.RecognizedSpeech || e.result.reason === ResultReason.RecognizingSpeech) {
@@ -74,7 +74,6 @@ class AzureSTT {
7474
recognizer.stopContinuousRecognitionAsync()
7575
}
7676
recognizer.canceled = (s, e) => {
77-
console.log(e.errorDetails)
7877
const event = {
7978
status: 'error',
8079
err: `Azure STT failed: ${getAzureErrorDetails(e)}`
@@ -95,6 +94,7 @@ class AzureSTT {
9594
close: () => {
9695
recognizer.stopContinuousRecognitionAsync()
9796
pushStream.close()
97+
eventHistory = null
9898
},
9999
triggerHistoryEmit: () => {
100100
for (const eh of eventHistory) {

frontend/src/stt/google.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class GoogleSTT {
7373
const bufferStream = new PassThrough()
7474
bufferStream.pipe(recognizeStream)
7575
const events = new EventEmitter()
76-
const eventHistory = []
76+
let eventHistory = []
7777

7878
recognizeStream.on('data', (data) => {
7979
const alternative = data.results[0] && data.results[0].alternatives[0]
@@ -118,6 +118,7 @@ class GoogleSTT {
118118
if (recognizeStream) {
119119
recognizeStream.destroy()
120120
}
121+
eventHistory = null
121122
recognizeStream = null
122123
},
123124
triggerHistoryEmit: () => {

frontend/src/stt/ibm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class IbmSTT {
4242
const bufferStream = new PassThrough()
4343
bufferStream.pipe(recognizeStream)
4444
const events = new EventEmitter()
45-
const eventHistory = []
45+
let eventHistory = []
4646

4747
recognizeStream.on('data', (data) => {
4848
for (const result of data.results || []) {
@@ -91,6 +91,7 @@ class IbmSTT {
9191
recognizeStream.destroy()
9292
}
9393
recognizeStream = null
94+
eventHistory = null
9495
},
9596
triggerHistoryEmit: () => {
9697
for (const eh of eventHistory) {

frontend/src/stt/kaldi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class KaldiSTT {
4242

4343
const ws = new WebSocket(wsUri)
4444
const events = new EventEmitter()
45-
const eventHistory = []
45+
let eventHistory = []
4646

4747
ws.on('open', () => {
4848
ws.on('message', (data) => {
@@ -95,6 +95,7 @@ class KaldiSTT {
9595
if (ws) {
9696
ws.close()
9797
}
98+
eventHistory = null
9899
},
99100
triggerHistoryEmit: () => {
100101
for (const eh of eventHistory) {

0 commit comments

Comments
 (0)