openvidu/openvidu-browser/src/OpenViduInternal/Events/SpeechToTextEvent.ts

73 lines
2.2 KiB
TypeScript
Raw Normal View History

2022-10-10 11:45:27 +02:00
/*
* (C) Copyright 2017-2022 OpenVidu (https://openvidu.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { Event } from './Event';
import { Connection } from '../../OpenVidu/Connection';
import { Session } from '../../OpenVidu/Session';
2022-11-15 15:28:55 +01:00
import { SpeechToTextEventReason } from './Types/Types';
2022-10-10 11:45:27 +02:00
/**
* Triggered by {@link SessionEventMap.speechToTextMessage}
2022-10-10 11:45:27 +02:00
*/
export class SpeechToTextEvent extends Event {
2022-10-10 11:45:27 +02:00
/**
* The {@link 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.
2022-10-10 11:45:27 +02:00
*/
connection: Connection;
/**
* The text of the event. This is the transcription for this specific piece of audio stream
*/
text: string;
/**
* All speech-to-text events are generated
2022-10-10 11:45:27 +02:00
*/
2022-11-15 15:28:55 +01:00
reason: SpeechToTextEventReason;
2022-10-10 11:45:27 +02:00
/**
* The original event from the speech to text engine. This can vary depending on the engine
*/
raw: string;
/**
2022-11-02 12:17:44 +01:00
* [BCP-47](https://tools.ietf.org/html/bcp47) language tag (like "en-US" or "es-ES") of the recognized text. This will be the same as the language provided
* in method {@link Session.subscribeToSpeechToText} method
*/
lang: string;
2022-10-10 11:45:27 +02:00
/**
* @hidden
*/
2022-11-15 15:28:55 +01:00
constructor(target: Session, connection: Connection, text: string, reason: SpeechToTextEventReason, raw: string, lang: string) {
super(false, target, 'speechToTextMessage');
2022-10-10 11:45:27 +02:00
this.connection = connection;
this.text = text;
this.reason = reason;
2022-10-10 11:45:27 +02:00
this.raw = raw;
this.lang = lang;
2022-10-10 11:45:27 +02:00
}
/**
* @hidden
*/
// tslint:disable-next-line:no-empty
callDefaultBehavior() { }
}