unijoh commited on
Commit
f7a79dd
1 Parent(s): 3e1ff6b

Update tts.py

Browse files
Files changed (1) hide show
  1. tts.py +11 -5
tts.py CHANGED
@@ -23,12 +23,18 @@ def synthesize_speech(text):
23
  return None
24
 
25
  result = pipe(text)
26
- waveform = result["waveform"]
27
 
28
- # Save waveform to an audio file
29
- audio_path = "output.wav"
30
- sf.write(audio_path, waveform, 16000) # Write the waveform using soundfile
31
- return audio_path
 
 
 
 
 
 
32
  except Exception as e:
33
  logging.error(f"Error during speech synthesis: {e}")
34
  return None
 
23
  return None
24
 
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}")
37
+ return None
38
  except Exception as e:
39
  logging.error(f"Error during speech synthesis: {e}")
40
  return None