openvidu-browser: final SpeechToTextEvent format

pull/748/head
pabloFuente 2022-10-17 12:27:23 +02:00
parent d4cbc67836
commit 9defcf4e87
4 changed files with 22 additions and 15 deletions

View File

@ -1317,13 +1317,10 @@ export class Session extends EventDispatcher {
/**
* @hidden
*/
async onSpeechToTextMessage(event: { streamId: string; connectionId: string; sessionId: string, timestamp: number, raw: string }): Promise<void> {
async onSpeechToTextMessage(event: { streamId: string; connectionId: string; sessionId: string, text: string, reason: string, raw: string }): Promise<void> {
const connection = await this.getConnection(event.connectionId, 'No connection found for connectionId ' + event.connectionId);
const ev = new SpeechToTextEvent(this, connection, event.timestamp, event.raw);
const ev = new SpeechToTextEvent(this, connection, event.text, <any>event.reason.toLowerCase(), event.raw);
this.ee.emitEvent('speechToTextMessage', [ev]);
if (ev.raw.includes('text')) {
console.log(ev);
}
}
/**

View File

@ -20,18 +20,25 @@ import { Connection } from '../../OpenVidu/Connection';
import { Session } from '../../OpenVidu/Session';
/**
* Triggered by [[SessionEventMap.signal]]
* Triggered by [[SessionEventMap.speechToTextMessage]]
*/
export class SpeechToTextEvent extends Event {
/**
* The connectionId of the
* The [[Connection]] owning the Stream that produced the speech-to-text event.
* In other words, this is the participant that spoke and produced this transcription event.
*/
connection: Connection;
/**
*
* The text of the event. This is the transcription for this specific piece of audio stream
*/
timestamp: number;
text: string;
/**
* All speech-to-text events are generated
*/
reason: 'recognizing' | 'recognized';
/**
* The original event from the speech to text engine. This can vary depending on the engine
@ -41,10 +48,11 @@ export class SpeechToTextEvent extends Event {
/**
* @hidden
*/
constructor(target: Session, connection: Connection, timestamp: number, raw: string) {
constructor(target: Session, connection: Connection, text: string, reason: 'recognizing' | 'recognized', raw: string) {
super(false, target, 'speechToTextMessage');
this.connection = connection;
this.timestamp = timestamp;
this.text = text;
this.reason = reason;
this.raw = raw;
}

View File

@ -232,6 +232,8 @@ public class ProtocolElements {
public static final String SPEECHTOTEXTMESSAGE_TIMESTAMP_PARAM = "timestamp";
public static final String SPEECHTOTEXTMESSAGE_SESSIONID_PARAM = "sessionId";
public static final String SPEECHTOTEXTMESSAGE_CONNECTIONID_PARAM = "connectionId";
public static final String SPEECHTOTEXTMESSAGE_TEXT_PARAM = "text";
public static final String SPEECHTOTEXTMESSAGE_REASON_PARAM = "reason";
public static final String SPEECHTOTEXTMESSAGE_RAW_PARAM = "raw";
public static final String CUSTOM_NOTIFICATION = "customNotification";

View File

@ -640,7 +640,7 @@ public class OpenviduConfig {
webrtcIceServersBuilders = loadWebrtcIceServers("OPENVIDU_WEBRTC_ICE_SERVERS");
Boolean openviduDevAux = asOptionalBoolean("OPENVIDU_DEV");
Boolean openviduDevAux = asOptionalBoolean("OPENVIDU_DEV", false);
if (openviduDevAux != null) {
openviduDev = openviduDevAux;
}
@ -887,9 +887,9 @@ public class OpenviduConfig {
return getValue(property);
}
protected Boolean asOptionalBoolean(String property) {
protected Boolean asOptionalBoolean(String property, boolean storeInConfigProps) {
Boolean value = null;
String strValue = this.getValue(property, false);
String strValue = this.getValue(property, storeInConfigProps);
if (strValue != null) {
value = Boolean.parseBoolean(strValue);
}