-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (55 loc) · 2.03 KB
/
script.js
File metadata and controls
67 lines (55 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
let recognition;
let isDarkMode = true;
let savedSentences = []; //Mitschrift im Textfile
function startRecognition() {
if (!('webkitSpeechRecognition' in window)) {
alert('Dein Browser unterstützt keine Sprachaufnahme.');
return;
}
recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
recognition.lang = document.getElementById('language').value;
recognition.onresult = function(event) {
let finalTranscript = savedSentences.join('\n') + '\n';
for (let i = event.resultIndex; i < event.results.length; ++i) {
const result = event.results[i];
const text = result[0].transcript.trim();
if (result.isFinal) {
savedSentences.push(text); // Finaler Satz -> speichern
finalTranscript += text + '\n';
} else {
finalTranscript += text + '...';
}
}
document.getElementById('transcript').innerText = finalTranscript;
};
recognition.start();
}
function setFontSize(size) {
const transcript = document.getElementById('transcript');
if (size === 'small') {
transcript.style.fontSize = '0.9em';
} else if (size === 'medium') {
transcript.style.fontSize = '1.2em';
} else if (size === 'large') {
transcript.style.fontSize = '1.5em';
}
}
function toggleDarkMode() {
isDarkMode = !isDarkMode;
document.body.style.backgroundColor = isDarkMode ? '#0f0c24' : '#ffffff';
document.querySelector('.container').style.backgroundColor = isDarkMode ? '#18122b' : '#f0f0f0';
document.body.style.color = isDarkMode ? '#ffffff' : '#000000';
const transcriptBox = document.getElementById("transcript");
transcriptBox.style.backgroundColor = isDarkMode ? '#1f1b3a' : '#f0f0f0';
transcriptBox.style.color = isDarkMode ? '#ffffff' : '#000000';
}
function saveTranscript() {
const text = savedSentences.join('\n');
const blob = new Blob([text], { type: 'text/plain' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'transkript.txt';
link.click();
}