HirCoir commited on
Commit
0371a5c
1 Parent(s): 7f61c2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -18,24 +18,24 @@ def filter_text(text):
18
  def convert_text_to_speech(parrafo, model):
19
  parrafo_filtrado = filter_text(parrafo)
20
  bundle_dir = os.path.abspath(os.path.dirname(__file__))
21
- print("Cargando carpeta Modelos desde:", os.path.join(bundle_dir, '.'))
22
  random_name = '.'.join(random.choices(string.ascii_letters + string.digits, k=8)) + '.wav'
23
- output_file = os.path.join('.', random_name)
24
  piper_exe = '/app/piper'
25
- print("Ejecutando piper.exe desde:", piper_exe)
26
 
27
  if os.path.isfile(piper_exe):
28
- comando = f'echo {parrafo_filtrado} | "{piper_exe}" -m {model} -f {output_file}'
29
- subprocess.run(comando, shell=True)
30
  return output_file
31
  else:
32
- return "El archivo piper.exe no se encontró en el directorio correcto."
33
 
34
  @app.route('/')
35
  def index():
36
  model_folder = '.'
37
  bundle_dir = os.path.abspath(os.path.dirname(__file__))
38
- print("Cargando carpeta Modelos desde:", os.path.join(bundle_dir, model_folder))
39
  model_options = [file for file in os.listdir(model_folder) if file.endswith('.onnx')]
40
  return render_template('index.html', model_options=model_options)
41
 
@@ -52,4 +52,4 @@ def convert_text():
52
  return jsonify({'audio_base64': audio_base64})
53
 
54
  if __name__ == '__main__':
55
- app.run(debug=True, host='0.0.0.0', port=7860)
 
18
  def convert_text_to_speech(parrafo, model):
19
  parrafo_filtrado = filter_text(parrafo)
20
  bundle_dir = os.path.abspath(os.path.dirname(__file__))
21
+ print("Cargando carpeta Modelos desde:", bundle_dir)
22
  random_name = '.'.join(random.choices(string.ascii_letters + string.digits, k=8)) + '.wav'
23
+ output_file = os.path.join(bundle_dir, random_name)
24
  piper_exe = '/app/piper'
25
+ print("Ejecutando piper desde:", piper_exe)
26
 
27
  if os.path.isfile(piper_exe):
28
+ comando = f'echo {parrafo_filtrado} | {piper_exe} -m {model} -f {output_file}'
29
+ subprocess.run(comando, shell=True, check=True)
30
  return output_file
31
  else:
32
+ return "El archivo piper no se encontró en el directorio correcto."
33
 
34
  @app.route('/')
35
  def index():
36
  model_folder = '.'
37
  bundle_dir = os.path.abspath(os.path.dirname(__file__))
38
+ print("Cargando carpeta Modelos desde:", bundle_dir)
39
  model_options = [file for file in os.listdir(model_folder) if file.endswith('.onnx')]
40
  return render_template('index.html', model_options=model_options)
41
 
 
52
  return jsonify({'audio_base64': audio_base64})
53
 
54
  if __name__ == '__main__':
55
+ app.run(debug=True, host='0.0.0.0', port=7860)