ZeeAI1 commited on
Commit
fdd75f5
Β·
verified Β·
1 Parent(s): cbe3602

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
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 V2", layout="centered")
12
- st.title("🎀 AI Voiceover V2: Replace One Speaker Only")
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 clip (MP4 preferred)", type=["mp4", "mov", "avi"])
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 custom voiceover text to replace one speaker:", result["text"])
39
 
40
- if st.button("Replace Only One Speaker's Voice"):
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", "_final_v2.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 with Mixed Voiceover", data=f, file_name="final_ai_video_v2.mp4")
 
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")