feat(auto-caption): 发布 v0.7.0 版本

This commit is contained in:
himeditator
2025-08-20 00:53:06 +08:00
parent 771f7ad002
commit 34362fea3d
24 changed files with 164 additions and 70 deletions

View File

@@ -1,5 +1,5 @@
import argparse
from utils import stdout_cmd, stderr
from utils import stdout_cmd, stdout_err
from utils import thread_data, start_server
from utils import merge_chunk_channels, resample_chunk_mono
from audio2text import InvalidParameter, GummyRecognizer
@@ -17,6 +17,7 @@ def main_gummy(s: str, t: str, a: int, c: int, k: str):
stream.open_stream()
engine.start()
chunk_mono = bytes()
restart_count = 0
while thread_data.status == "running":
@@ -28,15 +29,17 @@ def main_gummy(s: str, t: str, a: int, c: int, k: str):
engine.send_audio_frame(chunk_mono)
except InvalidParameter as e:
restart_count += 1
if restart_count > 8:
stderr(str(e))
if restart_count > 5:
stdout_err(str(e))
thread_data.status = "kill"
stdout_cmd('kill')
break
else:
stdout_cmd('info', f'Gummy engine stopped, trying to restart #{restart_count}')
stdout_cmd('info', f'Gummy engine stopped, restart attempt: {restart_count}...')
except KeyboardInterrupt:
break
engine.send_audio_frame(chunk_mono)
stream.close_stream()
engine.stop()

View File

@@ -4,6 +4,6 @@ from .audioprcs import (
resample_chunk_mono_np,
resample_mono_chunk
)
from .sysout import stdout, stdout_cmd, stdout_obj, stderr
from .sysout import stdout, stdout_err, stdout_cmd, stdout_obj, stderr
from .thdata import thread_data
from .server import start_server

View File

@@ -4,6 +4,9 @@ import json
def stdout(text: str):
stdout_cmd("print", text)
def stdout_err(text: str):
stdout_cmd("error", text)
def stdout_cmd(command: str, content = ""):
msg = { "command": command, "content": content }
sys.stdout.write(json.dumps(msg) + "\n")