Pedro Sandoval commited on
Commit
e01c257
·
1 Parent(s): a6bc029

update examples, update upload ckpt scripts

Browse files
app.py CHANGED
@@ -24,7 +24,7 @@ DEFAULT_MAX_NEW_TOKENS = 500
24
  DEFAULT_TEMPERATURE = 0.9
25
  DEFAULT_TOP_K = 50
26
  MAX_PROMPT_CHARS = 500
27
- CHECKPOINT_PATH = ROOT / "checkpoints" / "nanotts_ckpt_030000_inference.pt"
28
  TEXT_TOKENIZER_PATH = ROOT / "text_tokenizer" / "libritts_bpe.json"
29
  WAVTOKENIZER_REPO_ID = "novateur/WavTokenizer"
30
  WAVTOKENIZER_CONFIG = "wavtokenizer_smalldata_frame40_3s_nq1_code4096_dim512_kmeans200_attn.yaml"
@@ -57,7 +57,7 @@ def load_bundle() -> ModelBundle:
57
  if not CHECKPOINT_PATH.exists():
58
  raise FileNotFoundError(
59
  f"Missing nanoTTS checkpoint at {CHECKPOINT_PATH}. "
60
- "Upload checkpoints/nanotts_ckpt_030000_inference.pt to this Space first."
61
  )
62
 
63
  device = _device()
@@ -151,7 +151,7 @@ with gr.Blocks(title="nanoTTS") as demo:
151
  placeholder="Type a short sentence...",
152
  lines=4,
153
  max_lines=8,
154
- value="Hello again! This is nano text to speech.",
155
  )
156
  generate_button = gr.Button("Generate", variant="primary")
157
  with gr.Column(scale=2):
@@ -183,9 +183,11 @@ with gr.Blocks(title="nanoTTS") as demo:
183
 
184
  gr.Examples(
185
  examples=[
 
 
 
 
186
  ["The quick brown fox jumps over the lazy dog.", 500, 0.9, 50, 0],
187
- ["My name is Pedro Sandoval Segura.", 500, 0.9, 50, 0],
188
- ["Nano text to speech was created at the University of Maryland.", 600, 0.9, 50, 0],
189
  ],
190
  inputs=[text_input, max_new_tokens, temperature, top_k, seed],
191
  outputs=audio_output,
 
24
  DEFAULT_TEMPERATURE = 0.9
25
  DEFAULT_TOP_K = 50
26
  MAX_PROMPT_CHARS = 500
27
+ CHECKPOINT_PATH = ROOT / "checkpoints" / "ckpt_025000_inference.pt"
28
  TEXT_TOKENIZER_PATH = ROOT / "text_tokenizer" / "libritts_bpe.json"
29
  WAVTOKENIZER_REPO_ID = "novateur/WavTokenizer"
30
  WAVTOKENIZER_CONFIG = "wavtokenizer_smalldata_frame40_3s_nq1_code4096_dim512_kmeans200_attn.yaml"
 
57
  if not CHECKPOINT_PATH.exists():
58
  raise FileNotFoundError(
59
  f"Missing nanoTTS checkpoint at {CHECKPOINT_PATH}. "
60
+ "Upload checkpoints/ckpt_025000_inference.pt to this Space first."
61
  )
62
 
63
  device = _device()
 
151
  placeholder="Type a short sentence...",
152
  lines=4,
153
  max_lines=8,
154
+ value="Hello friend! This is nano text to speech.",
155
  )
156
  generate_button = gr.Button("Generate", variant="primary")
157
  with gr.Column(scale=2):
 
183
 
