Recipe catalog / passage-mood
Identify a passage's mood
What mood does the described musical passage express?
A musical passage is described in text, such as mode, tempo, register, and dynamics, and you need one of a fixed set of moods to compare against a request or to log what was played.
Explore this recipe interactively ยท Source and implementation guide
Use passage-mood in TypeScript
Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.
import { passageMood } from 'jev-recipes/passage-mood';
const result = await passageMood({
"passage": "D minor, slow tempo around 52 bpm, melody in the low-middle register moving mostly by step and descending at the end of each phrase, sustained chords in the left hand, dynamics piano throughout, frequent suspensions that resolve downward.",
"minConfidence": 0.8
});
console.log(result);
Input contract
| Field | Type | Needed |
|---|---|---|
| passage | string | Required |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"passage": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"passage"
]
},
"result": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"model": {
"type": "string"
},
"usage": {
"type": "object",
"properties": {
"input_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"output_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"input_tokens",
"output_tokens"
],
"additionalProperties": false
},
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"happy",
"sad",
"calm",
"energetic",
"tense",
"romantic",
"unclear"
]
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"probabilities": {
"type": "object",
"propertyNames": {
"type": "string",
"enum": [
"happy",
"sad",
"calm",
"energetic",
"tense",
"romantic",
"unclear"
]
},
"additionalProperties": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"required": [
"happy",
"sad",
"calm",
"energetic",
"tense",
"romantic",
"unclear"
]
}
},
"required": [
"model",
"usage",
"status",
"verdict",
"confidence",
"probabilities"
],
"additionalProperties": false
}
}Saved example result
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo passage-mood.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"verdict": "sad",
"confidence": 0.88,
"probabilities": {
"happy": 0,
"sad": 0.88,
"calm": 0.07,
"energetic": 0,
"tense": 0.02,
"romantic": 0.02,
"unclear": 0.01
}
}
Evaluation evidence
No verified live accuracy measurement is available. Evaluate representative cases before using this decision in your workflow.
Use the evaluation guide to measure this decision on your own labeled cases.
Limitations
- Judges the described musical features only. It does not know how any listener felt or what the performer intended.
- Reads the description as written and cannot hear audio; an inaccurate description yields a mood about the description, not the sound.
- Passages whose described features point in opposite directions, such as a bright major melody over a driving dissonant bass, resolve to the dominant mood or to unclear.
Related recipes
- emotion-kind: Use emotion-kind to label the emotion a writer expresses in a message, rather than the mood a described piece of music conveys.
- outcome-framing: Use outcome-framing to label gain and loss wording about an outcome, not the affect of a musical description.