From 75eeda4aeee7158f953bb1482dc076565084498a Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Tue, 15 Nov 2022 19:25:40 +0100 Subject: [PATCH] New RPC event "speechToTextDisconnected" --- openvidu-browser/src/OpenVidu/OpenVidu.ts | 3 ++- openvidu-browser/src/OpenVidu/Session.ts | 8 ++++++++ .../src/OpenViduInternal/Events/ExceptionEvent.ts | 13 +++++++++++-- .../openvidu/client/internal/ProtocolElements.java | 4 +++- .../test/browsers/utils/CommandLineExecutor.java | 3 +++ openvidu-testapp/package.json | 6 +++--- 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/openvidu-browser/src/OpenVidu/OpenVidu.ts b/openvidu-browser/src/OpenVidu/OpenVidu.ts index 4222c86a..b64d5fb3 100644 --- a/openvidu-browser/src/OpenVidu/OpenVidu.ts +++ b/openvidu-browser/src/OpenVidu/OpenVidu.ts @@ -875,7 +875,8 @@ export class OpenVidu { mediaError: this.session.onMediaError.bind(this.session), masterNodeCrashedNotification: this.onMasterNodeCrashedNotification.bind(this), forciblyReconnectSubscriber: this.session.onForciblyReconnectSubscriber.bind(this.session), - speechToTextMessage: this.session.onSpeechToTextMessage.bind(this.session) + speechToTextMessage: this.session.onSpeechToTextMessage.bind(this.session), + speechToTextDisconnected: this.session.onSpeechToTextDisconnected.bind(this.session) } }; this.jsonRpcClient = new RpcBuilder.clients.JsonRpcClient(config); diff --git a/openvidu-browser/src/OpenVidu/Session.ts b/openvidu-browser/src/OpenVidu/Session.ts index 301d7edb..e7a33140 100644 --- a/openvidu-browser/src/OpenVidu/Session.ts +++ b/openvidu-browser/src/OpenVidu/Session.ts @@ -53,6 +53,7 @@ import semverMajor = require('semver/functions/major'); * @hidden */ import semverMinor = require('semver/functions/minor'); +import { ExceptionEvent, ExceptionEventName } from '../OpenViduInternal/Events/ExceptionEvent'; /** * @hidden @@ -1345,6 +1346,13 @@ export class Session extends EventDispatcher { this.ee.emitEvent('speechToTextMessage', [ev]); } + /** + * @hidden + */ + async onSpeechToTextDisconnected(event: { message: string }): Promise { + this.emitEvent('exception', [new ExceptionEvent(this, ExceptionEventName.SPEECH_TO_TEXT_DISCONNECTED, this, event.message)]); + } + /** * @hidden */ diff --git a/openvidu-browser/src/OpenViduInternal/Events/ExceptionEvent.ts b/openvidu-browser/src/OpenViduInternal/Events/ExceptionEvent.ts index 4f4da9a0..49f1edb6 100644 --- a/openvidu-browser/src/OpenViduInternal/Events/ExceptionEvent.ts +++ b/openvidu-browser/src/OpenViduInternal/Events/ExceptionEvent.ts @@ -78,7 +78,16 @@ export enum ExceptionEventName { * * [[ExceptionEvent]] objects with this [[ExceptionEvent.name]] will have as [[ExceptionEvent.origin]] property a [[Subscriber]] object. */ - NO_STREAM_PLAYING_EVENT = 'NO_STREAM_PLAYING_EVENT' + NO_STREAM_PLAYING_EVENT = 'NO_STREAM_PLAYING_EVENT', + + /** + * There has been a server-side disconnection of the Speech To Text module. From the moment this exception is fired to the moment method + * [[Session.subscribeToSpeechToText]] is called again, the transcription of the audio stream will not be available and no [[SpeechToTextEvent]] + * will be fired. + * + * [[ExceptionEvent]] objects with this [[ExceptionEvent.name]] will have as [[ExceptionEvent.origin]] property a [[Session]] object. + */ + SPEECH_TO_TEXT_DISCONNECTED = 'SPEECH_TO_TEXT_DISCONNECTED', } /** @@ -123,5 +132,5 @@ export class ExceptionEvent extends Event { * @hidden */ // tslint:disable-next-line:no-empty - callDefaultBehavior() {} + callDefaultBehavior() { } } diff --git a/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java b/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java index c02de34f..f9853d32 100644 --- a/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java +++ b/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java @@ -155,7 +155,6 @@ public class ProtocolElements { public static final String UNSUBSCRIBEFROMSPEECHTOTEXT_METHOD = "unsubscribeFromSpeechToText"; public static final String UNSUBSCRIBEFROMSPEECHTOTEXT_CONNECTIONID_PARAM = "connectionId"; - // ---------------------------- SERVER RESPONSES & EVENTS ----------------- public static final String PARTICIPANTJOINED_METHOD = "participantJoined"; @@ -239,6 +238,9 @@ public class ProtocolElements { public static final String SPEECHTOTEXTMESSAGE_RAW_PARAM = "raw"; public static final String SPEECHTOTEXTMESSAGE_LANG_PARAM = "lang"; + public static final String SPEECHTOTEXTDISCONNECTED_METHOD = "speechToTextDisconnected"; + public static final String SPEECHTOTEXTDISCONNECTED_MESSAGE_PARAM = "message"; + public static final String CUSTOM_NOTIFICATION = "customNotification"; public static final String RECORDER_PARTICIPANT_PUBLICID = "RECORDER"; diff --git a/openvidu-test-browsers/src/main/java/io/openvidu/test/browsers/utils/CommandLineExecutor.java b/openvidu-test-browsers/src/main/java/io/openvidu/test/browsers/utils/CommandLineExecutor.java index f96d7386..a08ca7e2 100644 --- a/openvidu-test-browsers/src/main/java/io/openvidu/test/browsers/utils/CommandLineExecutor.java +++ b/openvidu-test-browsers/src/main/java/io/openvidu/test/browsers/utils/CommandLineExecutor.java @@ -23,6 +23,9 @@ import java.util.concurrent.TimeUnit; public class CommandLineExecutor { + /** + * WARNING: does not work with subshell. i.e: echo $(VARIABLE) + */ public String executeCommand(String command, int secondsTimeout) { String output = ""; Process p = null; diff --git a/openvidu-testapp/package.json b/openvidu-testapp/package.json index 2a847d8b..dcb256a6 100644 --- a/openvidu-testapp/package.json +++ b/openvidu-testapp/package.json @@ -38,12 +38,12 @@ "name": "openvidu-testapp", "private": true, "scripts": { - "build": "ng build", + "build": "NODE_OPTIONS=--openssl-legacy-provider ng build", "e2e": "ng e2e", "lint": "ng lint", "ng": "ng", - "start": "ng serve", - "test": "ng test" + "start": "NODE_OPTIONS=--openssl-legacy-provider ng serve --host 0.0.0.0 --ssl", + "test": "NODE_OPTIONS=--openssl-legacy-provider ng test" }, "version": "2.23.0" } \ No newline at end of file