DHEIVER commited on
Commit
9c6803e
·
verified ·
1 Parent(s): e5d55fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -43,14 +43,6 @@ my_article = """
43
  <p>4. Reproduza o áudio gerado ou faça o download.</p>
44
  """
45
 
46
- # Componentes de entrada e saída
47
- my_inputs = [
48
- gr.Textbox(lines=10, label="Texto em Português", placeholder="Insira o texto aqui... (até 500 tokens)"),
49
- gr.Radio(label="Voz", choices=TTS_VOICES, value="Ed") # Voz padrão: masculina
50
- ]
51
-
52
- my_outputs = gr.Audio(type="filepath", label="Áudio Gerado")
53
-
54
  # Função para sintetizar a fala
55
  def tts(text: str, speaker_idx: str):
56
  # Baixar os arquivos do modelo
@@ -82,17 +74,25 @@ def tts(text: str, speaker_idx: str):
82
  synthesizer.save_wav(wavs, fp)
83
  return fp.name
84
 
85
- # Criar a interface Gradio
86
- iface = gr.Interface(
87
- fn=tts,
88
- inputs=my_inputs,
89
- outputs=my_outputs,
90
- title=my_title,
91
- description=my_description,
92
- article=my_article,
93
- examples=my_examples,
94
- allow_flagging=False
95
- )
 
 
 
 
 
 
 
 
96
 
97
  # Iniciar a interface
98
- iface.launch()
 
43
  <p>4. Reproduza o áudio gerado ou faça o download.</p>
44
  """
45
 
 
 
 
 
 
 
 
 
46
  # Função para sintetizar a fala
47
  def tts(text: str, speaker_idx: str):
48
  # Baixar os arquivos do modelo
 
74
  synthesizer.save_wav(wavs, fp)
75
  return fp.name
76
 
77
+ # Criar a interface Gradio com layout moderno
78
+ with gr.Blocks(title=my_title, css=".gradio-container {max-width: 800px; margin: auto;}") as demo:
79
+ gr.Markdown(f"# {my_title}")
80
+ gr.Markdown(my_description)
81
+
82
+ with gr.Row():
83
+ with gr.Column():
84
+ text_input = gr.Textbox(lines=10, label="Texto em Português", placeholder="Insira o texto aqui... (até 500 tokens)")
85
+ voice_selector = gr.Radio(label="Voz", choices=TTS_VOICES, value="Ed")
86
+ submit_button = gr.Button("Gerar Áudio", variant="primary")
87
+ with gr.Column():
88
+ audio_output = gr.Audio(type="filepath", label="Áudio Gerado")
89
+ gr.Markdown(my_article)
90
+
91
+ # Exemplos
92
+ gr.Examples(examples=my_examples, inputs=[text_input, voice_selector], outputs=audio_output, fn=tts, cache_examples=True)
93
+
94
+ # Ação do botão
95
+ submit_button.click(fn=tts, inputs=[text_input, voice_selector], outputs=audio_output)
96
 
97
  # Iniciar a interface
98
+ demo.launch()