akazmi commited on
Commit
93476c0
·
verified ·
1 Parent(s): 9e51fe9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -1,17 +1,8 @@
1
- # Install dependencies if not already done in your environment
2
- # pip install transformers torch gtts ffmpeg-python
3
-
4
  from transformers import pipeline
5
  from gtts import gTTS
6
  import subprocess
7
  import streamlit as st
8
 
9
- uploaded_file = st.file_uploader("Upload a video file", type=["mp4"])
10
- if uploaded_file is not None:
11
- with open("input_video.mp4", "wb") as f:
12
- f.write(uploaded_file.getbuffer())
13
- main("input_video.mp4")
14
-
15
  # Step 1: Extract Text from Audio using Hugging Face Transformers
16
  def extract_text_from_audio(audio_path):
17
  # Load the ASR pipeline from Hugging Face with a Whisper-like model
@@ -51,7 +42,7 @@ def add_voice_over_to_video(video_path, audio_path, output_video_path="output_vi
51
  subprocess.run(ffmpeg_command)
52
  print(f"Final video with voice-over saved as {output_video_path}")
53
 
54
- # Run the complete process
55
  def main(video_path):
56
  # Step 1: Extract text from video/audio
57
  text = extract_text_from_audio(video_path)
@@ -63,5 +54,11 @@ def main(video_path):
63
  # Step 3: Add voice-over to the video
64
  add_voice_over_to_video(video_path, audio_path)
65
 
66
- # Provide the path to your input video file
67
- main("input_video.mp4")
 
 
 
 
 
 
 
 
 
 
1
  from transformers import pipeline
2
  from gtts import gTTS
3
  import subprocess
4
  import streamlit as st
5
 
 
 
 
 
 
 
6
  # Step 1: Extract Text from Audio using Hugging Face Transformers
7
  def extract_text_from_audio(audio_path):
8
  # Load the ASR pipeline from Hugging Face with a Whisper-like model
 
42
  subprocess.run(ffmpeg_command)
43
  print(f"Final video with voice-over saved as {output_video_path}")
44
 
45
+ # Step 4: Run the complete process
46
  def main(video_path):
47
  # Step 1: Extract text from video/audio
48
  text = extract_text_from_audio(video_path)
 
54
  # Step 3: Add voice-over to the video
55
  add_voice_over_to_video(video_path, audio_path)
56
 
57
+ # Streamlit interface to upload video file
58
+ uploaded_file = st.file_uploader("Upload a video file", type=["mp4"])
59
+ if uploaded_file is not None:
60
+ with open("input_video.mp4", "wb") as f:
61
+ f.write(uploaded_file.getbuffer())
62
+
63
+ # Call the main function after video is uploaded
64
+ main("input_video.mp4")