RobCaamano commited on
Commit
7144462
1 Parent(s): 84a138e

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +13 -7
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 the video
 
34
  downloaded_video_path = download_video(youtube_url)
35
 
36
- # Step 2: Transcribe the video's audio
 
37
  transcribed_text_path = get_transcription_filename(downloaded_video_path)
38
- model_type = 'base' # You can specify the Whisper model type
39
  convert_video_to_text(downloaded_video_path, model_type)
40
 
41
 
42
- # Step 3: Translate the transcribed text to Spanish
 
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' # Ensure this is the correct path
54
  output_audio_file = './translated/final_audio.wav'
55
  tts_main(speaker_directory, aligned_text_file, output_audio_file)
56
 
57
- # Step 6: Create the final translated video
 
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)