dangtr0408 commited on
Commit
156f2a1
·
1 Parent(s): f522903

minor fixes

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -6,6 +6,7 @@ import soundfile as sf
6
  import torch
7
  import traceback
8
  import random
 
9
  import spaces
10
 
11
  import sys
@@ -98,8 +99,8 @@ def main(text_prompt, reference_paths, speed, denoise, avg_style, stabilize):
98
  styles = model.get_styles(speaker, denoise, avg_style)
99
  r = model.generate(phonemes, styles, stabilize, 18)
100
 
101
- sf.write("output_demo.wav", r, samplerate=24000)
102
- return "output_demo.wav", "Audio generated successfully!"
103
 
104
  except Exception as e:
105
  error_message = traceback.format_exc()
@@ -127,9 +128,9 @@ with gr.Blocks() as demo:
127
  with gr.Row(equal_height=True):
128
  with gr.Column():
129
  speed = gr.Slider(0.0, 2.0, step=0.1, value=1.0, label="Speed")
130
- denoise = gr.Slider(0.0, 1.0, step=0.1, value=0.0, label="Denoise Strength")
131
- avg_style = gr.Checkbox(label="Use Average Styles", value=False)
132
- stabilize = gr.Checkbox(label="Stabilize Speaking Speed", value=False)
133
 
134
  text_prompt = gr.Textbox(label="Text Prompt", placeholder="Enter your text here...", lines=10, max_lines=10)
135
 
@@ -138,13 +139,15 @@ with gr.Blocks() as demo:
138
 
139
  with gr.Column():
140
  reference_audios = gr.Audio(label="Reference Audios", type='filepath')
141
- synthesized_audio = gr.Audio(label="Generate Audio", type="filepath")
142
 
143
  example_voices = gr.Dropdown(
144
  label="Example voices",
145
  choices=voice_choices,
146
- value=voice_choices[0][0],
147
  interactive=True,
 
 
148
  )
149
 
150
  with gr.Row(equal_height=False):
 
6
  import torch
7
  import traceback
8
  import random
9
+ import numpy as np
10
  import spaces
11
 
12
  import sys
 
99
  styles = model.get_styles(speaker, denoise, avg_style)
100
  r = model.generate(phonemes, styles, stabilize, 18)
101
 
102
+ r = r / np.max(np.abs(r)) #Normalize
103
+ return (24000, r), "Audio generated successfully!"
104
 
105
  except Exception as e:
106
  error_message = traceback.format_exc()
 
128
  with gr.Row(equal_height=True):
129
  with gr.Column():
130
  speed = gr.Slider(0.0, 2.0, step=0.1, value=1.0, label="Speed")
131
+ denoise = gr.Slider(0.0, 1.0, step=0.1, value=0.2, label="Denoise Strength")
132
+ avg_style = gr.Checkbox(label="Use Average Styles", value=True)
133
+ stabilize = gr.Checkbox(label="Stabilize Speaking Speed", value=True)
134
 
135
  text_prompt = gr.Textbox(label="Text Prompt", placeholder="Enter your text here...", lines=10, max_lines=10)
136
 
 
139
 
140
  with gr.Column():
141
  reference_audios = gr.Audio(label="Reference Audios", type='filepath')
142
+ synthesized_audio = gr.Audio(label="Generate Audio", type='numpy')
143
 
144
  example_voices = gr.Dropdown(
145
  label="Example voices",
146
  choices=voice_choices,
147
+ value=None,
148
  interactive=True,
149
+ allow_custom_value=False,
150
+ filterable=False
151
  )
152
 
153
  with gr.Row(equal_height=False):