Skip to content

Commit 15b7779

Browse files
committed
fix
1 parent 2545c6b commit 15b7779

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

app/core/subtitle_processor/spliter.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ..bk_asr.ASRData import ASRData, from_srt, ASRDataSeg
99
from ..utils.logger import setup_logger
1010

11-
logger = setup_logger("subtitle_spliter", level=logging.DEBUG)
11+
logger = setup_logger("subtitle_spliter")
1212

1313
SEGMENT_THRESHOLD = 500 # 每个分段的最大字数
1414
FIXED_NUM_THREADS = 4 # 固定的线程数量
@@ -145,12 +145,12 @@ def merge_segments_based_on_sentences(asr_data: ASRData, sentences: List[str]) -
145145
new_segments.extend(split_segs)
146146
else:
147147
new_segments.append(merged_seg)
148-
max_shift = 100
148+
max_shift = 30
149149
asr_index = end_seg_index + 1 # 移动到下一个未处理的分段
150150
else:
151151
logger.warning(f"无法匹配句子: {sentence}")
152-
max_shift = 30
153-
asr_index += 1
152+
max_shift = 100
153+
asr_index = end_seg_index + 1
154154

155155
return ASRData(new_segments)
156156

@@ -243,7 +243,6 @@ def split_asr_data(asr_data: ASRData, num_segments: int) -> List[ASRData]:
243243
"""
244244
total_segs = len(asr_data.segments)
245245
total_word_count = count_words(asr_data.to_txt())
246-
print(f"总字数: {total_word_count}")
247246
words_per_segment = total_word_count // num_segments
248247
split_indices = []
249248

@@ -349,7 +348,6 @@ def process_segment(asr_data_part):
349348
txt = asr_data_part.to_txt().replace("\n", "")
350349
sentences = split_by_llm(txt, model=model, use_cache=True)
351350
logger.info(f"分段的句子提取完成,共 {len(sentences)} 句")
352-
print(f"sentences: {sentences}")
353351

354352
return sentences
355353

app/core/thread/transcript_thread.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,13 @@ def run(self):
9999
logger.info("字幕文件已保存到: %s", str(original_subtitle_path))
100100

101101
# 删除音频文件 和 封面
102-
audio_save_path.unlink()
103-
thumbnail_path = Path(self.task.video_info.thumbnail_path)
104-
if thumbnail_path.exists():
105-
thumbnail_path.unlink()
102+
try:
103+
audio_save_path.unlink()
104+
thumbnail_path = Path(self.task.video_info.thumbnail_path)
105+
if thumbnail_path.exists():
106+
thumbnail_path.unlink()
107+
except Exception as e:
108+
logger.error("删除音频文件或封面失败: %s", str(e))
106109

107110
self.progress.emit(100, self.tr("转录完成"))
108111
self.finished.emit(self.task)

app/view/subtitle_style_interface.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ def _initStyle(self):
315315

316316
def __setValues(self):
317317
"""设置初始值"""
318+
# 设置字幕排布
319+
self.layoutCard.comboBox.setCurrentText(cfg.get(cfg.subtitle_layout))
320+
# 设置字幕样式
321+
self.styleNameComboBox.comboBox.setCurrentText(cfg.get(cfg.subtitle_style_name))
322+
318323
# 获取系统字体,设置comboBox的选项
319324
fontDatabase = QFontDatabase()
320325
fontFamilies = fontDatabase.families()
@@ -339,9 +344,6 @@ def __setValues(self):
339344
self.loadStyle(style_files[0])
340345
self.styleNameComboBox.comboBox.setCurrentText(style_files[0])
341346

342-
# 设置字幕排布
343-
self.layoutCard.comboBox.setCurrentText(cfg.get(cfg.subtitle_layout))
344-
345347
def connectSignals(self):
346348
"""连接所有设置变更的信号到预览更新函数"""
347349
# 字幕排布

app/view/task_creation_interface.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,13 @@ def setup_values(self):
256256
self.transcription_model_card.value() == TranscribeModelEnum.WHISPER.value or
257257
self.transcription_model_card.value() == TranscribeModelEnum.WHISPER_API.value
258258
)
259-
InfoBar.warning(
260-
self.tr("警告,将使用自带小模型API"),
261-
self.tr("为确保字幕修正的准确性,建议到设置中配置自己的API"),
262-
duration=8000,
263-
parent=self,
264-
position=InfoBarPosition.BOTTOM_RIGHT
259+
if cfg.api_base == "":
260+
InfoBar.warning(
261+
self.tr("警告"),
262+
self.tr("为确保字幕修正的准确性,建议到设置中配置自己的API"),
263+
duration=6000,
264+
parent=self,
265+
position=InfoBarPosition.BOTTOM_RIGHT
265266
)
266267

267268
def on_transcription_model_changed(self, value):

resource/subtitle_style/新闻大字风.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)