@@ -246,91 +246,121 @@ export default {
246
246
});
247
247
sequence++ ;
248
248
};
249
- RemoteEventBus .$on (' sendMutationToReceivers' , ({ mutation, payload }) => {
250
- if (
251
- this .$store .state .settings .integrations .webhooks .on &&
252
- mutation === ' captioner/APPEND_TRANSCRIPT_STABILIZED'
253
- ) {
254
- callWebhook ({
255
- url: this .$store .state .settings .integrations .webhooks .url ,
256
- method: this .$store .state .settings .integrations .webhooks .method ,
257
- transcript: payload ? payload .transcript : ' ' ,
258
- });
259
- lastWebhookEventDate = Date .now ();
260
- }
261
249
262
- if (
263
- mutation === ' captioner/SET_TRANSCRIPT_INTERIM' &&
264
- Date .now () - lastWebhookEventDate >= 100
265
- ) {
250
+ RemoteEventBus .$on (
251
+ ' sendMutationToReceivers' ,
252
+ async ({ mutation, payload }) => {
266
253
if (
267
- this .$store .state .settings .share .roomId &&
268
- this .$store .state .socket .isConnected &&
269
- this .$store .state .settings .share .on
254
+ this .$store .state .settings .integrations .webhooks .on &&
255
+ mutation === ' captioner/APPEND_TRANSCRIPT_STABILIZED'
270
256
) {
271
- this . $socket . sendObj ({
272
- action : ' mutation ' ,
273
- mutation ,
274
- payload,
257
+ callWebhook ({
258
+ url : this . $store . state . settings . integrations . webhooks . url ,
259
+ method : this . $store . state . settings . integrations . webhooks . method ,
260
+ transcript : payload ? payload . transcript : ' ' ,
275
261
});
276
262
lastWebhookEventDate = Date .now ();
277
263
}
278
- }
279
264
280
- if (
281
- [
282
- ' captioner/APPEND_TRANSCRIPT_FINAL' ,
283
- ' captioner/CLEAR_TRANSCRIPT_INTERIM' ,
284
- ' captioner/CLEAR_TRANSCRIPT' ,
265
+ if (
266
+ mutation === ' captioner/SET_TRANSCRIPT_INTERIM' &&
267
+ Date .now () - lastWebhookEventDate >= 100
268
+ ) {
269
+ if (
270
+ this .$store .state .settings .share .roomId &&
271
+ this .$store .state .socket .isConnected &&
272
+ this .$store .state .settings .share .on
273
+ ) {
274
+ this .$socket .sendObj ({
275
+ action: ' mutation' ,
276
+ mutation,
277
+ payload,
278
+ });
279
+ lastWebhookEventDate = Date .now ();
280
+ }
281
+ }
285
282
286
- ' SET_TEXT_COLOR' ,
287
- ' SET_TEXT_COLOR_INTERIM' ,
288
- ' SET_FONT_FAMILY' ,
289
- ' SET_FONT_VARIANT' ,
290
- ' SET_TEXT_SIZE' ,
291
- ' SET_LINE_HEIGHT' ,
292
- ' SET_LETTER_SPACING' ,
293
- ' SET_TEXT_TRANSFORM' ,
294
- ' SET_SHADOW_COLOR' ,
295
- ' SET_SHADOW_OPACITY' ,
296
- ' SET_SHADOW_BLUR_RADIUS' ,
297
- ' SET_SHADOW_OFFSET_X' ,
298
- ' SET_SHADOW_OFFSET_Y' ,
299
- ' SET_BACKGROUND_COLOR' ,
300
- ' SET_BACKGROUND_OPACITY' ,
301
- ' SET_ALIGNMENT_HORIZONTAL' ,
302
- ' SET_ALIGNMENT_VERTICAL' ,
303
- ' SET_ALIGNMENT_PADDING' ,
304
- ].includes (mutation)
305
- ) {
306
283
if (
307
- this .$store .state .settings .share .roomId &&
308
- this .$store .state .socket .isConnected
284
+ [
285
+ ' captioner/APPEND_TRANSCRIPT_FINAL' ,
286
+ ' captioner/CLEAR_TRANSCRIPT_INTERIM' ,
287
+ ' captioner/CLEAR_TRANSCRIPT' ,
288
+
289
+ ' SET_TEXT_COLOR' ,
290
+ ' SET_TEXT_COLOR_INTERIM' ,
291
+ ' SET_FONT_FAMILY' ,
292
+ ' SET_FONT_VARIANT' ,
293
+ ' SET_TEXT_SIZE' ,
294
+ ' SET_LINE_HEIGHT' ,
295
+ ' SET_LETTER_SPACING' ,
296
+ ' SET_TEXT_TRANSFORM' ,
297
+ ' SET_SHADOW_COLOR' ,
298
+ ' SET_SHADOW_OPACITY' ,
299
+ ' SET_SHADOW_BLUR_RADIUS' ,
300
+ ' SET_SHADOW_OFFSET_X' ,
301
+ ' SET_SHADOW_OFFSET_Y' ,
302
+ ' SET_BACKGROUND_COLOR' ,
303
+ ' SET_BACKGROUND_OPACITY' ,
304
+ ' SET_ALIGNMENT_HORIZONTAL' ,
305
+ ' SET_ALIGNMENT_VERTICAL' ,
306
+ ' SET_ALIGNMENT_PADDING' ,
307
+ ].includes (mutation)
309
308
) {
310
- this .$socket .sendObj ({
311
- action: ' mutation' ,
312
- mutation,
313
- payload,
314
- });
309
+ if (
310
+ this .$store .state .settings .share .roomId &&
311
+ this .$store .state .socket .isConnected
312
+ ) {
313
+ this .$socket .sendObj ({
314
+ action: ' mutation' ,
315
+ mutation,
316
+ payload,
317
+ });
318
+ }
315
319
}
316
- }
317
- if (
318
- [
319
- ' captioner/APPEND_TRANSCRIPT_FINAL' ,
320
- ' captioner/SET_CAPTIONER_OFF' ,
321
- ' captioner/APPEND_TRANSCRIPT_STABILIZED' ,
322
- ].includes (mutation) &&
323
- this .$store .state .settings .integrations .dropbox .accessToken &&
324
- this .$store .state .captioner .transcript .final
325
- ) {
326
- if (' captioner/SET_CAPTIONER_OFF' === mutation) {
327
- // immediate
328
- this .$store .dispatch (' SAVE_TO_DROPBOX' );
329
- } else {
330
- this .saveToDropboxThrottled ();
320
+ if (
321
+ [
322
+ ' captioner/APPEND_TRANSCRIPT_FINAL' ,
323
+ ' captioner/SET_CAPTIONER_OFF' ,
324
+ ' captioner/APPEND_TRANSCRIPT_STABILIZED' ,
325
+ ].includes (mutation) &&
326
+ this .$store .state .settings .integrations .dropbox .accessToken &&
327
+ this .$store .state .captioner .transcript .final
328
+ ) {
329
+ if (' captioner/SET_CAPTIONER_OFF' === mutation) {
330
+ // immediate
331
+ this .$store .dispatch (' SAVE_TO_DROPBOX' );
332
+ } else {
333
+ this .saveToDropboxThrottled ();
334
+ }
335
+ }
336
+
337
+ if (
338
+ [
339
+ ' captioner/APPEND_TRANSCRIPT_FINAL' ,
340
+ // 'captioner/APPEND_TRANSCRIPT_STABILIZED',
341
+ ].includes (mutation) &&
342
+ this .experiments .includes (' speakBack' )
343
+ ) {
344
+ const voices = await new Promise ((resolve ) => {
345
+ let voices = speechSynthesis .getVoices ();
346
+ if (voices .length ) {
347
+ resolve (voices);
348
+ return ;
349
+ }
350
+ speechSynthesis .onvoiceschanged = () => {
351
+ voices = speechSynthesis .getVoices ();
352
+ resolve (voices);
353
+ };
354
+ });
355
+ let utterance = new SpeechSynthesisUtterance (payload .transcriptFinal );
356
+
357
+ utterance .voice = voices .find (
358
+ (voice ) => voice .name === ' Google US English'
359
+ );
360
+ window .speechSynthesis .speak (utterance);
331
361
}
332
362
}
333
- } );
363
+ );
334
364
335
365
// Zoom integration
336
366
let zoomTranscriptBuffer = [];
@@ -665,4 +695,4 @@ export default {
665
695
}, 1000 * 30 ),
666
696
},
667
697
};
668
- </script >
698
+ </script >
0 commit comments