fix: error state resettable via mic click, debug logging, pipeline traceback

This commit is contained in:
2026-04-01 12:41:45 +02:00
parent 6574481647
commit 6e317a9c67
4 changed files with 20 additions and 3 deletions
+6
View File
@@ -1,7 +1,11 @@
import logging
import os
import tempfile
import traceback
from api.state import state, Status
logger = logging.getLogger(__name__)
from config import load as load_config
from transcription import engine as transcription_engine
from llm import OllamaClient
@@ -59,6 +63,8 @@ async def run_pipeline():
await state.set_status(Status.IDLE)
except Exception as e:
tb = traceback.format_exc()
logger.error("Pipeline error:\n%s", tb)
state.last_error = str(e)
await state.set_status(Status.ERROR)
await broadcast({"event": "error", "message": str(e)})
+3
View File
@@ -97,6 +97,9 @@ async def toggle_recording(user: dict = Depends(current_user)):
if state.status == Status.RECORDING:
asyncio.create_task(run_pipeline())
return {"action": "stopped"}
if state.status == Status.ERROR:
await state.set_status(Status.IDLE)
return {"action": "reset"}
if state.status == Status.IDLE:
from audio import AudioRecorder
state._recorder = AudioRecorder()
+10 -2
View File
@@ -47,12 +47,20 @@ function setStatus(status) {
btn.className = status;
headerStatus.className = `status-badge ${status}`;
const label = STATUS_LABELS[status] || status;
statusText.textContent = label;
statusText.textContent = status === 'error' ? label + ' — klicken zum Zurücksetzen' : label;
headerStatus.textContent = label;
btn.disabled = status === 'processing';
}
btn.addEventListener('click', () => apiFetch('/toggle', { method: 'POST' }));
btn.addEventListener('click', async () => {
const r = await apiFetch('/toggle', { method: 'POST' });
const data = await r.json();
if (data.action === 'reset') {
preview.textContent = 'Noch keine Aufnahme verarbeitet.';
preview.classList.remove('has-content');
setStatus('idle');
}
});
function connectWs() {
const proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
+1 -1
View File
@@ -137,7 +137,7 @@ if __name__ == "__main__":
write_pid(pid_path)
signal.signal(signal.SIGUSR1, _sigusr1_handler)
uvicorn_cfg = uvicorn.Config(app, host=host, port=port, log_level="warning")
uvicorn_cfg = uvicorn.Config(app, host=host, port=port, log_level="debug")
server_thread = threading.Thread(target=run_server, args=(uvicorn_cfg,), daemon=True)
server_thread.start()