Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,6 +29,7 @@ from huggingface_hub import hf_hub_download
|
|
| 29 |
#!pip install gradio
|
| 30 |
import gradio as gr
|
| 31 |
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
# μ€λμ€ λ³ν mp4 --> wav
|
|
@@ -60,6 +61,9 @@ def seprate_speaker(audio_file, pipeline):
|
|
| 60 |
# λ°ν ꡬκ°μ ν΄λΉ νμμ 리μ€νΈμ μΆκ°
|
| 61 |
segment_waveform = waveform[:, int(start_time * sample_rate):int(end_time * sample_rate)]
|
| 62 |
speaker_segments[speaker].append(segment_waveform)
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
# κ° νμλ³λ‘ λͺ¨λ λ°ν ꡬκ°μ νλμ νμΌλ‘ μ΄μ΄λΆμ¬ μ μ₯
|
| 65 |
for speaker, segments in speaker_segments.items():
|
|
@@ -67,6 +71,8 @@ def seprate_speaker(audio_file, pipeline):
|
|
| 67 |
combined_waveform = torch.cat(segments, dim=1)
|
| 68 |
#current_path = os.getcwd()
|
| 69 |
output_path = "/tmp/wav" # κ²½λ‘
|
|
|
|
|
|
|
| 70 |
os.makedirs(output_path, exist_ok=True) # κ²½λ‘κ° μμΌλ©΄ μμ±
|
| 71 |
output_filename = os.path.join(output_path,f"{speaker}.wav")
|
| 72 |
|
|
|
|
| 29 |
#!pip install gradio
|
| 30 |
import gradio as gr
|
| 31 |
|
| 32 |
+
import shutil
|
| 33 |
|
| 34 |
|
| 35 |
# μ€λμ€ λ³ν mp4 --> wav
|
|
|
|
| 61 |
# λ°ν ꡬκ°μ ν΄λΉ νμμ 리μ€νΈμ μΆκ°
|
| 62 |
segment_waveform = waveform[:, int(start_time * sample_rate):int(end_time * sample_rate)]
|
| 63 |
speaker_segments[speaker].append(segment_waveform)
|
| 64 |
+
# ν΄λκ° μ‘΄μ¬νλ©΄ μμ
|
| 65 |
+
if os.path.exists("/tmp/wav" ):
|
| 66 |
+
shutil.rmtree("/tmp/wav" ) # ν΄λ λ° λ΄λΆ νμΌ μμ
|
| 67 |
|
| 68 |
# κ° νμλ³λ‘ λͺ¨λ λ°ν ꡬκ°μ νλμ νμΌλ‘ μ΄μ΄λΆμ¬ μ μ₯
|
| 69 |
for speaker, segments in speaker_segments.items():
|
|
|
|
| 71 |
combined_waveform = torch.cat(segments, dim=1)
|
| 72 |
#current_path = os.getcwd()
|
| 73 |
output_path = "/tmp/wav" # κ²½λ‘
|
| 74 |
+
|
| 75 |
+
|
| 76 |
os.makedirs(output_path, exist_ok=True) # κ²½λ‘κ° μμΌλ©΄ μμ±
|
| 77 |
output_filename = os.path.join(output_path,f"{speaker}.wav")
|
| 78 |
|