Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,8 @@ import tempfile
|
|
7 |
from pydub import AudioSegment
|
8 |
from moviepy.editor import VideoFileClip, AudioFileClip, concatenate_videoclips, ImageClip
|
9 |
|
|
|
|
|
10 |
def extract_audio_as_mp3(video_path: str) -> str:
|
11 |
"""
|
12 |
Extracts the audio from a video file and saves it as a temporary MP3 file.
|
@@ -31,10 +33,11 @@ def process_audio(input_file):
|
|
31 |
|
32 |
# Ensure it's in MP3 format
|
33 |
output_file = os.path.splitext(input_file)[0] + ".mp3"
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
audio
|
|
|
38 |
|
39 |
# Export as MP3
|
40 |
audio.export(output_file, format="mp3")
|
@@ -255,7 +258,13 @@ with gr.Blocks(css=css) as demo:
|
|
255 |
with gr.Column(elem_id="col-container"):
|
256 |
gr.Markdown("# Hibiki ")
|
257 |
gr.Markdown("This is a simple demo for Kyutai's Hibiki translation models • Currently supports French to English only.")
|
258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
with gr.Row():
|
260 |
with gr.Column(scale=2):
|
261 |
video_input = gr.Video(label="Video IN (Optional)")
|
|
|
7 |
from pydub import AudioSegment
|
8 |
from moviepy.editor import VideoFileClip, AudioFileClip, concatenate_videoclips, ImageClip
|
9 |
|
10 |
+
is_shared_ui = True if "fffiloni/Hibiki-simple" in os.environ['SPACE_ID'] else False
|
11 |
+
|
12 |
def extract_audio_as_mp3(video_path: str) -> str:
|
13 |
"""
|
14 |
Extracts the audio from a video file and saves it as a temporary MP3 file.
|
|
|
33 |
|
34 |
# Ensure it's in MP3 format
|
35 |
output_file = os.path.splitext(input_file)[0] + ".mp3"
|
36 |
+
|
37 |
+
if is_shared_ui:
|
38 |
+
# Limit duration to 1 minute (60,000 ms)
|
39 |
+
if len(audio) > 60000:
|
40 |
+
audio = audio[:60000] # Trim to 60 seconds
|
41 |
|
42 |
# Export as MP3
|
43 |
audio.export(output_file, format="mp3")
|
|
|
258 |
with gr.Column(elem_id="col-container"):
|
259 |
gr.Markdown("# Hibiki ")
|
260 |
gr.Markdown("This is a simple demo for Kyutai's Hibiki translation models • Currently supports French to English only.")
|
261 |
+
gr.HTML("""
|
262 |
+
<div style="display:flex;column-gap:4px;">
|
263 |
+
<a href="https://huggingface.co/spaces/fffiloni/Hibiki-simple?duplicate=true">
|
264 |
+
<img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-sm.svg" alt="Duplicate this Space">
|
265 |
+
</a>
|
266 |
+
</div>
|
267 |
+
""")
|
268 |
with gr.Row():
|
269 |
with gr.Column(scale=2):
|
270 |
video_input = gr.Video(label="Video IN (Optional)")
|