[mirotalksfu] - improve transcription

هذا الالتزام موجود في:
Miroslav Pejic
2023-10-18 15:02:16 +02:00
الأصل 89128e071b
التزام 32d64f755e
6 ملفات معدلة مع 70 إضافات و1 حذوفات

عرض الملف

@@ -663,6 +663,19 @@ th {
cursor: pointer; cursor: pointer;
} }
/*--------------------------------------------------------------
# Transcription room popup
--------------------------------------------------------------*/
.transcriptio-popup {
z-index: 9;
position: absolute;
width: 100%;
bottom: 0px;
text-align: center;
border-radius: 10px;
}
/*-------------------------------------------------------------- /*--------------------------------------------------------------
# Chat Room # Chat Room
--------------------------------------------------------------*/ --------------------------------------------------------------*/

عرض الملف

@@ -18,6 +18,7 @@ class LocalStorage {
this.SFU_SETTINGS = { this.SFU_SETTINGS = {
share_on_join: true, // popup message on join share_on_join: true, // popup message on join
show_chat_on_msg: true, // show chat on new message show_chat_on_msg: true, // show chat on new message
show_transcript_on_msg: true, // show transcript on new message
speech_in_msg: false, // speech incoming message speech_in_msg: false, // speech incoming message
video_fps: 0, // default 1280x768 30fps video_fps: 0, // default 1280x768 30fps
screen_fps: 0, // max 30fps screen_fps: 0, // max 30fps

عرض الملف

@@ -210,6 +210,7 @@ function initClient() {
setTippy('transcriptionMaxBtn', 'Maximize', 'bottom'); setTippy('transcriptionMaxBtn', 'Maximize', 'bottom');
setTippy('transcriptionMinBtn', 'Minimize', 'bottom'); setTippy('transcriptionMinBtn', 'Minimize', 'bottom');
setTippy('transcriptionSpeechStatus', 'Status', 'bottom'); setTippy('transcriptionSpeechStatus', 'Status', 'bottom');
setTippy('transcriptShowOnMsg', 'Show transcript on new message comes', 'bottom');
setTippy('transcriptionGhostBtn', 'Toggle transparent background', 'bottom'); setTippy('transcriptionGhostBtn', 'Toggle transparent background', 'bottom');
setTippy('transcriptionSaveBtn', 'Save', 'bottom'); setTippy('transcriptionSaveBtn', 'Save', 'bottom');
setTippy('transcriptionCleanBtn', 'Clean', 'bottom'); setTippy('transcriptionCleanBtn', 'Clean', 'bottom');
@@ -1720,6 +1721,14 @@ function handleSelects() {
lS.setSettings(lsSettings); lS.setSettings(lsSettings);
e.target.blur(); e.target.blur();
}; };
// transcript
transcriptShowOnMsg.onchange = (e) => {
transcription.showOnMessage = e.currentTarget.checked;
rc.roomMessage('showTranscript', transcription.showOnMessage);
lsSettings.show_transcript_on_msg = transcription.showOnMessage;
lS.setSettings(lsSettings);
e.target.blur();
};
// whiteboard options // whiteboard options
wbDrawingColorEl.onchange = () => { wbDrawingColorEl.onchange = () => {
wbCanvas.freeDrawingBrush.color = wbDrawingColorEl.value; wbCanvas.freeDrawingBrush.color = wbDrawingColorEl.value;
@@ -1873,10 +1882,12 @@ function handleRoomEmojiPicker() {
function loadSettingsFromLocalStorage() { function loadSettingsFromLocalStorage() {
rc.showChatOnMessage = lsSettings.show_chat_on_msg; rc.showChatOnMessage = lsSettings.show_chat_on_msg;
transcription.showOnMessage = lsSettings.show_transcript_on_msg;
rc.speechInMessages = lsSettings.speech_in_msg; rc.speechInMessages = lsSettings.speech_in_msg;
isPitchBarEnabled = lsSettings.pitch_bar; isPitchBarEnabled = lsSettings.pitch_bar;
isSoundEnabled = lsSettings.sounds; isSoundEnabled = lsSettings.sounds;
showChatOnMsg.checked = rc.showChatOnMessage; showChatOnMsg.checked = rc.showChatOnMessage;
transcriptShowOnMsg.checked = transcription.showOnMessage;
speechIncomingMsg.checked = rc.speechInMessages; speechIncomingMsg.checked = rc.speechInMessages;
switchPitchBar.checked = isPitchBarEnabled; switchPitchBar.checked = isPitchBarEnabled;
switchSounds.checked = isSoundEnabled; switchSounds.checked = isSoundEnabled;

عرض الملف

@@ -43,6 +43,7 @@ const html = {
const icons = { const icons = {
chat: '<i class="fas fa-comments"></i>', chat: '<i class="fas fa-comments"></i>',
transcript: '<i class="fas fa-closed-captioning"></i>',
speech: '<i class="fas fa-volume-high"></i>', speech: '<i class="fas fa-volume-high"></i>',
share: '<i class="fas fa-share-alt"></i>', share: '<i class="fas fa-share-alt"></i>',
ptt: '<i class="fa-solid fa-hand-pointer"></i>', ptt: '<i class="fa-solid fa-hand-pointer"></i>',
@@ -4367,6 +4368,19 @@ class RoomClient {
case 'speechMessages': case 'speechMessages':
this.userLog('info', `${icons.speech} Speech incoming messages ${status}`, 'top-end'); this.userLog('info', `${icons.speech} Speech incoming messages ${status}`, 'top-end');
break; break;
case 'showTranscript':
active
? userLog(
'info',
`${icons.transcript} Transcript will be shown, when you receive a message`,
'top-end',
)
: userLog(
'info',
`${icons.transcript} Transcript not will be shown, when you receive a message`,
'top-end',
);
break;
default: default:
break; break;
} }

عرض الملف

@@ -80,6 +80,7 @@ class Transcription {
this.transcripts = []; this.transcripts = [];
this.isBgTransparent = false; this.isBgTransparent = false;
this.isPinned = false; this.isPinned = false;
this.showOnMessage = true;
} }
isSupported() { isSupported() {
@@ -166,7 +167,13 @@ class Transcription {
const time_stamp = rc.getTimeNow(); const time_stamp = rc.getTimeNow();
const avatar_image = rc.genAvatarSvg(peer_name, 32); const avatar_image = rc.genAvatarSvg(peer_name, 32);
if (this.isHidden()) this.toggle(); if (this.isHidden()) {
if (this.showOnMessage) {
this.toggle();
} else {
this.handleTranscriptionPopup(transcriptionData);
}
}
const msgHTML = ` const msgHTML = `
<div class="msg-transcription left-msg-transcription"> <div class="msg-transcription left-msg-transcription">
@@ -190,6 +197,21 @@ class Transcription {
rc.sound('transcript'); rc.sound('transcript');
} }
handleTranscriptionPopup(transcriptionData, duration = 5000) {
const transcriptionDisplay = document.createElement('div');
transcriptionDisplay.className = 'animate__animated animate__fadeInUp';
transcriptionDisplay.style.padding = '10px';
transcriptionDisplay.style.fontSize = '1rem';
transcriptionDisplay.style.color = '#FFF';
transcriptionDisplay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
transcriptionDisplay.style.borderRadius = '10px';
transcriptionDisplay.innerText = `${transcriptionData.peer_name}: ${transcriptionData.text_data}`;
transcriptionPopup.appendChild(transcriptionDisplay);
setTimeout(() => {
transcriptionDisplay.remove();
}, duration);
}
isHidden() { isHidden() {
return Boolean(transcriptionRoom.style.display === 'none' || transcriptionRoom.style.display === ''); return Boolean(transcriptionRoom.style.display === 'none' || transcriptionRoom.style.display === '');
} }

عرض الملف

@@ -760,6 +760,12 @@ access to use this app.
<button id="transcriptionMaxBtn" class=""><i class="fas fa-expand"></i></button> <button id="transcriptionMaxBtn" class=""><i class="fas fa-expand"></i></button>
<button id="transcriptionMinBtn" class="hidden"><i class="fas fa-compress"></i></button> <button id="transcriptionMinBtn" class="hidden"><i class="fas fa-compress"></i></button>
<button id="transcriptionSpeechStatus" class="fas fa-microphone-alt"></button> <button id="transcriptionSpeechStatus" class="fas fa-microphone-alt"></button>
<div style="margin-left: 10px" class="title">
<i class="fa-solid fa-eye"></i>
<div style="margin-left: 5px" class="form-check form-switch form-switch-md">
<input class="form-check-input" type="checkbox" id="transcriptShowOnMsg" checked />
</div>
</div>
</div> </div>
<div class="transcription-header-options"> <div class="transcription-header-options">
<button id="transcriptionGhostBtn" class="fas fa-circle-half-stroke"></button> <button id="transcriptionGhostBtn" class="fas fa-circle-half-stroke"></button>
@@ -777,6 +783,8 @@ access to use this app.
</section> </section>
</section> </section>
<div id="transcriptionPopup" class="transcriptio-popup"></div>
<section id="lobby" class="fadein center hidden"> <section id="lobby" class="fadein center hidden">
<header id="lobbyHeader" class="lobby-header"> <header id="lobbyHeader" class="lobby-header">
<div id="lobbyHeaderTitle" class="lobby-header-title">Lobby users</div> <div id="lobbyHeaderTitle" class="lobby-header-title">Lobby users</div>