ccoreilly commited on
Commit
f47653c
1 Parent(s): 9dd669d

use filepath

Browse files
Files changed (2) hide show
  1. app.py +20 -7
  2. engine.py +1 -1
app.py CHANGED
@@ -59,12 +59,25 @@ def tts(text, speaker_idx):
59
  wav_coll = model_collectivat.tts(text)
60
  wav_piper = model_piper.synthesize(text)
61
 
62
- return (model_bsc.tts_config.audio["sample_rate"], wav_bsc), (22000, wav_coll), (16000, wav_piper)
63
 
64
  # return output
 
65
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
66
- model_bsc.save_wav(wavs, fp)
67
- return fp.name
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
 
70
  description="""
@@ -83,12 +96,12 @@ iface = gr.Interface(
83
  label="Text",
84
  default="L'Èlia i l'Alí a l'aula. L'oli i l'ou. Lulú olorava la lila.",
85
  ),
86
- gr.Dropdown(label="Selecciona un parlant", choices=SPEAKERS, default=None)
87
  ],
88
  outputs=[
89
- gr.Audio(label="BSC VITS",type="numpy"),
90
- gr.Audio(label="Collectivat Fastspeech",type="numpy"),
91
- gr.Audio(label="Piper VITS",type="numpy")
92
  ],
93
  title="🗣️ TTS Català Multi Parlant - VITS 🗣️",
94
  description=description,
 
59
  wav_coll = model_collectivat.tts(text)
60
  wav_piper = model_piper.synthesize(text)
61
 
62
+ #return (model_bsc.tts_config.audio["sample_rate"], wav_bsc), (22000, wav_coll), (16000, wav_piper)
63
 
64
  # return output
65
+ fp_bsc = ""
66
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
67
+ model_bsc.save_wav(wav_bsc, fp)
68
+ fp_bsc = fp.name
69
+
70
+ fp_coll = ""
71
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
72
+ model_collectivat.save_wav(wav_coll, fp)
73
+ fp_coll = fp.name
74
+
75
+ fp_piper = ""
76
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
77
+ fp.write(wav_piper)
78
+ fp_piper = fp.name
79
+
80
+ return fp_bsc, fp_coll, fp_piper
81
 
82
 
83
  description="""
 
96
  label="Text",
97
  default="L'Èlia i l'Alí a l'aula. L'oli i l'ou. Lulú olorava la lila.",
98
  ),
99
+ gr.Dropdown(label="Selecciona un parlant", choices=SPEAKERS, default="ona")
100
  ],
101
  outputs=[
102
+ gr.Audio(label="BSC VITS",type="filepath"),
103
+ gr.Audio(label="Collectivat Fastspeech",type="filepath"),
104
+ gr.Audio(label="Piper VITS",type="filepath")
105
  ],
106
  title="🗣️ TTS Català Multi Parlant - VITS 🗣️",
107
  description=description,
engine.py CHANGED
@@ -104,7 +104,7 @@ class Piper:
104
  },
105
  )[0].squeeze((0, 1))
106
  audio = audio_float_to_int16(audio.squeeze())
107
- return audio
108
  # Convert to WAV
109
  with io.BytesIO() as wav_io:
110
  wav_file: wave.Wave_write = wave.open(wav_io, "wb")
 
104
  },
105
  )[0].squeeze((0, 1))
106
  audio = audio_float_to_int16(audio.squeeze())
107
+
108
  # Convert to WAV
109
  with io.BytesIO() as wav_io:
110
  wav_file: wave.Wave_write = wave.open(wav_io, "wb")