184
  gr.Examples(
185
  examples=[
186
+ ["Nano text to speech", 500, 0.9, 50, 0],
187
+ ["Created at the University of Maryland", 500, 0.9, 50, 0],
188
+ ["Trained using only two hundred and forty five hours of speech data", 600, 0.9, 50, 0],
189
+ ["In the year two thousand and twenty six", 500, 0.9, 50, 0],
190
  ["The quick brown fox jumps over the lazy dog.", 500, 0.9, 50, 0],
 
 
191
  ],
192
  inputs=[text_input, max_new_tokens, temperature, top_k, seed],
193
  outputs=audio_output,
scripts/export_inference_checkpoint.py CHANGED
@@ -5,15 +5,9 @@ from pathlib import Path
5
 
6
  import torch
7
 
8
- DEFAULT_SOURCE = Path("/fs/nexus-scratch/psando/nanotts-05-10/gpt2/ckpt_030000.pt")
9
- DEFAULT_OUTPUT = Path("checkpoints/nanotts_ckpt_030000_inference.pt")
10
-
11
-
12
- def to_python_number(value):
13
- if isinstance(value, torch.Tensor):
14
- return value.detach().cpu().item()
15
- return value
16
-
17
 
18
  def main() -> None:
19
  parser = argparse.ArgumentParser(description="Export a slim nanoTTS inference checkpoint.")
@@ -32,8 +26,8 @@ def main() -> None:
32
  "model": checkpoint["model"],
33
  "model_args": checkpoint["model_args"],
34
  "iter_num": checkpoint.get("iter_num"),
35
- "train_loss": to_python_number(checkpoint.get("train_loss")),
36
- "val_loss": to_python_number(checkpoint.get("val_loss")),
37
  "source_checkpoint": str(args.source),
38
  }
39
 
@@ -43,6 +37,7 @@ def main() -> None:
43
  size_mib = args.output.stat().st_size / 1024 / 1024
44
  print(f"Wrote {args.output} ({size_mib:.1f} MiB)")
45
  print(f"Keys: {sorted(inference_checkpoint.keys())}")
 
46
 
47
 
48
  if __name__ == "__main__":
 
5
 
6
  import torch
7
 
8
+ DEFAULT_SOURCE = Path("/fs/nexus-scratch/psando/nanotts-05-10/gpt2/ckpt_025000.pt")
9
+ stem = DEFAULT_SOURCE.stem
10
+ DEFAULT_OUTPUT = Path(f"checkpoints/{stem}_inference.pt")
 
 
 
 
 
 
11
 
12
  def main() -> None:
13
  parser = argparse.ArgumentParser(description="Export a slim nanoTTS inference checkpoint.")
 
26
  "model": checkpoint["model"],
27
  "model_args": checkpoint["model_args"],
28
  "iter_num": checkpoint.get("iter_num"),
29
+ "train_loss": checkpoint.get("train_loss"),
30
+ "val_loss": checkpoint.get("val_loss"),
31
  "source_checkpoint": str(args.source),
32
  }
33
 
 
37
  size_mib = args.output.stat().st_size / 1024 / 1024
38
  print(f"Wrote {args.output} ({size_mib:.1f} MiB)")
39
  print(f"Keys: {sorted(inference_checkpoint.keys())}")
40
+ print(f"Val loss: {inference_checkpoint.get('val_loss')}")
41
 
42
 
43
  if __name__ == "__main__":
scripts/upload_checkpoint.py CHANGED
@@ -8,8 +8,7 @@ from pathlib import Path
8
  from huggingface_hub import HfApi
9
  from huggingface_hub.errors import HfHubHTTPError
10
 
11
- DEFAULT_PATH = Path("checkpoints/nanotts_ckpt_030000_inference.pt")
12
-
13
 
14
  def main() -> None:
15
  parser = argparse.ArgumentParser(description="Upload the nanoTTS inference checkpoint to the Space.")
 
8
  from huggingface_hub import HfApi
9
  from huggingface_hub.errors import HfHubHTTPError
10
 
11
+ DEFAULT_PATH = Path("checkpoints/ckpt_025000_inference.pt")
 
12
 
13
  def main() -> None:
14
  parser = argparse.ArgumentParser(description="Upload the nanoTTS inference checkpoint to the Space.")