added visual waiting steps
All checks were successful
Deploy FluentGerman.ai / deploy (push) Successful in 52s
All checks were successful
Deploy FluentGerman.ai / deploy (push) Successful in 52s
This commit is contained in:
@@ -160,7 +160,6 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
const text = inputEl.value.trim();
|
||||
if (!text) return;
|
||||
|
||||
const wasVoice = voice.lastInputWasVoice;
|
||||
voice.lastInputWasVoice = false;
|
||||
|
||||
inputEl.value = '';
|
||||
@@ -169,7 +168,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
appendMessage('user', text);
|
||||
history.push({ role: 'user', content: text });
|
||||
|
||||
const assistantEl = appendMessage('assistant', '');
|
||||
const assistantEl = appendMessage('assistant', voiceModeOn ? 'Thinking...' : '');
|
||||
let fullResponse = '';
|
||||
|
||||
try {
|
||||
@@ -188,9 +187,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
|
||||
// Special handling for Voice Mode: Buffer text, wait for TTS, then show & play
|
||||
if (voiceModeOn) {
|
||||
// Show thinking state
|
||||
assistantEl.innerHTML = '<span class="thinking-dots">Thinking<span>.</span><span>.</span><span>.</span></span>';
|
||||
assistantEl.classList.add('message-thinking');
|
||||
// "Thinking..." is already shown from appendMessage above
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
|
||||
@@ -147,6 +147,8 @@ class VoiceManager {
|
||||
stopRecording() {
|
||||
if (this.mode === 'api') {
|
||||
if (this.mediaRecorder?.state === 'recording') {
|
||||
// Show processing state immediately (don't wait for onstop callback)
|
||||
if (this.onProcessing) this.onProcessing(true);
|
||||
this.mediaRecorder.stop();
|
||||
} else {
|
||||
this.isRecording = false;
|
||||
@@ -240,17 +242,20 @@ class VoiceManager {
|
||||
return new Promise(resolve => {
|
||||
audio.onended = () => {
|
||||
if (avatarContainer) avatarContainer.classList.remove('speaking');
|
||||
URL.revokeObjectURL(audioUrl);
|
||||
resolve();
|
||||
};
|
||||
// Handle errors during playback (e.g. format issues)
|
||||
audio.onerror = () => {
|
||||
if (avatarContainer) avatarContainer.classList.remove('speaking');
|
||||
URL.revokeObjectURL(audioUrl);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("Playback failed", e);
|
||||
if (avatarContainer) avatarContainer.classList.remove('speaking');
|
||||
URL.revokeObjectURL(audioUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user