Spaces:
Paused
Paused
move dep
Browse files- crazy_functions/crazy_utils.py +0 -37
- crazy_functions/总结音视频.py +36 -1
crazy_functions/crazy_utils.py
CHANGED
@@ -606,40 +606,3 @@ def get_files_from_everything(txt, type): # type='.md'
|
|
606 |
success = False
|
607 |
|
608 |
return success, file_manifest, project_folder
|
609 |
-
|
610 |
-
|
611 |
-
def split_audio_file(filename, split_duration=1000):
|
612 |
-
"""
|
613 |
-
根据给定的切割时长将音频文件切割成多个片段。
|
614 |
-
|
615 |
-
Args:
|
616 |
-
filename (str): 需要被切割的音频文件名。
|
617 |
-
split_duration (int, optional): 每个切割音频片段的时长(以秒为单位)。默认值为1000。
|
618 |
-
|
619 |
-
Returns:
|
620 |
-
filelist (list): 一个包含所有切割音频片段文件路径的列表。
|
621 |
-
|
622 |
-
"""
|
623 |
-
from moviepy.editor import AudioFileClip
|
624 |
-
import os
|
625 |
-
os.makedirs('gpt_log/mp3/cut/', exist_ok=True) # 创建存储切割音频的文件夹
|
626 |
-
|
627 |
-
# 读取音频文件
|
628 |
-
audio = AudioFileClip(filename)
|
629 |
-
|
630 |
-
# 计算文件总时长和切割点
|
631 |
-
total_duration = audio.duration
|
632 |
-
split_points = list(range(0, int(total_duration), split_duration))
|
633 |
-
split_points.append(int(total_duration))
|
634 |
-
filelist = []
|
635 |
-
|
636 |
-
# 切割音频文件
|
637 |
-
for i in range(len(split_points) - 1):
|
638 |
-
start_time = split_points[i]
|
639 |
-
end_time = split_points[i + 1]
|
640 |
-
split_audio = audio.subclip(start_time, end_time)
|
641 |
-
split_audio.write_audiofile(f"gpt_log/mp3/cut/{filename[0]}_{i}.mp3")
|
642 |
-
filelist.append(f"gpt_log/mp3/cut/{filename[0]}_{i}.mp3")
|
643 |
-
|
644 |
-
audio.close()
|
645 |
-
return filelist
|
|
|
606 |
success = False
|
607 |
|
608 |
return success, file_manifest, project_folder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
crazy_functions/总结音视频.py
CHANGED
@@ -1,6 +1,41 @@
|
|
1 |
from toolbox import CatchException, report_execption, select_api_key, update_ui, write_results_to_file
|
2 |
-
from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def AnalyAudio(file_manifest, llm_kwargs, chatbot, history):
|
6 |
import os, requests
|
|
|
1 |
from toolbox import CatchException, report_execption, select_api_key, update_ui, write_results_to_file
|
2 |
+
from .crazy_utils import request_gpt_model_in_new_thread_with_ui_alive
|
3 |
|
4 |
+
def split_audio_file(filename, split_duration=1000):
|
5 |
+
"""
|
6 |
+
根据给定的切割时长将音频文件切割成多个片段。
|
7 |
+
|
8 |
+
Args:
|
9 |
+
filename (str): 需要被切割的音频文件名。
|
10 |
+
split_duration (int, optional): 每个切割音频片段的时长(以秒为单位)。默认值为1000。
|
11 |
+
|
12 |
+
Returns:
|
13 |
+
filelist (list): 一个包含所有切割音频片段文件路径的列表。
|
14 |
+
|
15 |
+
"""
|
16 |
+
from moviepy.editor import AudioFileClip
|
17 |
+
import os
|
18 |
+
os.makedirs('gpt_log/mp3/cut/', exist_ok=True) # 创建存储切割音频的文件夹
|
19 |
+
|
20 |
+
# 读取音频文件
|
21 |
+
audio = AudioFileClip(filename)
|
22 |
+
|
23 |
+
# 计算文件总时长和切割点
|
24 |
+
total_duration = audio.duration
|
25 |
+
split_points = list(range(0, int(total_duration), split_duration))
|
26 |
+
split_points.append(int(total_duration))
|
27 |
+
filelist = []
|
28 |
+
|
29 |
+
# 切割音频文件
|
30 |
+
for i in range(len(split_points) - 1):
|
31 |
+
start_time = split_points[i]
|
32 |
+
end_time = split_points[i + 1]
|
33 |
+
split_audio = audio.subclip(start_time, end_time)
|
34 |
+
split_audio.write_audiofile(f"gpt_log/mp3/cut/{filename[0]}_{i}.mp3")
|
35 |
+
filelist.append(f"gpt_log/mp3/cut/{filename[0]}_{i}.mp3")
|
36 |
+
|
37 |
+
audio.close()
|
38 |
+
return filelist
|
39 |
|
40 |
def AnalyAudio(file_manifest, llm_kwargs, chatbot, history):
|
41 |
import os, requests
|