sulaimank commited on
Commit
b29994f
·
verified ·
1 Parent(s): 0b5cf02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -10
app.py CHANGED
@@ -7,21 +7,20 @@ from TTS.utils.synthesizer import Synthesizer
7
  # Max input text length
8
  MAX_TXT_LEN = 400
9
 
10
- # Checkpoints from your repo
11
  MODEL_INFO = {
12
- # "checkpoint_2080000": "checkpoint_2080000.pth",
13
- # "checkpoint_2085000": "checkpoint_2085000.pth",
14
- # "checkpoint_2090000": "checkpoint_2090000.pth",
15
- # "checkpoint_2095000": "checkpoint_2095000.pth",
16
  "checkpoint_2100000": "checkpoint_2100000.pth",
 
 
 
17
  }
18
 
19
  # Download config once
20
- config_path = hf_hub_download("huggingface.co/sulaimank/luganda_LMs/", filename="config.json")
21
 
22
  # Function to load synthesizer on demand
23
  def load_synth(model_file):
24
- model_path = hf_hub_download("huggingface.co/sulaimank/luganda_LMs/", filename=model_file)
25
  return Synthesizer(
26
  tts_checkpoint=model_path,
27
  tts_config_path=config_path
@@ -40,13 +39,29 @@ def tts(text: str, model_choice: str):
40
  synthesizer.save_wav(wav, fp.name)
41
  return fp.name
42
 
43
- # Example sentences
44
  examples = [
45
- ["Oli otya, nsanyuse okukulaba.", "checkpoint_2080000"],
46
- ["Abantu abangi mu Uganda bayogera Oluganda.", "checkpoint_2095000"],
47
  ]
48
 
49
  description = """
50
  🗣️ **Luganda TTS Demo** 🗣️
51
  Convert Luganda text into speech using VITS models trained with Coqui TTS.
52
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  # Max input text length
8
  MAX_TXT_LEN = 400
9
 
10
+ # Available checkpoint(s) from your repo
11
  MODEL_INFO = {
 
 
 
 
12
  "checkpoint_2100000": "checkpoint_2100000.pth",
13
+ # If you want to add more later, just extend this dict
14
+ # "checkpoint_2095000": "checkpoint_2095000.pth",
15
+ # "checkpoint_2090000": "checkpoint_2090000.pth",
16
  }
17
 
18
  # Download config once
19
+ config_path = hf_hub_download("sulaimank/luganda_LMs", filename="config.json")
20
 
21
  # Function to load synthesizer on demand
22
  def load_synth(model_file):
23
+ model_path = hf_hub_download("sulaimank/luganda_LMs", filename=model_file)
24
  return Synthesizer(
25
  tts_checkpoint=model_path,
26
  tts_config_path=config_path
 
39
  synthesizer.save_wav(wav, fp.name)
40
  return fp.name
41
 
42
+ # Example sentences (must match available model choices)
43
  examples = [
44
+ ["Oli otya, nsanyuse okukulaba.", "checkpoint_2100000"],
45
+ ["Abantu abangi mu Uganda bayogera Oluganda.", "checkpoint_2100000"],
46
  ]
47
 
48
  description = """
49
  🗣️ **Luganda TTS Demo** 🗣️
50
  Convert Luganda text into speech using VITS models trained with Coqui TTS.
51
  """
52
+
53
+ iface = gr.Interface(
54
+ fn=tts,
55
+ inputs=[
56
+ gr.Textbox(label="Enter Luganda Text", value="Gyebale ko nnyo."),
57
+ gr.Radio(label="Choose Model", choices=list(MODEL_INFO.keys()), value="checkpoint_2100000"),
58
+ ],
59
+ outputs=gr.Audio(label="Generated Speech", type="filepath"),
60
+ examples=examples,
61
+ title="Luganda TTS",
62
+ description=description,
63
+ live=False,
64
+ )
65
+
66
+ if __name__ == "__main__":
67
+ iface.launch()