Sofia Casadei
commited on
Commit
ยท
f100c8a
1
Parent(s):
65dd135
up
Browse files- main.py +3 -3
- static/client.js +19 -11
- static/index-screen.html +1 -1
main.py
CHANGED
@@ -150,17 +150,17 @@ stream = Stream(
|
|
150 |
# If, after the user started speaking, there is a chunk with less than speech_threshold seconds of speech, the user stopped speaking. (default 0.1)
|
151 |
speech_threshold=0.1,
|
152 |
# Max duration of speech chunks before the handler is triggered, even if a pause is not detected by the VAD model. (default -inf)
|
153 |
-
max_continuous_speech_s=
|
154 |
),
|
155 |
model_options=SileroVadOptions(
|
156 |
# Threshold for what is considered speech (default 0.5)
|
157 |
threshold=0.5,
|
158 |
# Final speech chunks shorter min_speech_duration_ms are thrown out (default 250)
|
159 |
-
min_speech_duration_ms=
|
160 |
# Max duration of speech chunks, longer will be split at the timestamp of the last silence that lasts more than 100ms (if any) or just before max_speech_duration_s (default float('inf')) (used internally in the VAD algorithm to split the audio that's passed to the algorithm)
|
161 |
max_speech_duration_s=5,
|
162 |
# Wait for ms at the end of each speech chunk before separating it (default 2000)
|
163 |
-
min_silence_duration_ms=
|
164 |
# Chunk size for VAD model. Can be 512, 1024, 1536 for 16k s.r. (default 1024)
|
165 |
window_size_samples=1024,
|
166 |
# Final speech chunks are padded by speech_pad_ms each side (default 400)
|
|
|
150 |
# If, after the user started speaking, there is a chunk with less than speech_threshold seconds of speech, the user stopped speaking. (default 0.1)
|
151 |
speech_threshold=0.1,
|
152 |
# Max duration of speech chunks before the handler is triggered, even if a pause is not detected by the VAD model. (default -inf)
|
153 |
+
max_continuous_speech_s=15
|
154 |
),
|
155 |
model_options=SileroVadOptions(
|
156 |
# Threshold for what is considered speech (default 0.5)
|
157 |
threshold=0.5,
|
158 |
# Final speech chunks shorter min_speech_duration_ms are thrown out (default 250)
|
159 |
+
min_speech_duration_ms=250,
|
160 |
# Max duration of speech chunks, longer will be split at the timestamp of the last silence that lasts more than 100ms (if any) or just before max_speech_duration_s (default float('inf')) (used internally in the VAD algorithm to split the audio that's passed to the algorithm)
|
161 |
max_speech_duration_s=5,
|
162 |
# Wait for ms at the end of each speech chunk before separating it (default 2000)
|
163 |
+
min_silence_duration_ms=200,
|
164 |
# Chunk size for VAD model. Can be 512, 1024, 1536 for 16k s.r. (default 1024)
|
165 |
window_size_samples=1024,
|
166 |
# Final speech chunks are padded by speech_pad_ms each side (default 400)
|
static/client.js
CHANGED
@@ -136,7 +136,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
136 |
const connectionTimeout = setTimeout(() => {
|
137 |
if (peerConnection && peerConnection.connectionState !== 'connected') {
|
138 |
showError('Connection timeout. Please check your network and try again.');
|
139 |
-
stop(); //
|
140 |
}
|
141 |
}, 15000);
|
142 |
|
@@ -371,7 +371,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
371 |
}
|
372 |
|
373 |
// Stop recording and clean up resources
|
374 |
-
function stop() {
|
375 |
console.log('Stopping recording...');
|
376 |
// Stop audio visualization
|
377 |
if (animationFrame) {
|
@@ -411,22 +411,30 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
411 |
// Update button display
|
412 |
updateButtonState();
|
413 |
|
414 |
-
//
|
415 |
-
if (
|
416 |
-
//
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
// Just end current paragraph
|
421 |
-
if (currentParagraph) {
|
422 |
-
currentParagraph.classList.remove('current');
|
423 |
currentParagraph = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
}
|
425 |
}
|
426 |
|
427 |
// Reset timestamp
|
428 |
lastUpdateTime = Date.now();
|
429 |
console.log('Recording stopped');
|
|
|
|
|
|
|
|
|
|
|
430 |
}
|
431 |
|
432 |
// Clean up resources when page is closed
|
|
|
136 |
const connectionTimeout = setTimeout(() => {
|
137 |
if (peerConnection && peerConnection.connectionState !== 'connected') {
|
138 |
showError('Connection timeout. Please check your network and try again.');
|
139 |
+
stop(true); // Restart connection on timeout
|
140 |
}
|
141 |
}, 15000);
|
142 |
|
|
|
371 |
}
|
372 |
|
373 |
// Stop recording and clean up resources
|
374 |
+
function stop(restartOnTimeout = false) {
|
375 |
console.log('Stopping recording...');
|
376 |
// Stop audio visualization
|
377 |
if (animationFrame) {
|
|
|
411 |
// Update button display
|
412 |
updateButtonState();
|
413 |
|
414 |
+
// Skip transcript clearing if restarting on timeout
|
415 |
+
if (!restartOnTimeout) {
|
416 |
+
// Ask about clearing transcript
|
417 |
+
if (window.confirm('Clear transcript?')) {
|
418 |
+
// Clear all transcript text
|
419 |
+
transcriptDiv.innerHTML = '';
|
|
|
|
|
|
|
420 |
currentParagraph = null;
|
421 |
+
} else {
|
422 |
+
// Just end current paragraph
|
423 |
+
if (currentParagraph) {
|
424 |
+
currentParagraph.classList.remove('current');
|
425 |
+
currentParagraph = null;
|
426 |
+
}
|
427 |
}
|
428 |
}
|
429 |
|
430 |
// Reset timestamp
|
431 |
lastUpdateTime = Date.now();
|
432 |
console.log('Recording stopped');
|
433 |
+
|
434 |
+
// Restart connection if requested
|
435 |
+
if (restartOnTimeout) {
|
436 |
+
setupWebRTC();
|
437 |
+
}
|
438 |
}
|
439 |
|
440 |
// Clean up resources when page is closed
|
static/index-screen.html
CHANGED
@@ -54,7 +54,7 @@
|
|
54 |
background: transparent; /* Transparent background (no highlighting) */
|
55 |
border-radius: 0; /* No rounded corners */
|
56 |
line-height: 1.6; /* Increases line spacing for readability */
|
57 |
-
font-size:
|
58 |
font-weight: 500; /* 500 = medium weight, 700 = bold */
|
59 |
max-width: 98%; /* Full width within container */
|
60 |
white-space: normal; /* Allows text to wrap normally */
|
|
|
54 |
background: transparent; /* Transparent background (no highlighting) */
|
55 |
border-radius: 0; /* No rounded corners */
|
56 |
line-height: 1.6; /* Increases line spacing for readability */
|
57 |
+
font-size: 10rem; /* rem means relative to the root font size */
|
58 |
font-weight: 500; /* 500 = medium weight, 700 = bold */
|
59 |
max-width: 98%; /* Full width within container */
|
60 |
white-space: normal; /* Allows text to wrap normally */
|