Spaces:
Runtime error
Runtime error
Update main.py
Browse files
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
|
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
|
|
|
|
|
|
|
|
|
|
|
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:
|