feat(transcriber): 更新转录器支持和模型下载逻辑

- 修改 NoteGenerator 类以支持动态选择转录器类型。
- 更新 MLXWhisperTranscriber 类,添加模型下载逻辑,确保模型存在时自动下载。
- 在 transcriber_provider.py 中优化 MLX Whisper 的环境变量处理,确保在不可用时回退到 fast-whisper。
This commit is contained in:
SurfRid3r
2025-04-20 22:50:07 +08:00
parent 369de19572
commit a567788448
3 changed files with 18 additions and 12 deletions
+4 -4
View File
@@ -18,7 +18,7 @@ from app.models.notes_model import AudioDownloadResult
from app.enmus.note_enums import DownloadQuality
from app.models.transcriber_model import TranscriptResult
from app.transcriber.base import Transcriber
from app.transcriber.transcriber_provider import get_transcriber
from app.transcriber.transcriber_provider import get_transcriber,_transcribers
from app.transcriber.whisper import WhisperTranscriber
import re
@@ -89,9 +89,9 @@ class NoteGenerator:
:param transcriber: 选择的转义器
:return:
'''
if self.transcriber_type == 'fast-whisper':
logger.info("使用Whisper")
return get_transcriber(transcriber_type='fast-whisper')
if self.transcriber_type in _transcribers.keys():
logger.info(f"使用{self.transcriber_type}转义器")
return get_transcriber(transcriber_type=self.transcriber_type)
else:
logger.warning("不支持的转义器")
raise ValueError(f"不支持的转义器:{self.transcriber}")