marigold334 commited on
Commit
93e433e
โ€ข
1 Parent(s): 486e21a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -12
app.py CHANGED
@@ -36,7 +36,7 @@ class TTS:
36
  self.voicegenerator.eval()
37
  self.voicegenerator.remove_weight_norm()
38
 
39
- def inference(self, input_textm, noise_scale = 0.667, length_scale = 1.0):
40
  filters = '([.,!?])'
41
  sentence = re.sub(re.compile(filters), '', input_text)
42
  x = text_to_sequence(sentence)
@@ -70,15 +70,6 @@ def centered_text(input_text, mode = "h1",):
70
  st.markdown(
71
  f"<{mode} style='text-align: center;'>{input_text}</{mode}>", unsafe_allow_html = True)
72
 
73
- def generate_voice(input_text):
74
- # TTS Inference
75
- voice = st.session_state.TTS.inference(input_text)
76
-
77
- # Play audio
78
- st.audio(voice,sample_rate = 22050)
79
- st.caption("Generated Voice by" + st.session_state.model_variant)
80
-
81
-
82
  init_session_state()
83
 
84
  centered_text("๐Ÿ”‰ ์†Œ์‹  Team Demo")
@@ -109,11 +100,13 @@ with col2:
109
  update_model()
110
  st.snow()
111
 
112
- noise_scale = st.slider('noise๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.', 0., 2., value = 0.66, step = 0.01)
113
  length_scale = st.slider('์†๋„๋ฅผ ์กฐ์ ˆํ•ฉ๋‹ˆ๋‹ค.', 0., 2., value = 1., step = 0.01)
114
  button_gen = st.button("Generate Voice")
115
  if button_gen == True:
116
- generate_voice(input_text, noise_scale, length_scale)
 
 
117
  st.balloons()
118
 
119
 
 
36
  self.voicegenerator.eval()
37
  self.voicegenerator.remove_weight_norm()
38
 
39
+ def inference(self, input_text, noise_scale = 0.667, length_scale = 1.0):
40
  filters = '([.,!?])'
41
  sentence = re.sub(re.compile(filters), '', input_text)
42
  x = text_to_sequence(sentence)
 
70
  st.markdown(
71
  f"<{mode} style='text-align: center;'>{input_text}</{mode}>", unsafe_allow_html = True)
72
 
 
 
 
 
 
 
 
 
 
73
  init_session_state()
74
 
75
  centered_text("๐Ÿ”‰ ์†Œ์‹  Team Demo")
 
100
  update_model()
101
  st.snow()
102
 
103
+ noise_scale = st.slider('noise๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.', 0., 2., value = 0.33, step = 0.01)
104
  length_scale = st.slider('์†๋„๋ฅผ ์กฐ์ ˆํ•ฉ๋‹ˆ๋‹ค.', 0., 2., value = 1., step = 0.01)
105
  button_gen = st.button("Generate Voice")
106
  if button_gen == True:
107
+ voice = st.session_state.TTS.inference(input_text, noise_scale, length_scale)
108
+ st.audio(voice,sample_rate = 22050)
109
+ st.caption("Generated Voice by" + st.session_state.model_variant)
110
  st.balloons()
111
 
112