Anita-19 commited on
Commit
a95975f
Β·
verified Β·
1 Parent(s): 521da50

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -59,16 +59,19 @@ def emotion_aware_tts_pipeline(input_text=None, file_input=None):
59
  emotion = emotion_data['label']
60
  confidence = emotion_data['score']
61
 
62
- # Adjust pitch and speed
63
  settings = emotion_settings.get(emotion.lower(), {"pitch": 1.0, "speed": 1.0})
64
- pitch = settings["pitch"]
65
  speed = settings["speed"]
 
 
66
 
67
  # Generate audio
68
  audio_path = "output.wav"
69
- tts_model.tts_to_file(text=input_text, file_path=audio_path, speed=speed, pitch=pitch)
70
-
71
 
 
 
 
72
 
73
  return f"Detected Emotion: {emotion} (Confidence: {confidence:.2f})", audio_path
74
  else:
@@ -77,6 +80,8 @@ def emotion_aware_tts_pipeline(input_text=None, file_input=None):
77
  return f"Error: {str(e)}", None
78
 
79
 
 
 
80
  # Define Gradio interface
81
  interface = gr.Interface(
82
  fn=emotion_aware_tts_pipeline,
 
59
  emotion = emotion_data['label']
60
  confidence = emotion_data['score']
61
 
62
+ # Adjust text for speed
63
  settings = emotion_settings.get(emotion.lower(), {"pitch": 1.0, "speed": 1.0})
 
64
  speed = settings["speed"]
65
+ pitch = settings["pitch"]
66
+
67
 
68
  # Generate audio
69
  audio_path = "output.wav"
70
+ tts_model.tts_to_file(text=input_text, file_path=audio_path)
 
71
 
72
+ # Adjust pitch
73
+ pitch_factor = (pitch - 1.0) * 12 # Convert to semitones for librosa
74
+ adjust_pitch(audio_path, pitch_factor)
75
 
76
  return f"Detected Emotion: {emotion} (Confidence: {confidence:.2f})", audio_path
77
  else:
 
80
  return f"Error: {str(e)}", None
81
 
82
 
83
+
84
+
85
  # Define Gradio interface
86
  interface = gr.Interface(
87
  fn=emotion_aware_tts_pipeline,