feat功能): 完善字幕引擎并添加字幕记录导出功能

- 丰富了 README.md 文件,介绍了字幕引擎的原理和构建方法
- 更新了 .gitignore 文件,排除了 build 目录
- 移除了 python-prototype 和 python-subprocess 目录下的无用代码
- 添加了字幕记录导出功能,用户可以将字幕数据导出为 JSON 文件
- 调整了字幕控制面板,移除了未使用的 Whisper 引擎选项
This commit is contained in:
himeditator
2025-06-21 20:35:49 +08:00
parent c446f846bd
commit 7030aaaae3
8 changed files with 81 additions and 138 deletions

View File

@@ -0,0 +1,38 @@
# -*- mode: python ; coding: utf-8 -*-
a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)

View File

@@ -1,61 +0,0 @@
import json
import websockets
class WebSocketServer:
def __init__(self):
self.server = None
self.websocket = None
async def start(self, port=8765):
"""启动 WebSocket 服务器"""
self.server = await websockets.serve(self.handle_client, "localhost", port)
print(f"INFO websocket server started on ws://localhost:{port}")
async def stop(self):
"""关闭 WebSocket 服务器"""
if self.server:
try:
if self.websocket:
await self.close()
self.server.close()
await self.server.wait_closed()
print("INFO server closed successfully")
except Exception as e:
print(f"ERROR failed to close server: {e}")
finally:
self.server = None
async def handle_client(self, websocket, path="/"):
"""处理客户端连接"""
try:
self.websocket = websocket
async for message in websocket:
print(f"INFO received: {message}")
except websockets.exceptions.ConnectionClosed:
print("INFO client disconnected")
self.websocket = None
async def send(self, data):
"""向连接的客户端发送数据"""
if self.websocket:
try:
await self.websocket.send(json.dumps(data))
print(f"INFO sent: {data}")
return True
except websockets.exceptions.ConnectionClosed:
print("ERROR: Client disconnected while sending data")
self.websocket = None
return False
return False
async def close(self):
"""安全地断开WebSocket连接"""
if self.websocket:
try:
await self.websocket.close()
print("INFO connection closed successfully")
except Exception as e:
print(f"ERROR failed to close connection: {e}")
finally:
self.websocket = None