AlexK-PL commited on
Commit
eec8d3d
·
1 Parent(s): 3ed419f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -10,6 +10,7 @@ from melgan.utils.hparams import load_hparam
10
 
11
  import torch
12
  import numpy as np
 
13
 
14
  from matplotlib import pyplot as plt
15
  from matplotlib import gridspec
@@ -88,8 +89,19 @@ def synthesize(text, gst_1, gst_2, gst_3):
88
  return (22050, audio_numpy), fig_mel # fig_align
89
 
90
 
91
- iface = gr.Interface(fn=synthesize, inputs=[gr.Textbox(label="Input Text"), gr.Slider(0.2, 0.45, label="First style token weight:"),
92
- gr.Slider(0.2, 0.45, label="Second style token weight:"), gr.Slider(0.2, 0.45, label="Third style token weight:")],
 
 
 
 
 
 
 
 
 
 
 
93
  outputs=[gr.Audio(label="Generated Speech", type="numpy"), gr.Plot(label="Output"),],
94
  title="Single-Head Attention Tacotron2 with Style Tokens", description=DESCRIPTION)
95
  iface.launch()
 
10
 
11
  import torch
12
  import numpy as np
13
+ import random
14
 
15
  from matplotlib import pyplot as plt
16
  from matplotlib import gridspec
 
89
  return (22050, audio_numpy), fig_mel # fig_align
90
 
91
 
92
+ def randomize_style_weights():
93
+ rand_weight_1 = random.randrange(0.3, 0.45, 0.01)
94
+ rand_weight_2 = random.randrange(0.3, 0.45, 0.01)
95
+ rand_weight_3 = 1.0 - (rand_weight_1 + rand_weight_2)
96
+
97
+ return rand_weight_1, rand_weight_2, rand_weight_3
98
+
99
+
100
+ w1, w2, w3 = randomize_style_weights()
101
+
102
+ iface = gr.Interface(fn=synthesize, inputs=[gr.Textbox(label="Input Text"), gr.Slider(0.2, 0.45, label="First style token weight:", value=w1),
103
+ gr.Slider(0.2, 0.45, label="Second style token weight:", value=w2),
104
+ gr.Slider(0.2, 0.45, label="Third style token weight:",value=w3)],
105
  outputs=[gr.Audio(label="Generated Speech", type="numpy"), gr.Plot(label="Output"),],
106
  title="Single-Head Attention Tacotron2 with Style Tokens", description=DESCRIPTION)
107
  iface.launch()