Spaces:
Running
Running
Commit
·
4a0564f
1
Parent(s):
3cb4983
Fix typo
Browse files
app.py
CHANGED
@@ -92,7 +92,7 @@ async def load_models():
|
|
92 |
forced = processor.get_decoder_prompt_ids(task="transcribe", language="english")
|
93 |
model.config.forced_decoder_ids = forced
|
94 |
model.to("cpu").eval()
|
95 |
-
|
96 |
|
97 |
@app.get("/")
|
98 |
async def root() -> FileResponse: # serve SPA
|
@@ -112,7 +112,9 @@ def call_gemini(prompt: str, vision_parts=None) -> str:
|
|
112 |
resp = client.models.generate_content(
|
113 |
model="gemini-2.5-flash-preview-04-17", **kwargs
|
114 |
)
|
115 |
-
|
|
|
|
|
116 |
|
117 |
@app.post("/voice-transcribe")
|
118 |
async def voice_transcribe(file: UploadFile = File(...)):
|
@@ -130,7 +132,7 @@ async def voice_transcribe(file: UploadFile = File(...)):
|
|
130 |
question = processor.decode(ids[0], skip_special_tokens=True).strip()
|
131 |
if not question:
|
132 |
raise ValueError("No speech detected")
|
133 |
-
|
134 |
answer = call_gemini(build_prompt(question))
|
135 |
return JSONResponse({"question": question, "answer": answer, "memory_mb": memory_mb()})
|
136 |
finally:
|
|
|
92 |
forced = processor.get_decoder_prompt_ids(task="transcribe", language="english")
|
93 |
model.config.forced_decoder_ids = forced
|
94 |
model.to("cpu").eval()
|
95 |
+
logger.info("[MODEL] 🔊 Whisper loaded ✔")
|
96 |
|
97 |
@app.get("/")
|
98 |
async def root() -> FileResponse: # serve SPA
|
|
|
112 |
resp = client.models.generate_content(
|
113 |
model="gemini-2.5-flash-preview-04-17", **kwargs
|
114 |
)
|
115 |
+
response = resp.text.strip()
|
116 |
+
logger.info(f"[LLM] Response: {response}")
|
117 |
+
return response
|
118 |
|
119 |
@app.post("/voice-transcribe")
|
120 |
async def voice_transcribe(file: UploadFile = File(...)):
|
|
|
132 |
question = processor.decode(ids[0], skip_special_tokens=True).strip()
|
133 |
if not question:
|
134 |
raise ValueError("No speech detected")
|
135 |
+
logger.info(f"[MODEL] Transcribed text: {question}")
|
136 |
answer = call_gemini(build_prompt(question))
|
137 |
return JSONResponse({"question": question, "answer": answer, "memory_mb": memory_mb()})
|
138 |
finally:
|