RafaG commited on
Commit
fe0db59
·
verified ·
1 Parent(s): dec6ec7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -22
app.py CHANGED
@@ -96,7 +96,7 @@ def generate_audio(texto, modelo_de_voz, velocidade, tom, volume):
96
 
97
  output_dir = "output"
98
  os.makedirs(output_dir, exist_ok=True)
99
- mp3_output_file = os.path.join(output_dir, "new_audio.mp3")
100
 
101
  cmd = [
102
  "edge-tts",
@@ -105,7 +105,7 @@ def generate_audio(texto, modelo_de_voz, velocidade, tom, volume):
105
  "--volume=" + volume_str,
106
  "-v", actual_voice,
107
  "-t", texto,
108
- "--write-media", mp3_output_file
109
  ]
110
 
111
  print("Gerando áudio...")
@@ -116,10 +116,7 @@ def generate_audio(texto, modelo_de_voz, velocidade, tom, volume):
116
  return None
117
 
118
  print("Áudio gerado com sucesso!")
119
- wav_output_file = os.path.join(output_dir, "new_audio.wav")
120
- audio = AudioSegment.from_mp3(mp3_output_file)
121
- audio.export(wav_output_file, format="wav")
122
- return wav_output_file
123
 
124
  def generate_audio_from_file(file_path, modelo_de_voz, velocidade, tom, volume):
125
  # Extrai o nome real da voz formatada, se necessário
@@ -132,7 +129,7 @@ def generate_audio_from_file(file_path, modelo_de_voz, velocidade, tom, volume):
132
 
133
  output_dir = "output"
134
  os.makedirs(output_dir, exist_ok=True)
135
- mp3_output_file = os.path.join(output_dir, "new_audio.mp3")
136
 
137
  # Usar -f FILE para passar o caminho do arquivo de texto
138
  cmd = [
@@ -142,7 +139,7 @@ def generate_audio_from_file(file_path, modelo_de_voz, velocidade, tom, volume):
142
  "--pitch=" + pitch_str,
143
  "--volume=" + volume_str,
144
  "-v", actual_voice,
145
- "--write-media", mp3_output_file
146
  ]
147
 
148
  print("Gerando áudio do arquivo...")
@@ -153,10 +150,7 @@ def generate_audio_from_file(file_path, modelo_de_voz, velocidade, tom, volume):
153
  return None
154
 
155
  print("Áudio gerado com sucesso!")
156
- wav_output_file = os.path.join(output_dir, "new_audio.wav")
157
- audio = AudioSegment.from_mp3(mp3_output_file)
158
- audio.export(wav_output_file, format="wav")
159
- return wav_output_file
160
 
161
  def controlador_generate_audio_from_file(file, voice_model_input, speed_input, pitch_input, volume_input, checkbox_cortar_silencio):
162
  if file is None:
@@ -242,16 +236,7 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="green", secondary_hue="blue"
242
  )
243
 
244
  checkbox_cortar_silencio = gr.Checkbox(label="Cortar Silencio", interactive=True)
245
- audio_output = gr.Audio(
246
- label="Resultado",
247
- type="filepath",
248
- interactive=False,
249
- streaming=False,
250
- format="mp3",
251
- waveform_options={"show_controls": True},
252
- autoplay=False,
253
- show_download_button=True
254
- )
255
 
256
  with gr.Row():
257
  edgetts_button = gr.Button(value="Falar")
 
96
 
97
  output_dir = "output"
98
  os.makedirs(output_dir, exist_ok=True)
99
+ output_file = os.path.join(output_dir, "new_audio.mp3")
100
 
101
  cmd = [
102
  "edge-tts",
 
105
  "--volume=" + volume_str,
106
  "-v", actual_voice,
107
  "-t", texto,
108
+ "--write-media", output_file
109
  ]
110
 
111
  print("Gerando áudio...")
 
116
  return None
117
 
118
  print("Áudio gerado com sucesso!")
119
+ return output_file
 
 
 
120
 
121
  def generate_audio_from_file(file_path, modelo_de_voz, velocidade, tom, volume):
122
  # Extrai o nome real da voz formatada, se necessário
 
129
 
130
  output_dir = "output"
131
  os.makedirs(output_dir, exist_ok=True)
132
+ output_file = os.path.join(output_dir, "new_audio.mp3")
133
 
134
  # Usar -f FILE para passar o caminho do arquivo de texto
135
  cmd = [
 
139
  "--pitch=" + pitch_str,
140
  "--volume=" + volume_str,
141
  "-v", actual_voice,
142
+ "--write-media", output_file
143
  ]
144
 
145
  print("Gerando áudio do arquivo...")
 
150
  return None
151
 
152
  print("Áudio gerado com sucesso!")
153
+ return output_file
 
 
 
154
 
155
  def controlador_generate_audio_from_file(file, voice_model_input, speed_input, pitch_input, volume_input, checkbox_cortar_silencio):
156
  if file is None:
 
236
  )
237
 
238
  checkbox_cortar_silencio = gr.Checkbox(label="Cortar Silencio", interactive=True)
239
+ audio_output = gr.Audio(label="Resultado", type="filepath", interactive=False)
 
 
 
 
 
 
 
 
 
240
 
241
  with gr.Row():
242
  edgetts_button = gr.Button(value="Falar")