Spaces:
Sleeping
Sleeping
Commit
·
9826ba4
1
Parent(s):
091b090
"LOL"
Browse files- app.py +1 -24
- src/text_processing.py +1 -1
app.py
CHANGED
@@ -8,11 +8,9 @@ except RuntimeError:
|
|
8 |
import streamlit as st
|
9 |
from main import main
|
10 |
import os
|
11 |
-
import subprocess
|
12 |
|
13 |
# Định nghĩa đường dẫn video đầu ra
|
14 |
OUTPUT_VIDEO_PATH = "final_output.mp4"
|
15 |
-
OUTPUT_VIDEO_FIXED_PATH = "final_output_fixed.mp4"
|
16 |
|
17 |
# Tiêu đề ứng dụng
|
18 |
st.set_page_config(page_title="KnowFlow", page_icon="📖")
|
@@ -77,24 +75,6 @@ art_style = st.text_input("🖌️ Image Description Style", placeholder="Exampl
|
|
77 |
style = st.text_input("🎨 Image Style", placeholder="Example: realistic, anime,...")
|
78 |
color_palette = st.text_input("🌈 Color Palette", placeholder="Example: vibrant, monochrome,...")
|
79 |
|
80 |
-
def convert_audio_format(video_input, video_output):
|
81 |
-
"""Chuyển đổi định dạng âm thanh của video sang AAC."""
|
82 |
-
if not os.path.exists(video_input):
|
83 |
-
raise FileNotFoundError(f"File '{video_input}' không tồn tại!")
|
84 |
-
|
85 |
-
command = [
|
86 |
-
"ffmpeg", "-i", video_input,
|
87 |
-
"-c:v", "copy", "-c:a", "aac", "-b:a", "192k",
|
88 |
-
"-y", # Ghi đè nếu file output đã tồn tại
|
89 |
-
video_output
|
90 |
-
]
|
91 |
-
|
92 |
-
try:
|
93 |
-
subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
94 |
-
print(f"✅ Chuyển đổi thành công: {video_output}")
|
95 |
-
except subprocess.CalledProcessError as e:
|
96 |
-
print(f"❌ Lỗi khi chuyển đổi video: {e.stderr.decode()}")
|
97 |
-
|
98 |
# Nút chạy pipeline
|
99 |
if st.button("🚀 Generate Video"):
|
100 |
if file_path and os.path.exists(file_path):
|
@@ -104,12 +84,9 @@ if st.button("🚀 Generate Video"):
|
|
104 |
# Kiểm tra xem video đã được tạo chưa
|
105 |
if os.path.exists(OUTPUT_VIDEO_PATH):
|
106 |
st.success("🎉 Video generated successfully!")
|
107 |
-
|
108 |
-
# Chuyển đổi định dạng âm thanh
|
109 |
-
convert_audio_format(OUTPUT_VIDEO_PATH, OUTPUT_VIDEO_FIXED_PATH)
|
110 |
|
111 |
# Tạo link tải về
|
112 |
-
with open(
|
113 |
st.download_button(label="📥 Download Video", data=video_file, file_name="final_output_fixed.mp4", mime="video/mp4")
|
114 |
else:
|
115 |
st.error("⚠️ Video generation failed. Please check the logs.")
|
|
|
8 |
import streamlit as st
|
9 |
from main import main
|
10 |
import os
|
|
|
11 |
|
12 |
# Định nghĩa đường dẫn video đầu ra
|
13 |
OUTPUT_VIDEO_PATH = "final_output.mp4"
|
|
|
14 |
|
15 |
# Tiêu đề ứng dụng
|
16 |
st.set_page_config(page_title="KnowFlow", page_icon="📖")
|
|
|
75 |
style = st.text_input("🎨 Image Style", placeholder="Example: realistic, anime,...")
|
76 |
color_palette = st.text_input("🌈 Color Palette", placeholder="Example: vibrant, monochrome,...")
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
# Nút chạy pipeline
|
79 |
if st.button("🚀 Generate Video"):
|
80 |
if file_path and os.path.exists(file_path):
|
|
|
84 |
# Kiểm tra xem video đã được tạo chưa
|
85 |
if os.path.exists(OUTPUT_VIDEO_PATH):
|
86 |
st.success("🎉 Video generated successfully!")
|
|
|
|
|
|
|
87 |
|
88 |
# Tạo link tải về
|
89 |
+
with open(OUTPUT_VIDEO_PATH, "rb") as video_file:
|
90 |
st.download_button(label="📥 Download Video", data=video_file, file_name="final_output_fixed.mp4", mime="video/mp4")
|
91 |
else:
|
92 |
st.error("⚠️ Video generation failed. Please check the logs.")
|
src/text_processing.py
CHANGED
@@ -42,7 +42,7 @@ def extract_text_from_file(file_path):
|
|
42 |
####################### - SEMANTIC CHUNKING - #######################
|
43 |
def split_text_by_semantics(text, chunks, client):
|
44 |
prompt = f"""
|
45 |
-
Bạn là một chuyên gia xử lý văn bản. Hãy chia văn bản sau thành {chunks}
|
46 |
|
47 |
Văn bản:
|
48 |
{text}
|
|
|
42 |
####################### - SEMANTIC CHUNKING - #######################
|
43 |
def split_text_by_semantics(text, chunks, client):
|
44 |
prompt = f"""
|
45 |
+
Bạn là một chuyên gia xử lý văn bản. Hãy chia văn bản sau thành {chunks} đoạn có ý nghĩa sao cho mỗi đoạn vừa đủ để giải thích trong khoảng 3 đến 5 câu.
|
46 |
|
47 |
Văn bản:
|
48 |
{text}
|