Commit 37df61f9 authored by Your Name's avatar Your Name

Fix whisper-server: check for whisper-server FIRST in transcription endpoint

- Move whisper-server check before audio_model check
- Now whisper-server will be used if available, regardless of audio_model setting
- Also update multi_model_manager.audio_models with cached path
parent bbf12dd4
......@@ -2693,26 +2693,27 @@ async def create_transcription(
- Local faster-whisper models (when --audio-model is specified)
- whisper.cpp server (when --whisper-server is specified)
"""
# Check if whisper-server is available FIRST (before checking audio_model)
if multi_model_manager.whisper_server and multi_model_manager.whisper_server.is_running():
# Use whisper-server - read file and send to server
file_content = await file.read()
result = multi_model_manager.whisper_server.transcribe(
file_content,
language=language,
prompt=prompt
)
if "error" in result:
raise HTTPException(status_code=500, detail=result["error"])
# Convert whisper-server response to OpenAI format
text = result.get("text", "")
return {
"text": text
}
audio_model = multi_model_manager.audio_model
# If no audio model configured, return an error
if not audio_model:
# Check if whisper-server is available
if multi_model_manager.whisper_server and multi_model_manager.whisper_server.is_running():
# Use whisper-server - read file and send to server
file_content = await file.read()
result = multi_model_manager.whisper_server.transcribe(
file_content,
language=language,
prompt=prompt
)
if "error" in result:
raise HTTPException(status_code=500, detail=result["error"])
# Convert whisper-server response to OpenAI format
text = result.get("text", "")
return {
"text": text
}
raise HTTPException(
status_code=400,
detail="Audio transcription not configured. Use --audio-model or --whisper-server to specify a model."
......@@ -4459,13 +4460,11 @@ def main():
gpu_device = getattr(args, 'audio_vulkan_device', 0) or 0
actual_model_path = whisper_server_mgr.start(model_path=model_to_use, gpu_device=gpu_device)
if actual_model_path:
# Update audio_models to store the actual path (not the URL)
# Update audio_models in multi_model_manager to store the actual path (not the URL)
if model_to_use != actual_model_path:
audio_models[0] = actual_model_path
multi_model_manager.set_audio_model(actual_model_path, {
'ctx': args.audio_ctx,
'offload': args.audio_offload,
})
# Update the manager's audio_models list
if multi_model_manager.audio_models and multi_model_manager.audio_models[0] == model_to_use:
multi_model_manager.audio_models[0] = actual_model_path
print(f"Whisper server started with model: {actual_model_path}")
else:
print("Warning: Failed to start whisper-server, falling back to other backends")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment