sssssungk commited on
Commit
ebd3dc2
Β·
verified Β·
1 Parent(s): a887a28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
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