From d68326a374baf6ef5d914963a56169f735519c53 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Mon, 31 Oct 2022 13:40:39 +0100 Subject: [PATCH] openvidu-components: Subscribed to STT only for camera type --- .../src/lib/components/session/session.component.ts | 12 ++++++++---- .../lib/services/participant/participant.service.ts | 9 +++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts index 83224137..9f182191 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/components/session/session.component.ts @@ -299,10 +299,14 @@ export class SessionComponent implements OnInit { const subscriber: Subscriber = this.session.subscribe(event.stream, undefined); this.participantService.addRemoteConnection(connectionId, data, subscriber); // this.oVSessionService.sendNicknameSignal(event.stream.connection); - try { - await this.session.subscribeToSpeechToText(event.stream, this.captionService.getLangSelected().ISO); - } catch (error) { - this.log.e('Error subscribing from STT: ', error); + + if (this.participantService.getTypeConnectionData(data) === VideoType.CAMERA) { + // Only subscribe to STT when stream is CAMERA type and it is a remote stream + try { + await this.session.subscribeToSpeechToText(event.stream, this.captionService.getLangSelected().ISO); + } catch (error) { + this.log.e('Error subscribing from STT: ', error); + } } } }); diff --git a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/participant/participant.service.ts b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/participant/participant.service.ts index 36ef33b3..4826c6d6 100644 --- a/openvidu-components-angular/projects/openvidu-angular/src/lib/services/participant/participant.service.ts +++ b/openvidu-components-angular/projects/openvidu-angular/src/lib/services/participant/participant.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { Publisher, Subscriber } from 'openvidu-browser'; import { BehaviorSubject, Observable } from 'rxjs'; import { ILogger } from '../../models/logger.model'; -import { StreamModel, ParticipantAbstractModel, ParticipantModel, ParticipantProperties } from '../../models/participant.model'; +import { ParticipantAbstractModel, ParticipantModel, ParticipantProperties, StreamModel } from '../../models/participant.model'; import { VideoType } from '../../models/video-type.model'; import { OpenViduAngularConfigService } from '../config/openvidu-angular.config.service'; import { LoggerService } from '../logger/logger.service'; @@ -399,7 +399,12 @@ export class ParticipantService { this._remoteParticipants.next([...this.remoteParticipants]); } - protected getTypeConnectionData(data: string): VideoType { + /** + * @internal + * @param data + * @returns Stream video type + */ + getTypeConnectionData(data: string): VideoType { try { return JSON.parse(data).type; } catch (error) {