-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_utils.py
More file actions
59 lines (50 loc) · 1.87 KB
/
Copy pathdebug_utils.py
File metadata and controls
59 lines (50 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from logger import get_logger
# 获取 logger
logger = get_logger()
def print_section(title, content):
"""
Print a section with a title and content.
Args:
title: Section title
content: Section content
"""
logger.info(f"\n===== {title} =====")
logger.info(content)
logger.info(f"===== {title}结束 =====\n")
def print_subtitle_info(subtitles):
"""
Print information about subtitles.
Args:
subtitles: List of subtitle entries
"""
logger.info("\n===== 字幕信息 =====")
for i, subtitle in enumerate(subtitles):
logger.info(f"字幕 {i+1}:")
logger.info(f" 时间范围: {subtitle['start']:.2f}s - {subtitle['end']:.2f}s")
logger.info(f" 文本: {subtitle['text']}")
logger.info("---")
logger.info("===== 字幕信息结束 =====\n")
def print_sentence_pairs(original_sentences, translated_sentences):
"""
Print pairs of original and translated sentences.
Args:
original_sentences: List of original sentences
translated_sentences: List of translated sentences
"""
logger.info("\n===== 拆分后的句子对照 =====")
for i, (orig, trans) in enumerate(zip(original_sentences, translated_sentences)):
logger.info(f"句子 {i+1}:")
logger.info(f" 原文: {orig}")
logger.info(f" 译文: {trans}")
logger.info("---")
logger.info("===== 拆分后的句子对照结束 =====\n")
def print_audio_segment_info(segment):
"""
Print information about an audio segment.
Args:
segment: Audio segment information
"""
logger.info(f"\n生成音频片段 {segment['index']+1}:")
logger.info(f" 时间范围: {segment['start']:.2f}s - {segment['end']:.2f}s")
logger.info(f" 文本: {segment['text']}")
logger.info(f" 生成的音频时长: {segment['duration']:.2f}s")