shethjenil commited on
Commit
71d986e
·
verified ·
1 Parent(s): 698b449

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +29 -1
main.py CHANGED
@@ -166,7 +166,35 @@ def convert_model_from_local(
166
 
167
  save_file(final_sd, save_path)
168
 
169
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
 
171
  # config = StyleTTS2Config.from_yaml("config.yaml")
172
  # convert_model_from_local(
 
166
 
167
  save_file(final_sd, save_path)
168
 
169
+ from huggingface_hub import hf_hub_download
170
+ import numpy as np
171
+ import torch
172
+ from pathlib import Path
173
+ file_path = hf_hub_download(
174
+ repo_id="KittenML/kitten-tts-nano-0.8-fp32",
175
+ filename="voices.npz"
176
+ )
177
+ keys = [
178
+ 'expr-voice-2-m', 'expr-voice-2-f',
179
+ 'expr-voice-3-m', 'expr-voice-3-f',
180
+ 'expr-voice-4-m', 'expr-voice-4-f',
181
+ 'expr-voice-5-m', 'expr-voice-5-f'
182
+ ]
183
+
184
+ values = [
185
+ 'Bella', 'Jasper',
186
+ 'Luna', 'Bruno',
187
+ 'Rosie', 'Hugo',
188
+ 'Kiki', 'Leo'
189
+ ]
190
+ voice_dict = dict(zip(keys, values))
191
+ voice_dir = Path("voice_dir")
192
+ voice_dir.mkdir(exist_ok=True)
193
+ data = np.load(file_path)
194
+ for key in data.files:
195
+ if key in voice_dict:
196
+ tensor = torch.from_numpy(data[key])
197
+ torch.save(tensor, voice_dir / f"{voice_dict[key]}.pt")
198
 
199
  # config = StyleTTS2Config.from_yaml("config.yaml")
200
  # convert_model_from_local(