mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-05-11 09:59:46 +08:00
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:
8
backend/events/__init__.py
Normal file
8
backend/events/__init__.py
Normal 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)
|
||||
|
||||
8
backend/events/handlers.py
Normal file
8
backend/events/handlers.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import os
|
||||
|
||||
|
||||
def cleanup_temp_files(data):
|
||||
print(f"🧹 清理转写文件:{data['file_path']}")
|
||||
os.remove(data['file_path'])
|
||||
|
||||
|
||||
2
backend/events/signals.py
Normal file
2
backend/events/signals.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from blinker import signal
|
||||
transcription_finished = signal("transcription_finished")
|
||||
Reference in New Issue
Block a user