fix: error state resettable via mic click, debug logging, pipeline traceback
This commit is contained in:
@@ -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)})
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user