Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
willwade committed Nov 1, 2024
2 parents 6a71382 + 3c9fa19 commit 4887ae4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions nodejs/sender-monitor/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,26 +125,25 @@ async function captureAndProcessScreen() {
}

const translator = new Translator({
from: config.translation.sourceLang,
to: config.translation.targetLang,
autoCorrect: config.translation.autoCorrect,
from: config.translation?.sourceLang || "en",
to: config.translation?.targetLang || "es",
autoCorrect: config.translation?.autoCorrect || false,
forceBatch: false,
tld: "com",
});

async function processAndSendText(text) {
if (text && text !== lastText && isConnected && webrtc.isChannelOpen()) {
if (config.translation.enabled) {
if (config.translation?.enabled || false) {
try {
const translated = await translator.translate(text);
text = translated.text; // Update text with the translated version
text = translated.text;
console.log(`Translated text: ${text}`);
} catch (error) {
console.error("Translation error:", error);
}
}

// Send the (translated or original) text to the display
webrtc.sendMessage(text);
lastText = text;
console.log(`Text sent to display: ${text}`);
Expand Down

0 comments on commit 4887ae4

Please sign in to comment.