mirror of https://github.com/OpenVidu/openvidu.git
openvidu-components: Changed language only when captions are enabled
parent
a8e0fcfb79
commit
d4cfd3893a
|
@ -343,16 +343,18 @@ export class SessionComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
private subscribeToCaptionLanguage() {
|
private subscribeToCaptionLanguage() {
|
||||||
this.captionLanguageSubscription = this.captionService.captionLangObs.subscribe(async (lang) => {
|
this.captionLanguageSubscription = this.captionService.captionLangObs.subscribe(async (lang) => {
|
||||||
// Unsubscribe all streams from speech to text and re-subscribe with new language
|
if (this.captionService.areCaptionsEnabled()) {
|
||||||
this.log.d('Re-subscribe from STT because of language changed to ', lang.ISO);
|
// Unsubscribe all streams from speech to text and re-subscribe with new language
|
||||||
for (const participant of this.participantService.getRemoteParticipants()) {
|
this.log.d('Re-subscribe from STT because of language changed to ', lang.ISO);
|
||||||
const streamManager = participant.getCameraConnection()?.streamManager;
|
for (const participant of this.participantService.getRemoteParticipants()) {
|
||||||
if (!!streamManager?.stream) {
|
const streamManager = participant.getCameraConnection()?.streamManager;
|
||||||
try {
|
if (!!streamManager?.stream) {
|
||||||
await this.session.unsubscribeFromSpeechToText(streamManager.stream);
|
try {
|
||||||
await this.session.subscribeToSpeechToText(streamManager.stream, lang.ISO);
|
await this.session.unsubscribeFromSpeechToText(streamManager.stream);
|
||||||
} catch (error) {
|
await this.session.subscribeToSpeechToText(streamManager.stream, lang.ISO);
|
||||||
this.log.e('Error re-subscribing to STT: ', error);
|
} catch (error) {
|
||||||
|
this.log.e('Error re-subscribing to STT: ', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue