feat(events): 实现转写完成后的文件清理功能

- 新增 events 模块,包括 handlers 和 signals 子模块
- 在 handlers 中实现 cleanup_temp_files 函数,用于清理转写临时文件
- 在 signals 中定义 transcription_finished 信号
- 修改 main.py,添加 startup_event 函数以注册事件处理器- 更新 WhisperTranscriber 类,增加 on_finish 方法并发送转写完成信号
- 在 base.py 中添加 TranscriberBase 类的 on_finish 方法占位符
This commit is contained in:
Jefferyhcool
2025-04-13 23:29:33 +08:00
parent 595a38723f
commit 43b88c85fa
7 changed files with 62 additions and 26 deletions

View File

@@ -0,0 +1,8 @@
# 注册监听器
from events.handlers import cleanup_temp_files
from events.signals import transcription_finished
def register_handler():
transcription_finished.connect(cleanup_temp_files)

View File

@@ -0,0 +1,8 @@
import os
def cleanup_temp_files(data):
print(f"🧹 清理转写文件:{data['file_path']}")
os.remove(data['file_path'])

View File

@@ -0,0 +1,2 @@
from blinker import signal
transcription_finished = signal("transcription_finished")