Update app.py
Browse files
app.py
CHANGED
@@ -8,8 +8,8 @@ from moviepy.editor import VideoFileClip, AudioFileClip
|
|
8 |
from tempfile import NamedTemporaryFile
|
9 |
import torchaudio
|
10 |
|
11 |
-
st.set_page_config(page_title="AI Voiceover
|
12 |
-
st.title("π€ AI Voiceover
|
13 |
|
14 |
@st.cache_resource
|
15 |
def load_whisper_model():
|
@@ -17,7 +17,7 @@ def load_whisper_model():
|
|
17 |
|
18 |
whisper_model = load_whisper_model()
|
19 |
|
20 |
-
video_file = st.file_uploader("Upload a short video
|
21 |
|
22 |
if video_file:
|
23 |
with NamedTemporaryFile(delete=False, suffix=".mp4") as tmp_video:
|
@@ -35,9 +35,9 @@ if video_file:
|
|
35 |
st.subheader("π Detected Speech")
|
36 |
st.write(result["text"])
|
37 |
|
38 |
-
custom_text = st.text_area("Enter your
|
39 |
|
40 |
-
if st.button("
|
41 |
ai_voice_path = audio_path.replace(".wav", "_ai_voice.wav")
|
42 |
tts = gTTS(text=custom_text)
|
43 |
tts.save(ai_voice_path)
|
@@ -57,8 +57,8 @@ if video_file:
|
|
57 |
torchaudio.save(mixed_path, mixed_audio, sr)
|
58 |
|
59 |
final_video = video.set_audio(AudioFileClip(mixed_path))
|
60 |
-
final_path = tmp_video_path.replace(".mp4", "
|
61 |
final_video.write_videofile(final_path, codec="libx264", audio_codec="aac")
|
62 |
|
63 |
with open(final_path, "rb") as f:
|
64 |
-
st.download_button(label="π₯ Download Final Video
|
|
|
8 |
from tempfile import NamedTemporaryFile
|
9 |
import torchaudio
|
10 |
|
11 |
+
st.set_page_config(page_title="AI Voiceover", layout="centered")
|
12 |
+
st.title("π€ AI Voiceover App")
|
13 |
|
14 |
@st.cache_resource
|
15 |
def load_whisper_model():
|
|
|
17 |
|
18 |
whisper_model = load_whisper_model()
|
19 |
|
20 |
+
video_file = st.file_uploader("Upload a short video (MP4 preferred)", type=["mp4", "mov", "avi"])
|
21 |
|
22 |
if video_file:
|
23 |
with NamedTemporaryFile(delete=False, suffix=".mp4") as tmp_video:
|
|
|
35 |
st.subheader("π Detected Speech")
|
36 |
st.write(result["text"])
|
37 |
|
38 |
+
custom_text = st.text_area("Enter your voiceover text:", result["text"])
|
39 |
|
40 |
+
if st.button("Generate AI Voiceover"):
|
41 |
ai_voice_path = audio_path.replace(".wav", "_ai_voice.wav")
|
42 |
tts = gTTS(text=custom_text)
|
43 |
tts.save(ai_voice_path)
|
|
|
57 |
torchaudio.save(mixed_path, mixed_audio, sr)
|
58 |
|
59 |
final_video = video.set_audio(AudioFileClip(mixed_path))
|
60 |
+
final_path = tmp_video_path.replace(".mp4", "_final_streamlit.mp4")
|
61 |
final_video.write_videofile(final_path, codec="libx264", audio_codec="aac")
|
62 |
|
63 |
with open(final_path, "rb") as f:
|
64 |
+
st.download_button(label="π₯ Download Final Video", data=f, file_name="final_ai_voiceover.mp4")
|