import os try: import torchaudio except ImportError: os.system("cd ./F5-TTS; pip install -e .") import spaces import logging from datetime import datetime from pathlib import Path import gradio as gr import torch import torchaudio import tempfile import requests log = logging.getLogger() #@spaces.GPU(duration=120) def video_to_audio(video: gr.Video, prompt: str): video_path = tempfile.NamedTemporaryFile(delete=False, suffix='.mp4').name output_dir = video_path.rsplit("/", 1)[0] video_save_path = str(output_dir) + "/" + str(video_path).replace("/", "__").strip(".") + ".mp4" print("paths", video, video_path, output_dir, video_save_path) if video.startswith("http"): data = requests.get(video, timeout=60).content with open(video_path, "wb") as fw: fw.write(data) else: os.system("cp %s %s" % (video, video_path)) os.system("cd ./MMAudio; python ./demo.py --variant small_44k --output %s --video %s --prompt %s --calc_energy 1" % (output_dir, video_path, prompt)) return video_save_path video_to_audio_tab = gr.Interface( fn=video_to_audio, description=""" Project page: https://acappemin.github.io/DeepAudio-V1.github.io
Code: https://github.com/acappemin/DeepAudio-V1
""", inputs=[ gr.Video(), gr.Text(label='Prompt'), ], outputs='playable_video', cache_examples=False, title='Video-to-Audio', examples=[ [ './tests/0235.mp4', '', ], [ './tests/0778.mp4', '', ], ]) if __name__ == "__main__": gr.TabbedInterface([video_to_audio_tab], ['Video-to-Audio']).launch()