-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
124 lines (109 loc) · 5.01 KB
/
index.html
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Speech to Text Application</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<img src="logo.png">
<h1>TRANSCRIPTION APP | ZAMBIA UNIVERSITY COLLEGE OF TECHNOLOGY</h1>
</header>
<main>
<button id="start-btn">Start Listening</button>
<button id="stop-btn" style="display:none;">Stop Listening</button>
<button id="open-transcription-btn">Open Transcriptions</button>
<p id="transcript">Transcription: </p>
<div class="main-content">
<div class="main-content-item">
<img src="Text_to_speech_2.png" alt="Speech to Text image one">
<p>
The core innovation for this project lies in optimising existing speech-to-text algorithms to accurately interpret the niche vocabulary and spontaneous dialogues common
in academic discourses. By training the models on diverse educational speech data, the transcription-app renders precise automated transcripts tailored
to academic subjects and terminology. As teachers give lessons or lead learner discussions, the app listens in and immediately generates corresponding
text reports viewable by learners and teachers alike. This relieves manual note-taking burdens while still providing text references of lessons and talking
points.
</p>
</div>
</div>
</main>
<footer>
<p>© 2023 TRANSCRIPTION APP | AGNESS SANGA :2110516, ANGELA MAZILA :2110523, EMELDA CHILUFYA: 2110524 AND GETRUDE MULENGA: 2110621</p>
</footer>
<script>
function addPunctuation(transcript) {
// Basic rule: add a period after each sentence
var sentences = transcript.split('.');
var punctuatedText = sentences.map(sentence => sentence.trim() + '.').join(' ');
return punctuatedText;
}
</script>
<script>
var startBtn = document.getElementById('start-btn');
var stopBtn = document.getElementById('stop-btn');
var transcriptParagraph = document.getElementById('transcript');
var recognition;
if ('webkitSpeechRecognition' in window) {
recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
recognition.onstart = function() {
startBtn.style.display = 'none';
stopBtn.style.display = 'inline';
};
recognition.onerror = function(event) {
console.error('Speech recognition error', event);
};
recognition.onend = function() {
startBtn.style.display = 'inline';
stopBtn.style.display = 'none';
};
recognition.onresult = function(event) {
var interim_transcript = '';
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
transcriptParagraph.textContent = event.results[i][0].transcript;
sendToServer(event.results[i][0].transcript);
} else {
interim_transcript += event.results[i][0].transcript;
transcriptParagraph.textContent = interim_transcript;
}
}
};
startBtn.onclick = function() {
recognition.start();
};
stopBtn.onclick = function() {
recognition.stop();
};
document.getElementById('open-transcription-btn').onclick = function() {
window.open('transcriptions.txt', '_blank');
};
} else {
alert("Web Speech API is not supported in this browser.");
}
function sendToServer(transcript) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'save_transcription.php', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send('transcription=' + encodeURIComponent(transcript));
}
</script>
recognition.onresult = function (event) {
var interim_transcript = '';
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
var spokenText = event.results[i][0].transcript;
transcriptParagraph.textContent = addPunctuation(spokenText);
sendToServer(spokenText);
} else {
interim_transcript += event.results[i][0].transcript;
transcriptParagraph.textContent = addPunctuation(interim_transcript);
}
}
};
</script>
</body>
</html>