Skip to content

Commit

Permalink
调整 duration, 防止时间是 0 或 大于 60 情况
Browse files Browse the repository at this point in the history
  • Loading branch information
lemisky committed May 20, 2022
1 parent 175ac19 commit ecf95d0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ def get_duration(silk_path: str) -> int:
return i * 20


def adjust_duration(duration):
if duration < 1:
return 1
if duration > 60:
return 60
return duration


def main(start_durations):
"""添加silk文件"""
folder = os.path.dirname(sys.argv[0])
Expand Down Expand Up @@ -106,7 +114,7 @@ def main(start_durations):
sf_index = 0
for item in start_durations(silk_file):
duration += item[0]
lens.append(item[1])
lens.append(adjust_duration(item[1]))
sf_file = f'sf_{code}_p{sf_index}_amr'
with open(sf_file, 'wb') as f:
f.write(b'\x02#!SILK_V3')
Expand Down

0 comments on commit ecf95d0

Please sign in to comment.