reach-vb HF staff commited on
Commit
0ee0e76
·
1 Parent(s): f79241e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -26,7 +26,7 @@ def predict(text, speaker):
26
 
27
  inputs = processor(text=text, return_tensors="pt")
28
 
29
- speaker_embedding = np.load(speaker_embeddings[speaker[:3]])
30
  speaker_embedding = torch.tensor(speaker_embedding).unsqueeze(0)
31
 
32
  speech = model.generate_speech(inputs["input_ids"], speaker_embedding, vocoder=vocoder)
@@ -74,19 +74,18 @@ article = """
74
  """
75
 
76
  examples = [
77
- ["It is not in the stars to hold our destiny but in ourselves.", "BDL (male)"],
78
- ["The octopus and Oliver went to the opera in October.", "CLB (female)"],
79
- ["She sells seashells by the seashore. I saw a kitten eating chicken in the kitchen.", "RMS (male)"],
80
- ["Brisk brave brigadiers brandished broad bright blades, blunderbusses, and bludgeons—balancing them badly.", "SLT (female)"],
81
- ["A synonym for cinnamon is a cinnamon synonym.", "BDL (male)"],
82
- ["How much wood would a woodchuck chuck if a woodchuck could chuck wood? He would chuck, he would, as much as he could, and chuck as much wood as a woodchuck would if a woodchuck could chuck wood.", "CLB (female)"],
83
  ]
84
 
85
  gr.Interface(
86
  fn=predict,
87
  inputs=[
88
  gr.Text(label="Input Text"),
89
- gr.Radio(label="Speaker", choices=["BDL (male)", "CLB (female)", "RMS (male)", "SLT (female)"], value="BDL (male)"),
90
  ],
91
  outputs=[
92
  gr.Audio(label="Generated Speech", type="numpy"),
 
26
 
27
  inputs = processor(text=text, return_tensors="pt")
28
 
29
+ speaker_embedding = np.random.default_rng().uniform(-0.20,0.20,512)
30
  speaker_embedding = torch.tensor(speaker_embedding).unsqueeze(0)
31
 
32
  speech = model.generate_speech(inputs["input_ids"], speaker_embedding, vocoder=vocoder)
 
74
  """
75
 
76
  examples = [
77
+ ["It is not in the stars to hold our destiny but in ourselves."],
78
+ ["The octopus and Oliver went to the opera in October."],
79
+ ["She sells seashells by the seashore. I saw a kitten eating chicken in the kitchen."],
80
+ ["Brisk brave brigadiers brandished broad bright blades, blunderbusses, and bludgeons—balancing them badly."],
81
+ ["A synonym for cinnamon is a cinnamon synonym."],
82
+ ["How much wood would a woodchuck chuck if a woodchuck could chuck wood? He would chuck, he would, as much as he could, and chuck as much wood as a woodchuck would if a woodchuck could chuck wood."],
83
  ]
84
 
85
  gr.Interface(
86
  fn=predict,
87
  inputs=[
88
  gr.Text(label="Input Text"),
 
89
  ],
90
  outputs=[
91
  gr.Audio(label="Generated Speech", type="numpy"),