Rajkumar Pramanik "RJproz commited on
Commit
f8e32a0
·
1 Parent(s): 3dde740
Files changed (1) hide show
  1. app.py +21 -22
app.py CHANGED
@@ -196,24 +196,23 @@ def generate_speech(description, text, temperature, max_tokens):
196
  if len(audio) > 2048:
197
  audio = audio[2048:]
198
 
199
- # Convert to WAV and save to temporary file
200
- # import tempfile
201
- # import soundfile as sf
202
 
203
- # audio_int16 = (audio * 32767).astype(np.int16)
204
 
205
- # # Create temporary file
206
- # with tempfile.NamedTemporaryFile(delete=False, suffix='.wav') as tmp_file:
207
- # tmp_path = tmp_file.name
208
 
209
- # # Save audio
210
- # sf.write(tmp_path, audio_int16, AUDIO_SAMPLE_RATE)
211
 
212
- # duration = len(audio) / AUDIO_SAMPLE_RATE
213
- # status_msg = f"Generated {duration:.2f}s of emotional speech!"
214
 
215
- tmp_path = "success"
216
- status_msg = "success"
217
  return tmp_path, status_msg
218
 
219
  except Exception as e:
@@ -287,17 +286,17 @@ with gr.Blocks(title="Maya1 - Open Source Emotional TTS", theme=gr.themes.Soft()
287
  with gr.Column(scale=1):
288
  gr.Markdown("### Generated Audio")
289
 
290
- # audio_output = gr.Audio(
291
- # label="Generated Speech",
292
- # type="filepath",
293
- # interactive=False
294
- # )
295
-
296
- audio_output = gr.Textbox(
297
- label="Autio Path",
298
- lines=3,
299
  interactive=False
300
  )
 
 
 
 
 
 
301
 
302
  status_output = gr.Textbox(
303
  label="Status",
 
196
  if len(audio) > 2048:
197
  audio = audio[2048:]
198
 
199
+ Convert to WAV and save to temporary file
200
+ import tempfile
201
+ import soundfile as sf
202
 
203
+ audio_int16 = (audio * 32767).astype(np.int16)
204
 
205
+ # Create temporary file
206
+ with tempfile.NamedTemporaryFile(delete=False, suffix='.wav') as tmp_file:
207
+ tmp_path = tmp_file.name
208
 
209
+ # Save audio
210
+ sf.write(tmp_path, audio_int16, AUDIO_SAMPLE_RATE)
211
 
212
+ duration = len(audio) / AUDIO_SAMPLE_RATE
213
+ status_msg = f"Generated {duration:.2f}s of emotional speech!"
214
 
215
+
 
216
  return tmp_path, status_msg
217
 
218
  except Exception as e:
 
286
  with gr.Column(scale=1):
287
  gr.Markdown("### Generated Audio")
288
 
289
+ audio_output = gr.Audio(
290
+ label="Generated Speech",
291
+ type="filepath",
 
 
 
 
 
 
292
  interactive=False
293
  )
294
+
295
+ # audio_output = gr.Textbox(
296
+ # label="Autio Path",
297
+ # lines=3,
298
+ # interactive=False
299
+ # )
300
 
301
  status_output = gr.Textbox(
302
  label="Status",