GUI: upload, live progress + ETA, delete; report thinking; docs twg fix
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
edb8ee3731
commit
cbe111bc34
+8
-4
@@ -39,14 +39,16 @@ def _decode(path):
|
||||
return np.frombuffer(raw, np.float32)
|
||||
|
||||
|
||||
def _cuda(audio, model, glossary):
|
||||
def _cuda(audio, model, glossary, tick=lambda done, total: None):
|
||||
import common
|
||||
m, dev = common.load_model(model)
|
||||
# ponytail: >~20 hotwords crowd whisper's prompt -> dropped text + repetition loops (seen with 60)
|
||||
kw = {"hotwords": " ".join(glossary[:20]), "condition_on_previous_text": False} if glossary else {}
|
||||
try:
|
||||
segs, _ = m.transcribe(str(audio), language="it", vad_filter=True, **kw)
|
||||
return [(s.start, s.end, s.text) for s in segs], dev
|
||||
segs, info = m.transcribe(str(audio), language="it", vad_filter=True, **kw)
|
||||
out = []
|
||||
for s in segs: out.append((s.start, s.end, s.text)); tick(s.end, info.duration)
|
||||
return out, dev
|
||||
finally:
|
||||
del m; gc.collect()
|
||||
|
||||
@@ -75,9 +77,11 @@ def run(name, model="large-v3-turbo", lang="it", device="cuda", out_path: Path |
|
||||
glossary = json.loads(gl.read_text(encoding="utf-8")) if gl.exists() else []
|
||||
t0 = time.time()
|
||||
if device == "npu":
|
||||
db.tick(name, 0, 0, "trascrizione su NPU (nessun avanzamento parziale)")
|
||||
segs, used = _npu(audio), "npu"
|
||||
else:
|
||||
segs, used = _cuda(audio, model, glossary)
|
||||
tick = lambda done, total: db.tick(name, round(done), round(total), f"{done / 60:.0f} di {total / 60:.0f} min di audio")
|
||||
segs, used = _cuda(audio, model, glossary, tick)
|
||||
lines = aggregate(segs)
|
||||
txt = "\n".join(f"[{t//60:02d}:{t%60:02d}] {x}" for t, x in lines)
|
||||
for l in txt.splitlines(): _log(l)
|
||||
|
||||
Reference in New Issue
Block a user