mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: final SpeechToTextEvent format
parent
d4cbc67836
commit
9defcf4e87
|
@ -1317,13 +1317,10 @@ export class Session extends EventDispatcher {
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @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 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]);
|
this.ee.emitEvent('speechToTextMessage', [ev]);
|
||||||
if (ev.raw.includes('text')) {
|
|
||||||
console.log(ev);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,18 +20,25 @@ import { Connection } from '../../OpenVidu/Connection';
|
||||||
import { Session } from '../../OpenVidu/Session';
|
import { Session } from '../../OpenVidu/Session';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered by [[SessionEventMap.signal]]
|
* Triggered by [[SessionEventMap.speechToTextMessage]]
|
||||||
*/
|
*/
|
||||||
export class SpeechToTextEvent extends Event {
|
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;
|
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
|
* 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
|
* @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');
|
super(false, target, 'speechToTextMessage');
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.timestamp = timestamp;
|
this.text = text;
|
||||||
|
this.reason = reason;
|
||||||
this.raw = raw;
|
this.raw = raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,6 +232,8 @@ public class ProtocolElements {
|
||||||
public static final String SPEECHTOTEXTMESSAGE_TIMESTAMP_PARAM = "timestamp";
|
public static final String SPEECHTOTEXTMESSAGE_TIMESTAMP_PARAM = "timestamp";
|
||||||
public static final String SPEECHTOTEXTMESSAGE_SESSIONID_PARAM = "sessionId";
|
public static final String SPEECHTOTEXTMESSAGE_SESSIONID_PARAM = "sessionId";
|
||||||
public static final String SPEECHTOTEXTMESSAGE_CONNECTIONID_PARAM = "connectionId";
|
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 SPEECHTOTEXTMESSAGE_RAW_PARAM = "raw";
|
||||||
|
|
||||||
public static final String CUSTOM_NOTIFICATION = "customNotification";
|
public static final String CUSTOM_NOTIFICATION = "customNotification";
|
||||||
|
|
|
@ -640,7 +640,7 @@ public class OpenviduConfig {
|
||||||
|
|
||||||
webrtcIceServersBuilders = loadWebrtcIceServers("OPENVIDU_WEBRTC_ICE_SERVERS");
|
webrtcIceServersBuilders = loadWebrtcIceServers("OPENVIDU_WEBRTC_ICE_SERVERS");
|
||||||
|
|
||||||
Boolean openviduDevAux = asOptionalBoolean("OPENVIDU_DEV");
|
Boolean openviduDevAux = asOptionalBoolean("OPENVIDU_DEV", false);
|
||||||
if (openviduDevAux != null) {
|
if (openviduDevAux != null) {
|
||||||
openviduDev = openviduDevAux;
|
openviduDev = openviduDevAux;
|
||||||
}
|
}
|
||||||
|
@ -887,9 +887,9 @@ public class OpenviduConfig {
|
||||||
return getValue(property);
|
return getValue(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Boolean asOptionalBoolean(String property) {
|
protected Boolean asOptionalBoolean(String property, boolean storeInConfigProps) {
|
||||||
Boolean value = null;
|
Boolean value = null;
|
||||||
String strValue = this.getValue(property, false);
|
String strValue = this.getValue(property, storeInConfigProps);
|
||||||
if (strValue != null) {
|
if (strValue != null) {
|
||||||
value = Boolean.parseBoolean(strValue);
|
value = Boolean.parseBoolean(strValue);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue