Update app.py
Browse files
app.py
CHANGED
@@ -92,11 +92,11 @@ html_code = """
|
|
92 |
const response = document.getElementById('response');
|
93 |
let mediaRecorder;
|
94 |
let audioChunks = [];
|
95 |
-
let
|
96 |
|
97 |
micButton.addEventListener('click', () => {
|
98 |
-
if (!
|
99 |
-
|
100 |
startConversation();
|
101 |
}
|
102 |
});
|
@@ -151,7 +151,7 @@ html_code = """
|
|
151 |
|
152 |
if (data.response.includes("Goodbye")) {
|
153 |
status.textContent = 'Conversation ended. Press the mic button to start again.';
|
154 |
-
|
155 |
} else {
|
156 |
status.textContent = 'Listening...';
|
157 |
setTimeout(startListening, 1000);
|
@@ -160,13 +160,13 @@ html_code = """
|
|
160 |
response.textContent = 'Error occurred. Please try again.';
|
161 |
response.style.display = 'block';
|
162 |
status.textContent = 'Press the mic button to restart the conversation.';
|
163 |
-
|
164 |
}
|
165 |
};
|
166 |
setTimeout(() => mediaRecorder.stop(), 10000); // Wait for 10 seconds of speaking time
|
167 |
}).catch(() => {
|
168 |
status.textContent = 'Microphone access denied.';
|
169 |
-
|
170 |
});
|
171 |
}
|
172 |
</script>
|
|
|
92 |
const response = document.getElementById('response');
|
93 |
let mediaRecorder;
|
94 |
let audioChunks = [];
|
95 |
+
let isListening = false;
|
96 |
|
97 |
micButton.addEventListener('click', () => {
|
98 |
+
if (!isListening) {
|
99 |
+
isListening = true;
|
100 |
startConversation();
|
101 |
}
|
102 |
});
|
|
|
151 |
|
152 |
if (data.response.includes("Goodbye")) {
|
153 |
status.textContent = 'Conversation ended. Press the mic button to start again.';
|
154 |
+
isListening = false;
|
155 |
} else {
|
156 |
status.textContent = 'Listening...';
|
157 |
setTimeout(startListening, 1000);
|
|
|
160 |
response.textContent = 'Error occurred. Please try again.';
|
161 |
response.style.display = 'block';
|
162 |
status.textContent = 'Press the mic button to restart the conversation.';
|
163 |
+
isListening = false;
|
164 |
}
|
165 |
};
|
166 |
setTimeout(() => mediaRecorder.stop(), 10000); // Wait for 10 seconds of speaking time
|
167 |
}).catch(() => {
|
168 |
status.textContent = 'Microphone access denied.';
|
169 |
+
isListening = false;
|
170 |
});
|
171 |
}
|
172 |
</script>
|