Anita-19 commited on
Commit
f67015b
Β·
verified Β·
1 Parent(s): 3d6a44d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -3
main.py CHANGED
@@ -299,14 +299,20 @@ def emotion_aware_tts_pipeline(input_text=None, file_input=None):
299
  emotion = emotion_data['label']
300
  confidence = emotion_data['score']
301
 
302
- # Adjust pitch and speed
303
  settings = emotion_settings.get(emotion.lower(), {"pitch": 1.0, "speed": 1.0})
304
- pitch = settings["pitch"]
305
  speed = settings["speed"]
 
 
306
 
307
  # Generate audio
308
  audio_path = "output.wav"
309
- tts_model.tts_to_file(text=input_text, file_path=audio_path, speed=speed, pitch=pitch)
 
 
 
 
 
310
 
311
  return f"Detected Emotion: {emotion} (Confidence: {confidence:.2f})", audio_path
312
  else:
 
299
  emotion = emotion_data['label']
300
  confidence = emotion_data['score']
301
 
302
+ # Adjust text for speed
303
  settings = emotion_settings.get(emotion.lower(), {"pitch": 1.0, "speed": 1.0})
 
304
  speed = settings["speed"]
305
+ pitch = settings["pitch"]
306
+
307
 
308
  # Generate audio
309
  audio_path = "output.wav"
310
+ tts_model.tts_to_file(text=input_text, file_path=audio_path)
311
+
312
+ # Adjust pitch
313
+ pitch_factor = (pitch - 1.0) * 12 # Convert to semitones for librosa
314
+ adjust_pitch(audio_path, pitch_factor)
315
+
316
 
317
  return f"Detected Emotion: {emotion} (Confidence: {confidence:.2f})", audio_path
318
  else: