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> {
|
||||
const connection = await this.getConnection(event.connectionId, 'No connection found for connectionId ' + event.connectionId);
|
||||
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')) {
|
||||
console.log(ev);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ export class SpeechToTextEvent extends Event {
|
|||
* @hidden
|
||||
*/
|
||||
constructor(target: Session, connection: Connection, timestamp: number, raw: string) {
|
||||
super(false, target, 'speechToText');
|
||||
super(false, target, 'speechToTextMessage');
|
||||
this.connection = connection;
|
||||
this.timestamp = timestamp;
|
||||
this.raw = raw;
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
import {
|
||||
OpenVidu, Session, Subscriber, Publisher, Event, StreamEvent, ConnectionEvent,
|
||||
SessionDisconnectedEvent, SignalEvent, RecordingEvent,
|
||||
PublisherSpeakingEvent, PublisherProperties, StreamPropertyChangedEvent, ConnectionPropertyChangedEvent, OpenViduError, NetworkQualityLevelChangedEvent, ExceptionEvent, OpenViduAdvancedConfiguration
|
||||
PublisherSpeakingEvent, PublisherProperties, StreamPropertyChangedEvent, ConnectionPropertyChangedEvent, OpenViduError, NetworkQualityLevelChangedEvent, ExceptionEvent, OpenViduAdvancedConfiguration, SpeechToTextEvent
|
||||
} from 'openvidu-browser';
|
||||
import {
|
||||
OpenVidu as OpenViduAPI,
|
||||
|
@ -141,6 +141,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
signal: true,
|
||||
publisherStartSpeaking: false,
|
||||
publisherStopSpeaking: false,
|
||||
speechToTextMessage: true,
|
||||
reconnecting: true,
|
||||
reconnected: true,
|
||||
exception: true
|
||||
|
@ -255,6 +256,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
signal: false,
|
||||
publisherStartSpeaking: true,
|
||||
publisherStopSpeaking: true,
|
||||
speechToTextMessage: false,
|
||||
reconnecting: false,
|
||||
reconnected: 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) {
|
||||
this.session.off('reconnecting');
|
||||
if (this.sessionEvents.reconnecting) {
|
||||
|
@ -700,6 +713,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
signal: this.sessionEvents.signal,
|
||||
publisherStartSpeaking: this.sessionEvents.publisherStartSpeaking,
|
||||
publisherStopSpeaking: this.sessionEvents.publisherStopSpeaking,
|
||||
speechToTextMessage: this.sessionEvents.speechToTextMessage,
|
||||
reconnecting: this.sessionEvents.reconnecting,
|
||||
reconnected: this.sessionEvents.reconnected,
|
||||
exception: this.sessionEvents.exception
|
||||
|
@ -735,6 +749,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
signal: result.signal,
|
||||
publisherStartSpeaking: result.publisherStartSpeaking,
|
||||
publisherStopSpeaking: result.publisherStopSpeaking,
|
||||
speechToTextMessage: result.speechToTextMessage,
|
||||
reconnecting: result.reconnecting,
|
||||
reconnected: result.reconnected,
|
||||
exception: result.exception
|
||||
|
|
Loading…
Reference in New Issue