Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -43,18 +43,16 @@ tts_model = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC")
|
|
43 |
def generate_emotional_speech(text, emotion):
|
44 |
# Map emotion to voice modulation parameters (pitch, speed)
|
45 |
emotion_settings = {
|
46 |
-
"
|
47 |
-
"joy": {"pitch": 1.
|
48 |
-
"
|
49 |
-
"
|
50 |
-
"angry": {"pitch": 1.6, "speed": 1.4}, # Intense and sharp
|
51 |
"fear": {"pitch": 1.2, "speed": 0.95}, # Tense and slightly slow
|
|
|
52 |
"disgust": {"pitch": 0.9, "speed": 0.95}, # Low and deliberate
|
53 |
"shame": {"pitch": 0.8, "speed": 0.85}, # Quiet, subdued tone
|
54 |
-
"neutral": {"pitch": 1.0, "speed": 1.0}, # Baseline conversational tone
|
55 |
-
}
|
56 |
-
|
57 |
|
|
|
58 |
|
59 |
# Retrieve pitch and speed based on detected emotion
|
60 |
settings = emotion_settings.get(emotion, {"pitch": 1.0, "speed": 1.0})
|
@@ -288,12 +286,14 @@ tts_model = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC")
|
|
288 |
|
289 |
# Emotion-specific settings for pitch and speed
|
290 |
emotion_settings = {
|
291 |
-
"joy": {"pitch": 1.2, "speed": 1.1},
|
292 |
-
"sadness": {"pitch": 0.8, "speed": 0.9},
|
293 |
-
"anger": {"pitch": 1.0, "speed": 1.2},
|
294 |
-
"fear": {"pitch": 0.9, "speed": 1.0},
|
295 |
-
"surprise": {"pitch": 1.3, "speed": 1.2},
|
296 |
"neutral": {"pitch": 1.0, "speed": 1.0},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
}
|
298 |
|
299 |
import librosa
|
|
|
43 |
def generate_emotional_speech(text, emotion):
|
44 |
# Map emotion to voice modulation parameters (pitch, speed)
|
45 |
emotion_settings = {
|
46 |
+
"neutral": {"pitch": 1.0, "speed": 1.0}, # Baseline conversational tone
|
47 |
+
"joy": {"pitch": 1.3, "speed": 1.2}, # Upbeat and energetic
|
48 |
+
"sadness": {"pitch": 0.8, "speed": 0.9}, # Subdued, slow tone
|
49 |
+
"anger": {"pitch": 1.6, "speed": 1.4}, # Intense and sharp
|
|
|
50 |
"fear": {"pitch": 1.2, "speed": 0.95}, # Tense and slightly slow
|
51 |
+
"surprise": {"pitch": 1.5, "speed": 1.3}, # Excitement with high pitch and fast speech
|
52 |
"disgust": {"pitch": 0.9, "speed": 0.95}, # Low and deliberate
|
53 |
"shame": {"pitch": 0.8, "speed": 0.85}, # Quiet, subdued tone
|
|
|
|
|
|
|
54 |
|
55 |
+
}
|
56 |
|
57 |
# Retrieve pitch and speed based on detected emotion
|
58 |
settings = emotion_settings.get(emotion, {"pitch": 1.0, "speed": 1.0})
|
|
|
286 |
|
287 |
# Emotion-specific settings for pitch and speed
|
288 |
emotion_settings = {
|
|
|
|
|
|
|
|
|
|
|
289 |
"neutral": {"pitch": 1.0, "speed": 1.0},
|
290 |
+
"joy": {"pitch": 1.3, "speed": 1.2},
|
291 |
+
"sadness": {"pitch": 0.8, "speed": 0.9},
|
292 |
+
"anger": {"pitch": 1.6, "speed": 1.4},
|
293 |
+
"fear": {"pitch": 1.2, "speed": 0.95},
|
294 |
+
"surprise": {"pitch": 1.5, "speed": 1.3},
|
295 |
+
"disgust": {"pitch": 0.9, "speed": 0.95},
|
296 |
+
"shame": {"pitch": 0.8, "speed": 0.85},
|
297 |
}
|
298 |
|
299 |
import librosa
|