app/infer.py CHANGED
@@ -12,23 +12,20 @@ from .zero import zero
12
  from .model import device
13
  import yt_dlp
14
 
15
-
16
  def download_audio(url):
17
  ydl_opts = {
18
- "format": "bestaudio/best",
19
- "outtmpl": "ytdl/%(title)s.%(ext)s",
20
- "postprocessors": [
21
- {
22
- "key": "FFmpegExtractAudio",
23
- "preferredcodec": "wav",
24
- "preferredquality": "192",
25
- }
26
- ],
27
  }
28
 
29
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
30
  info_dict = ydl.extract_info(url, download=True)
31
- file_path = ydl.prepare_filename(info_dict).rsplit(".", 1)[0] + ".wav"
32
  sample_rate, audio_data = read(file_path)
33
  audio_array = np.asarray(audio_data, dtype=np.int16)
34
 
@@ -49,6 +46,7 @@ def infer(
49
  ext = Path(original_audio).suffix
50
  original_audio_hashed = os.path.join(exp_dir, f"{original_audio_hash}{ext}")
51
  shutil.copy(original_audio, original_audio_hashed)
 
52
 
53
  out = os.path.join("separated", "htdemucs", original_audio_hash, "vocals.wav")
54
  if not os.path.exists(out):
@@ -104,22 +102,18 @@ class InferenceTab:
104
  type="filepath",
105
  show_download_button=True,
106
  )
107
- with gr.Accordion("inference by Link", open=False):
108
  with gr.Row():
109
  youtube_link = gr.Textbox(
110
- label="Link",
111
- placeholder="Paste the link here",
112
- interactive=True,
113
- )
114
  with gr.Row():
115
- gr.Markdown(
116
- "You can paste the link to the video/audio from many sites, check the complete list [here](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md)"
117
- )
118
  with gr.Row():
119
- download_button = gr.Button("Download!", variant="primary")
120
- download_button.click(
121
- download_audio, [youtube_link], [self.original_audio]
122
- )
123
 
124
  with gr.Column():
125
  self.pitch_mod = gr.Slider(
 
12
  from .model import device
13
  import yt_dlp
14
 
 
15
  def download_audio(url):
16
  ydl_opts = {
17
+ 'format': 'bestaudio/best',
18
+ 'outtmpl': 'ytdl/%(title)s.%(ext)s',
19
+ 'postprocessors': [{
20
+ 'key': 'FFmpegExtractAudio',
21
+ 'preferredcodec': 'wav',
22
+ 'preferredquality': '192',
23
+ }],
 
 
24
  }
25
 
26
  with yt_dlp.YoutubeDL(ydl_opts) as ydl:
27
  info_dict = ydl.extract_info(url, download=True)
28
+ file_path = ydl.prepare_filename(info_dict).rsplit('.', 1)[0] + '.wav'
29
  sample_rate, audio_data = read(file_path)
30
  audio_array = np.asarray(audio_data, dtype=np.int16)
31
 
 
46
  ext = Path(original_audio).suffix
47
  original_audio_hashed = os.path.join(exp_dir, f"{original_audio_hash}{ext}")
48
  shutil.copy(original_audio, original_audio_hashed)
49
+
50
 
51
  out = os.path.join("separated", "htdemucs", original_audio_hash, "vocals.wav")
52
  if not os.path.exists(out):
 
102
  type="filepath",
103
  show_download_button=True,
104
  )
105
+ with gr.Accordion("inference by Link",open=False):
106
  with gr.Row():
107
  youtube_link = gr.Textbox(
108
+ label = "Link",
109
+ placeholder = "Paste the link here",
110
+ interactive = True
111
+ )
112
  with gr.Row():
113
+ gr.Markdown("You can paste the link to the video/audio from many sites, check the complete list [here](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md)")
 
 
114
  with gr.Row():
115
+ download_button = gr.Button("Download!",variant = "primary")
116
+ download_button.click(download_audio, [youtube_link], [self.original_audio])
 
 
117
 
118
  with gr.Column():
119
  self.pitch_mod = gr.Slider(
pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
  [project]
2
  name = "zerorvc"
3
- version = "0.0.10"
4
  authors = [{ name = "Jacob Lin", email = "[email protected]" }]
5
  description = "Run Retrieval-based Voice Conversion training and inference with ease."
6
  readme = "README.md"
 
1
  [project]
2
  name = "zerorvc"
3
+ version = "0.0.8"
4
  authors = [{ name = "Jacob Lin", email = "[email protected]" }]
5
  description = "Run Retrieval-based Voice Conversion training and inference with ease."
6
  readme = "README.md"
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- zerorvc>=0.0.10
2
 
3
  # gradio app deps
4
  gradio==4.37.2
 
1
+ zerorvc>=0.0.8
2
 
3
  # gradio app deps
4
  gradio==4.37.2
zerorvc/preprocess/preprocess.py CHANGED
@@ -19,7 +19,7 @@ class Preprocessor:
19
  self.sr = sr
20
  self.bh, self.ah = signal.butter(N=5, Wn=48, btype="high", fs=self.sr)
21
  self.max_slice_length = max_slice_length
22
- self.min_slice_length = min_slice_length
23
  self.overlap = 0.3
24
  self.tail = self.max_slice_length + self.overlap
25
  self.max = 0.9
 
19
  self.sr = sr
20
  self.bh, self.ah = signal.butter(N=5, Wn=48, btype="high", fs=self.sr)
21
  self.max_slice_length = max_slice_length
22
+ self.max_slice_length = min_slice_length
23
  self.overlap = 0.3
24
  self.tail = self.max_slice_length + self.overlap
25
  self.max = 0.9
zerorvc/trainer.py CHANGED
@@ -9,7 +9,6 @@ from torch.utils.data import DataLoader
9
  from huggingface_hub import HfApi, upload_folder
10
  from accelerate import Accelerator
11
  from datasets import Dataset
12
- from .pretrained import pretrained_checkpoints
13
  from .constants import *
14
 
15
 
@@ -101,15 +100,15 @@ class RVCTrainer:
101
  self.checkpoint_dir = checkpoint_dir
102
  self.sr = sr
103
 
104
- def latest_checkpoint(self, fallback_to_pretrained: bool = True):
105
  files_g = glob(os.path.join(self.checkpoint_dir, "G_*.pth"))
106
  if not files_g:
107
- return pretrained_checkpoints() if fallback_to_pretrained else None
108
  latest_g = max(files_g, key=os.path.getctime)
109
 
110
  files_d = glob(os.path.join(self.checkpoint_dir, "D_*.pth"))
111
  if not files_d:
112
- return pretrained_checkpoints() if fallback_to_pretrained else None
113
  latest_d = max(files_d, key=os.path.getctime)
114
 
115
  return latest_g, latest_d
 
9
  from huggingface_hub import HfApi, upload_folder
10
  from accelerate import Accelerator
11
  from datasets import Dataset
 
12
  from .constants import *
13
 
14
 
 
100
  self.checkpoint_dir = checkpoint_dir
101
  self.sr = sr
102
 
103
+ def latest_checkpoint(self):
104
  files_g = glob(os.path.join(self.checkpoint_dir, "G_*.pth"))
105
  if not files_g:
106
+ return None
107
  latest_g = max(files_g, key=os.path.getctime)
108
 
109
  files_d = glob(os.path.join(self.checkpoint_dir, "D_*.pth"))
110
  if not files_d:
111
+ return None
112
  latest_d = max(files_d, key=os.path.getctime)
113
 
114
  return latest_g, latest_d