mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: speechToText to speechToTextMessage
parent
d700dd3e97
commit
37073bd0ec
|
@ -1320,7 +1320,7 @@ export class Session extends EventDispatcher {
|
||||||
async onSpeechToTextMessage(event: { streamId: string; connectionId: string; sessionId: string, timestamp: number, raw: string }): Promise<void> {
|
async onSpeechToTextMessage(event: { streamId: string; connectionId: string; sessionId: string, timestamp: number, 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.timestamp, event.raw);
|
||||||
this.ee.emitEvent('speechToText', [ev]);
|
this.ee.emitEvent('speechToTextMessage', [ev]);
|
||||||
if (ev.raw.includes('text')) {
|
if (ev.raw.includes('text')) {
|
||||||
console.log(ev);
|
console.log(ev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ export class SpeechToTextEvent extends Event {
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
constructor(target: Session, connection: Connection, timestamp: number, raw: string) {
|
constructor(target: Session, connection: Connection, timestamp: number, raw: string) {
|
||||||
super(false, target, 'speechToText');
|
super(false, target, 'speechToTextMessage');
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
this.raw = raw;
|
this.raw = raw;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
import {
|
import {
|
||||||
OpenVidu, Session, Subscriber, Publisher, Event, StreamEvent, ConnectionEvent,
|
OpenVidu, Session, Subscriber, Publisher, Event, StreamEvent, ConnectionEvent,
|
||||||
SessionDisconnectedEvent, SignalEvent, RecordingEvent,
|
SessionDisconnectedEvent, SignalEvent, RecordingEvent,
|
||||||
PublisherSpeakingEvent, PublisherProperties, StreamPropertyChangedEvent, ConnectionPropertyChangedEvent, OpenViduError, NetworkQualityLevelChangedEvent, ExceptionEvent, OpenViduAdvancedConfiguration
|
PublisherSpeakingEvent, PublisherProperties, StreamPropertyChangedEvent, ConnectionPropertyChangedEvent, OpenViduError, NetworkQualityLevelChangedEvent, ExceptionEvent, OpenViduAdvancedConfiguration, SpeechToTextEvent
|
||||||
} from 'openvidu-browser';
|
} from 'openvidu-browser';
|
||||||
import {
|
import {
|
||||||
OpenVidu as OpenViduAPI,
|
OpenVidu as OpenViduAPI,
|
||||||
|
@ -141,6 +141,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
signal: true,
|
signal: true,
|
||||||
publisherStartSpeaking: false,
|
publisherStartSpeaking: false,
|
||||||
publisherStopSpeaking: false,
|
publisherStopSpeaking: false,
|
||||||
|
speechToTextMessage: true,
|
||||||
reconnecting: true,
|
reconnecting: true,
|
||||||
reconnected: true,
|
reconnected: true,
|
||||||
exception: true
|
exception: true
|
||||||
|
@ -255,6 +256,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
signal: false,
|
signal: false,
|
||||||
publisherStartSpeaking: true,
|
publisherStartSpeaking: true,
|
||||||
publisherStopSpeaking: true,
|
publisherStopSpeaking: true,
|
||||||
|
speechToTextMessage: false,
|
||||||
reconnecting: false,
|
reconnecting: false,
|
||||||
reconnected: false,
|
reconnected: false,
|
||||||
exception: false
|
exception: false
|
||||||
|
@ -515,6 +517,17 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.sessionEvents.speechToTextMessage !== oldValues.speechToTextMessage || firstTime) {
|
||||||
|
if (!this.sessionEvents.speechToTextMessage) {
|
||||||
|
this.session.off('speechToTextMessage');
|
||||||
|
}
|
||||||
|
if (this.sessionEvents.speechToTextMessage) {
|
||||||
|
this.session.on('speechToTextMessage', (event: SpeechToTextEvent) => {
|
||||||
|
this.updateEventList('speechToTextMessage', event.connection.connectionId, event);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.sessionEvents.reconnecting !== oldValues.reconnecting || firstTime) {
|
if (this.sessionEvents.reconnecting !== oldValues.reconnecting || firstTime) {
|
||||||
this.session.off('reconnecting');
|
this.session.off('reconnecting');
|
||||||
if (this.sessionEvents.reconnecting) {
|
if (this.sessionEvents.reconnecting) {
|
||||||
|
@ -700,6 +713,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
signal: this.sessionEvents.signal,
|
signal: this.sessionEvents.signal,
|
||||||
publisherStartSpeaking: this.sessionEvents.publisherStartSpeaking,
|
publisherStartSpeaking: this.sessionEvents.publisherStartSpeaking,
|
||||||
publisherStopSpeaking: this.sessionEvents.publisherStopSpeaking,
|
publisherStopSpeaking: this.sessionEvents.publisherStopSpeaking,
|
||||||
|
speechToTextMessage: this.sessionEvents.speechToTextMessage,
|
||||||
reconnecting: this.sessionEvents.reconnecting,
|
reconnecting: this.sessionEvents.reconnecting,
|
||||||
reconnected: this.sessionEvents.reconnected,
|
reconnected: this.sessionEvents.reconnected,
|
||||||
exception: this.sessionEvents.exception
|
exception: this.sessionEvents.exception
|
||||||
|
@ -735,6 +749,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
signal: result.signal,
|
signal: result.signal,
|
||||||
publisherStartSpeaking: result.publisherStartSpeaking,
|
publisherStartSpeaking: result.publisherStartSpeaking,
|
||||||
publisherStopSpeaking: result.publisherStopSpeaking,
|
publisherStopSpeaking: result.publisherStopSpeaking,
|
||||||
|
speechToTextMessage: result.speechToTextMessage,
|
||||||
reconnecting: result.reconnecting,
|
reconnecting: result.reconnecting,
|
||||||
reconnected: result.reconnected,
|
reconnected: result.reconnected,
|
||||||
exception: result.exception
|
exception: result.exception
|
||||||
|
|
Loading…
Reference in New Issue