Skip to content

Commit

Permalink
Update default audio template
Browse files Browse the repository at this point in the history
  • Loading branch information
anticorrelator committed Jan 16, 2025
1 parent 44eb773 commit 77a7912
Showing 1 changed file with 41 additions and 28 deletions.
69 changes: 41 additions & 28 deletions packages/phoenix-evals/src/phoenix/evals/default_audio_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,71 @@
- Volume: Loudness of the speech (e.g., loud, soft, moderate).
- Intensity: Emotional strength or expression (e.g., subdued, sharp, exaggerated).
The classified emotion must be one of the following:
['anger', 'happiness', 'excitement', 'sadness', 'neutral', 'frustration', 'fear', 'surprise',
'disgust', 'other']
IMPORTANT: Choose the most dominant emotion expressed in the audio. Neutral should only be used when
no other emotion is clearly present, do your best to avoid this label.
************
Here is the base64 encoded audio string:
Here is the audio to classify:
"""

EMOTION_AUDIO_BASE_TEMPLATE_PT_2 = """{audio}"""

EMOTION_AUDIO_BASE_TEMPLATE_PT_3 = """
RESPONSE FORMAT:
Provide a single word from the list above representing the detected emotion.
************
POSSIBLE EMOTIONS:
['anger', 'happiness', 'excitement', 'sadness', 'neutral', 'frustration', 'fear', 'surprise',
'disgust', 'other']
IMPORTANT: Choose the most dominant emotion expressed in the audio. Neutral should only be used when
no other emotion is clearly present, do your best to avoid this label.
EXAMPLE RESPONSE: excitement
************
RESPONSE FORMAT:
Analyze the audio and respond in this format.
"""

Provide a single word from the list above representing the detected emotion.
EMOTION_AUDIO_EXPLANATION_TEMPLATE_PT_1 = """
You are an AI system designed to classify emotions in audio files.
EXAMPLE RESPONSE: excitement
### TASK:
First, explain in a step-by-step manner how the provided audio file based on these characteristics
and how they indicate the emotion of the speaker:
- Tone: General tone of the speaker (e.g., cheerful, tense, calm).
- Pitch: Level and variability of the pitch (e.g., high, low, monotone).
- Pace: Speed of speech (e.g., fast, slow, steady).
- Volume: Loudness of the speech (e.g., loud, soft, moderate).
- Intensity: Emotional strength or expression (e.g., subdued, sharp, exaggerated).
Analyze the audio and respond in this format.
Then, classify the primary emotion. The classified emotion must be one of the following:
['anger', 'happiness', 'excitement', 'sadness', 'neutral', 'frustration', 'fear', 'surprise',
'disgust', 'other']
IMPORTANT: Choose the most dominant emotion expressed in the audio. Neutral should only be used when
no other emotion is clearly present, do your best to avoid this label.
************
Here is the audio to classify:
"""

EMOTION_AUDIO_BASE_TEMPLATE_EXPLANATION = """
EMOTION_AUDIO_EXPLANATION_TEMPLATE_PT_3 = """
EXAMPLE RESPONSE FORMAT:
Write out in a step by step manner
an EXPLANATION to show how you determined the emotion of the audio considering the tone, pitch,
pace, volume, and intensity.
************
EXAMPLE RESPONSE:
1. Tone: The tone was enthusiastic and high-energy.
2. Pitch: The pitch was elevated and varied significantly.
3. Pace: The pace was fast, consistent with excitement.
4. Volume: The volume was loud and dynamic.
5. Intensity: The delivery was expressive and emotionally charged.
6. Conclusion: Based on these features, the primary emotion is 'excitement.'
EXPLANATION: An explanation of your reasoning based on the tone, pitch, pace, volume, and intensity
of the audio.
LABEL: "excitement"
************
EXPLANATION:
Analyze the audio and respond in the format shown above.
"""

EMOTION_AUDIO_RAILS = [
Expand Down Expand Up @@ -97,19 +114,15 @@
explanation_template=[
PromptPartTemplate(
content_type=PromptPartContentType.TEXT,
template=EMOTION_AUDIO_BASE_TEMPLATE_PT_1,
template=EMOTION_AUDIO_EXPLANATION_TEMPLATE_PT_1,
),
PromptPartTemplate(
content_type=PromptPartContentType.AUDIO,
template=EMOTION_AUDIO_BASE_TEMPLATE_PT_2,
),
PromptPartTemplate(
content_type=PromptPartContentType.TEXT,
template=EMOTION_AUDIO_BASE_TEMPLATE_PT_3,
),
PromptPartTemplate(
content_type=PromptPartContentType.TEXT,
template=EMOTION_AUDIO_BASE_TEMPLATE_EXPLANATION,
template=EMOTION_AUDIO_EXPLANATION_TEMPLATE_PT_3,
),
],
)
Expand Down

0 comments on commit 77a7912

Please sign in to comment.