Spaces:
Build error
Build error
Commit ·
7144462
1
Parent(s): 84a138e
Update main.py
Browse files
main.py
CHANGED
|
@@ -30,31 +30,37 @@ def main(youtube_url):
|
|
| 30 |
if not os.path.exists('./translated'):
|
| 31 |
os.makedirs('./translated')
|
| 32 |
|
| 33 |
-
# Step 1: Download
|
|
|
|
| 34 |
downloaded_video_path = download_video(youtube_url)
|
| 35 |
|
| 36 |
-
# Step 2: Transcribe
|
|
|
|
| 37 |
transcribed_text_path = get_transcription_filename(downloaded_video_path)
|
| 38 |
-
model_type = 'base'
|
| 39 |
convert_video_to_text(downloaded_video_path, model_type)
|
| 40 |
|
| 41 |
|
| 42 |
-
# Step 3: Translate
|
|
|
|
| 43 |
translated_text_path = './translated/translated_text.txt'
|
| 44 |
translate_file(transcribed_text_path, translated_text_path)
|
| 45 |
|
| 46 |
# Step 4: Perform diarization
|
|
|
|
| 47 |
audio_path = get_audio_filename(downloaded_video_path)
|
| 48 |
diarized_audio_dir = './audio/diarization'
|
| 49 |
perform_diarization(audio_path, translated_text_path)
|
| 50 |
|
| 51 |
# Step 5: Generate speech for translated text
|
|
|
|
| 52 |
speaker_directory = './audio/diarization'
|
| 53 |
-
aligned_text_file = './audio/diarization/aligned_text.txt'
|
| 54 |
output_audio_file = './translated/final_audio.wav'
|
| 55 |
tts_main(speaker_directory, aligned_text_file, output_audio_file)
|
| 56 |
|
| 57 |
-
# Step 6: Create
|
|
|
|
| 58 |
video_name = get_video_name(downloaded_video_path)
|
| 59 |
final_video_path = create_translated_video(downloaded_video_path, output_audio_file, translated_text_path, video_name)
|
| 60 |
|
|
@@ -67,4 +73,4 @@ if __name__ == "__main__":
|
|
| 67 |
parser.add_argument("youtube_url", help="YouTube video URL")
|
| 68 |
args = parser.parse_args()
|
| 69 |
|
| 70 |
-
main(args.youtube_url)
|
|
|
|
| 30 |
if not os.path.exists('./translated'):
|
| 31 |
os.makedirs('./translated')
|
| 32 |
|
| 33 |
+
# Step 1: Download video
|
| 34 |
+
## yt_download.py
|
| 35 |
downloaded_video_path = download_video(youtube_url)
|
| 36 |
|
| 37 |
+
# Step 2: Transcribe video's audio
|
| 38 |
+
## video_to_text.py
|
| 39 |
transcribed_text_path = get_transcription_filename(downloaded_video_path)
|
| 40 |
+
model_type = 'base' # Whisper model type
|
| 41 |
convert_video_to_text(downloaded_video_path, model_type)
|
| 42 |
|
| 43 |
|
| 44 |
+
# Step 3: Translate transcribed text to Spanish
|
| 45 |
+
## opus.py
|
| 46 |
translated_text_path = './translated/translated_text.txt'
|
| 47 |
translate_file(transcribed_text_path, translated_text_path)
|
| 48 |
|
| 49 |
# Step 4: Perform diarization
|
| 50 |
+
## diarization.py
|
| 51 |
audio_path = get_audio_filename(downloaded_video_path)
|
| 52 |
diarized_audio_dir = './audio/diarization'
|
| 53 |
perform_diarization(audio_path, translated_text_path)
|
| 54 |
|
| 55 |
# Step 5: Generate speech for translated text
|
| 56 |
+
## tts.py
|
| 57 |
speaker_directory = './audio/diarization'
|
| 58 |
+
aligned_text_file = './audio/diarization/aligned_text.txt'
|
| 59 |
output_audio_file = './translated/final_audio.wav'
|
| 60 |
tts_main(speaker_directory, aligned_text_file, output_audio_file)
|
| 61 |
|
| 62 |
+
# Step 6: Create final translated video
|
| 63 |
+
## translated_video.py
|
| 64 |
video_name = get_video_name(downloaded_video_path)
|
| 65 |
final_video_path = create_translated_video(downloaded_video_path, output_audio_file, translated_text_path, video_name)
|
| 66 |
|
|
|
|
| 73 |
parser.add_argument("youtube_url", help="YouTube video URL")
|
| 74 |
args = parser.parse_args()
|
| 75 |
|
| 76 |
+
main(args.youtube_url)
|