flocolombari commited on
Commit
5c64ea3
1 Parent(s): 0460dda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -14,6 +14,7 @@ def video_to_descriptions(video, target_language="en"):
14
 
15
  # Load the translation pipeline for the target language
16
  translator = translation_pipeline("translation", model=f"Helsinki-NLP/opus-mt-en-{target_language}")
 
17
 
18
  # Open the video
19
  cap = cv2.VideoCapture(video)
@@ -49,16 +50,20 @@ def video_to_descriptions(video, target_language="en"):
49
 
50
  # Translate the summarized text into the target language
51
  translated_text = translator(concatenated_descriptions[0]["summarized-text"])[0]["translation_text"]
 
 
52
 
53
- return translated_text
54
 
55
  # Create a dropdown menu with language options
56
- language_dropdown = gr.Interface.dropdown(["en", "fr", "de"], label="Langue cible")
 
 
57
 
58
  iface = gr.Interface(
59
  fn=video_to_descriptions,
60
- inputs=[gr.Video(type="file", label="Importez une vidéo"), language_dropdown],
61
- outputs="text",
62
  live=False
63
  )
64
 
 
14
 
15
  # Load the translation pipeline for the target language
16
  translator = translation_pipeline("translation", model=f"Helsinki-NLP/opus-mt-en-{target_language}")
17
+ audio = pipeline("text-to-speech", model="suno/bark")
18
 
19
  # Open the video
20
  cap = cv2.VideoCapture(video)
 
50
 
51
  # Translate the summarized text into the target language
52
  translated_text = translator(concatenated_descriptions[0]["summarized-text"])[0]["translation_text"]
53
+
54
+ audio_file = audio(translated_text)[0]["audio"]
55
 
56
+ return audio_file
57
 
58
  # Create a dropdown menu with language options
59
+ language_dropdown = gr.Dropdown(
60
+ ["en", "fr", "de", "es"], label="Language", info="The Language of the output"
61
+ )
62
 
63
  iface = gr.Interface(
64
  fn=video_to_descriptions,
65
+ inputs=[gr.Video(label="Import a Video", info="The Video to be described"), language_dropdown],
66
+ outputs="audio",
67
  live=False
68
  )
69