Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -47,19 +47,14 @@ def emotion_aware_tts_pipeline(input_text=None, file_input=None):
|
|
47 |
emotion = emotion_data['label']
|
48 |
confidence = emotion_data['score']
|
49 |
|
50 |
-
# Adjust
|
51 |
settings = emotion_settings.get(emotion.lower(), {"pitch": 1.0, "speed": 1.0})
|
52 |
-
speed = settings["speed"]
|
53 |
pitch = settings["pitch"]
|
54 |
-
|
55 |
|
56 |
# Generate audio
|
57 |
audio_path = "output.wav"
|
58 |
-
tts_model.tts_to_file(text=input_text, file_path=audio_path)
|
59 |
-
|
60 |
-
# Adjust pitch
|
61 |
-
pitch_factor = (pitch - 1.0) * 12 # Convert to semitones for librosa
|
62 |
-
adjust_pitch(audio_path, pitch_factor)
|
63 |
|
64 |
return f"Detected Emotion: {emotion} (Confidence: {confidence:.2f})", audio_path
|
65 |
else:
|
|
|
47 |
emotion = emotion_data['label']
|
48 |
confidence = emotion_data['score']
|
49 |
|
50 |
+
# Adjust pitch and speed
|
51 |
settings = emotion_settings.get(emotion.lower(), {"pitch": 1.0, "speed": 1.0})
|
|
|
52 |
pitch = settings["pitch"]
|
53 |
+
speed = settings["speed"]
|
54 |
|
55 |
# Generate audio
|
56 |
audio_path = "output.wav"
|
57 |
+
tts_model.tts_to_file(text=input_text, file_path=audio_path, speed=speed, pitch=pitch)
|
|
|
|
|
|
|
|
|
58 |
|
59 |
return f"Detected Emotion: {emotion} (Confidence: {confidence:.2f})", audio_path
|
60 |
else:
|