Spaces:
Sleeping
Sleeping
Update gradio_app.py
Browse files- gradio_app.py +5 -5
gradio_app.py
CHANGED
|
@@ -16,15 +16,15 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
| 16 |
dnr_model = look2hear.models.TIGERDNR.from_pretrained("JusperLee/TIGER-DnR", cache_dir="cache").to(device).eval()
|
| 17 |
sep_model = look2hear.models.TIGER.from_pretrained("JusperLee/TIGER-speech", cache_dir="cache").to(device).eval()
|
| 18 |
|
| 19 |
-
TARGET_SR =
|
| 20 |
MAX_SPEAKERS = 4
|
| 21 |
|
| 22 |
-
def extract_audio_from_video(video_path):
|
| 23 |
video = VideoFileClip(video_path)
|
| 24 |
session_id = uuid.uuid4().hex[:8]
|
| 25 |
audio_path = f"temp_audio/{session_id}.wav"
|
| 26 |
os.makedirs("temp_audio", exist_ok=True)
|
| 27 |
-
video.audio.write_audiofile(audio_path, fps=
|
| 28 |
return audio_path, video
|
| 29 |
|
| 30 |
def attach_audio_to_video(original_video, audio_path, out_path):
|
|
@@ -107,7 +107,7 @@ def separate_speakers(audio_path):
|
|
| 107 |
|
| 108 |
@spaces.GPU()
|
| 109 |
def separate_dnr_video(video_path):
|
| 110 |
-
audio_path, video = extract_audio_from_video(video_path)
|
| 111 |
dialog_path, effect_path, music_path = separate_dnr(audio_path)
|
| 112 |
|
| 113 |
session_id = uuid.uuid4().hex[:8]
|
|
@@ -133,7 +133,7 @@ def convert_to_ffmpeg_friendly(input_wav, output_wav):
|
|
| 133 |
|
| 134 |
@spaces.GPU()
|
| 135 |
def separate_speakers_video(video_path):
|
| 136 |
-
audio_path, video = extract_audio_from_video(video_path)
|
| 137 |
output_files = separate_speakers_core(audio_path)
|
| 138 |
|
| 139 |
session_id = uuid.uuid4().hex[:8]
|
|
|
|
| 16 |
dnr_model = look2hear.models.TIGERDNR.from_pretrained("JusperLee/TIGER-DnR", cache_dir="cache").to(device).eval()
|
| 17 |
sep_model = look2hear.models.TIGER.from_pretrained("JusperLee/TIGER-speech", cache_dir="cache").to(device).eval()
|
| 18 |
|
| 19 |
+
TARGET_SR = 16000
|
| 20 |
MAX_SPEAKERS = 4
|
| 21 |
|
| 22 |
+
def extract_audio_from_video(video_path, freq):
|
| 23 |
video = VideoFileClip(video_path)
|
| 24 |
session_id = uuid.uuid4().hex[:8]
|
| 25 |
audio_path = f"temp_audio/{session_id}.wav"
|
| 26 |
os.makedirs("temp_audio", exist_ok=True)
|
| 27 |
+
video.audio.write_audiofile(audio_path, fps=freq, verbose=False, logger=None)
|
| 28 |
return audio_path, video
|
| 29 |
|
| 30 |
def attach_audio_to_video(original_video, audio_path, out_path):
|
|
|
|
| 107 |
|
| 108 |
@spaces.GPU()
|
| 109 |
def separate_dnr_video(video_path):
|
| 110 |
+
audio_path, video = extract_audio_from_video(video_path, 44100)
|
| 111 |
dialog_path, effect_path, music_path = separate_dnr(audio_path)
|
| 112 |
|
| 113 |
session_id = uuid.uuid4().hex[:8]
|
|
|
|
| 133 |
|
| 134 |
@spaces.GPU()
|
| 135 |
def separate_speakers_video(video_path):
|
| 136 |
+
audio_path, video = extract_audio_from_video(video_path, 16000)
|
| 137 |
output_files = separate_speakers_core(audio_path)
|
| 138 |
|
| 139 |
session_id = uuid.uuid4().hex[:8]
|