unijoh commited on
Commit
1d4c12b
1 Parent(s): f7a79dd

Update tts.py

Browse files
Files changed (1) hide show
  1. tts.py +6 -5
tts.py CHANGED
@@ -25,12 +25,13 @@ def synthesize_speech(text):
25
  result = pipe(text)
26
  logging.debug(f"Pipeline result: {result}")
27
 
28
- # Check if the output contains 'waveform' key
29
- if 'waveform' in result:
30
- waveform = result['waveform']
31
- # Save waveform to an audio file
 
32
  audio_path = "output.wav"
33
- sf.write(audio_path, waveform, 16000) # Write the waveform using soundfile
34
  return audio_path
35
  else:
36
  logging.error(f"Unexpected pipeline output: {result}")
 
25
  result = pipe(text)
26
  logging.debug(f"Pipeline result: {result}")
27
 
28
+ # Check if the output contains 'audio' and 'sampling_rate' keys
29
+ if 'audio' in result and 'sampling_rate' in result:
30
+ audio = result['audio']
31
+ sampling_rate = result['sampling_rate']
32
+ # Save audio to an audio file
33
  audio_path = "output.wav"
34
+ sf.write(audio_path, audio[0], sampling_rate) # Write the audio using soundfile
35
  return audio_path
36
  else:
37
  logging.error(f"Unexpected pipeline output: {result}")