Pending TODO and transcription collapse

This commit is contained in:
Yauhen Pahrabniak 2023-02-07 11:36:32 +01:00
parent 050ec311a4
commit 05b67de798
1 changed files with 16 additions and 2 deletions

View File

@ -194,9 +194,23 @@ async function wrapVoiceMessage(audioEl: AudioElement) {
speechTextDiv.innerHTML = '';
speechTextDiv.classList.add('audio-to-text');
let isTranscribing: boolean = false;
let transcribed: boolean = false;
speechRecognitionDiv.onclick = async (e) => {
const transcription = await audioEl.managers.appMessagesManager.transcribeAudio(message);
speechTextDiv.innerHTML = transcription.text;
if (!transcribed) {
if (isTranscribing) return;
isTranscribing = true;
//Process started
const transcription = await audioEl.managers.appMessagesManager.transcribeAudio(message);
speechTextDiv.innerHTML = transcription.text;
isTranscribing = false;
transcribed = true;
//Process finished
} else {
//Hide transcription
speechTextDiv.innerHTML = '';
transcribed = false;
}
};
audioControlsDiv.append(speechRecognitionDiv);