OrbiSubs: English subtitle track translated by the gpu02 LLM (separate process)
orbisubs.py escribe la cola cues.jsonl y anuncia la pista en el master (--en); orbisubs_tr.py junta frases, traduce con Qwen (sin thinking, contexto de la frase anterior) y escribe en/<seq>.vtt + en.m3u8. Tarea 077.
This commit is contained in:
+10
@@ -251,6 +251,7 @@ def main():
|
||||
ap.add_argument("--bandwidth", type=int, default=2600000)
|
||||
ap.add_argument("--resolution", default="1280x720")
|
||||
ap.add_argument("--metrics", default=None)
|
||||
ap.add_argument("--en", action="store_true", help="anunciar la pista English (la escribe orbisubs_tr.py)")
|
||||
a = ap.parse_args()
|
||||
|
||||
t = time.time()
|
||||
@@ -266,6 +267,8 @@ def main():
|
||||
os.makedirs(subs_dir, exist_ok=True)
|
||||
tr = Transcriptor(motor, a.hold, max_buf=20.0)
|
||||
met = open(a.metrics, "a") if a.metrics else None
|
||||
# Cola para el traductor (otro proceso): si el Qwen se cuelga, este loop ni se entera.
|
||||
cola = open(os.path.join(a.dir, "cues.jsonl"), "w") if a.en else None
|
||||
|
||||
llegada = {} # seq -> reloj de pared en que apareció en la lista de ffmpeg
|
||||
info = {} # seq -> (uri, dur, pdt, pts_ini, pts_fin)
|
||||
@@ -276,6 +279,9 @@ def main():
|
||||
"#EXTM3U\n#EXT-X-VERSION:3\n"
|
||||
'#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Español (automático)",LANGUAGE="es",'
|
||||
'DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,URI="subs.m3u8"\n'
|
||||
+ ('#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English (automatic)",LANGUAGE="en",'
|
||||
'DEFAULT=NO,AUTOSELECT=NO,FORCED=NO,URI="en.m3u8"\n' if a.en else "")
|
||||
+
|
||||
f'#EXT-X-STREAM-INF:BANDWIDTH={a.bandwidth},RESOLUTION={a.resolution},SUBTITLES="subs"\n'
|
||||
"video.m3u8\n")
|
||||
|
||||
@@ -336,6 +342,10 @@ def main():
|
||||
cuerpo += [f"{ts_vtt(c0)} --> {ts_vtt(c1)}", partir_lineas(txt), ""]
|
||||
escribir_atomico(os.path.join(subs_dir, f"{s}.vtt"), "\n".join(cuerpo) + "\n")
|
||||
publicado = s
|
||||
if cola:
|
||||
cola.write(json.dumps({"seq": seq, "s0": p0, "s1": p0 + dur, "listo": listo_hasta,
|
||||
"cues": nuevos_cues}, ensure_ascii=False) + "\n")
|
||||
cola.flush()
|
||||
# Listas publicadas: video sostenido hasta el último segmento con subtítulo.
|
||||
ventana = [x for x in segs if x[0] <= publicado][-a.window:]
|
||||
if ventana:
|
||||
|
||||
Reference in New Issue
Block a user