How does a voice agent match its tone and emotion to the user?
- Authors
- Name
- Amit Shekhar
- Published on
A voice agent matches its tone and emotion to the user by first listening to how the user feels, from both their words and their voice, then choosing a fitting way to reply, and finally telling the text-to-speech engine to speak that reply with the right speed, pitch, and warmth.
In this blog, we will learn about how a voice agent matches its tone and emotion to the user. We will also see why matching does not mean copying, how the agent detects emotion from the words and the voice, how it decides the tone of its reply, how it speaks that reply with the right feeling, how it keeps the tone steady across a call, and where it works well and where it fails.
We will cover the following:
- What do tone and emotion mean in a voice?
- Why a voice agent must match the tone of the user
- Matching does not mean copying
- Where emotion fits in a voice agent
- Step 1: Detecting the emotion from the words
- Step 2: Detecting the emotion from the voice
- Step 3: Combining both signals
- Step 4: Deciding the tone of the reply
- Step 5: Choosing the right words
- Step 6: Speaking with the right tone
- Speech-to-speech models
- Keeping the tone steady across the call
- Where it works well and where it fails
I am Amit Shekhar, Founder @ Outcome School, I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.
I teach AI and Machine Learning at Outcome School.
Let's get started.
What do tone and emotion mean in a voice?
Tone is the way something is said, and emotion is the feeling behind it.
The same sentence can carry very different feelings. Let's say a person says "Okay, fine." It can be said in a happy way, in a tired way, or in an angry way. The words are the same, but the meaning is not.
When we speak, our feeling shows up in a few things:
- Pitch: how high or low the voice is.
- Speed: how fast or slow we talk.
- Loudness: how loud or soft we are.
- Pauses: where we stop and for how long.
- Words: the actual words we pick, like "This is the third time I am calling."
The pitch, speed, loudness, and pauses together are called prosody. It is everything about the voice other than the words themselves.
Why a voice agent must match the tone of the user
Let's say a user calls a bank because money was taken from their account by mistake. They are worried and a little angry. They say:
"Someone took 500 dollars from my account and I did not do it."
Now, imagine the voice agent replies in a bright, cheerful, fast voice:
"Great. I can totally help you with that today."
The words are polite, but the tone is wrong. The user feels that the agent does not care.
Now, imagine the agent replies in a slower, calm, and caring voice:
"I am sorry to hear that. Let's sort this out together right now."
This time, the user feels heard.
On a phone call, the user cannot see a face or a smile. The voice is the only thing they have. Hence, tone matters even more in a voice agent than in a chat app.
Matching does not mean copying
Matching the tone of the user does not mean copying the emotion of the user. If the user is angry, the agent must not become angry. Instead, the agent must reply with the tone that fits the feeling of the user.
Let's see a few examples:
| User feels | Agent must sound |
|---|---|
| Angry | Calm, slow, and respectful |
| Worried | Gentle, reassuring, and clear |
| Confused | Patient and slow, with simple steps |
| Happy or excited | Warm and upbeat |
| In a hurry | Short, quick, and to the point |
| Sad | Soft, kind, and unhurried |
Here, we can see that sometimes the agent moves in the same direction as the user, like being upbeat with a happy user. And sometimes it moves in the opposite direction, like being calm with an angry user. The goal is always the same: help the user feel heard and move the conversation forward.
Where emotion fits in a voice agent
Before jumping into the steps, we must know how a typical voice agent works. It has three main parts:
- Speech-to-Text (STT): turns the voice of the user into text. It is also called ASR (Automatic Speech Recognition).
- LLM (Large Language Model): reads the text and writes a reply.
- Text-to-Speech (TTS): turns the reply text back into a voice.
The flow looks like below:
User speaks
↓
Speech-to-Text
↓
LLM writes the reply
↓
Text-to-Speech
↓
Agent speaks
When the voice of the user becomes plain text, most of the feeling is lost. The text "Okay, fine." does not tell us if the user was happy or angry. The pitch, speed, and loudness are gone.
So, to match the tone, the agent needs a few extra pieces: one that listens to the feeling in the voice, one that decides how the reply must feel, and one that tells the TTS how to speak with that feeling. Let's learn each step one by one.
Step 1: Detecting the emotion from the words
The first and simplest signal is the words themselves. Some words carry a clear feeling. "This is ridiculous" shows anger. "Thank you so much" shows happiness. "I do not understand" shows confusion.
The agent can find the feeling from the text in two common ways:
- A classifier model: a model trained to read a sentence and give a label like "angry", "happy", or "neutral". This is called emotion classification. A simpler version, called sentiment analysis, only says if the feeling is positive, negative, or neutral. Both are fast and cheap.
- The LLM itself: the LLM already reads every sentence, so we can ask it to also notice the feeling of the user.
The words also carry clues beyond single words. When the user repeats the same question, or says "I already told you that", it tells us that the user is getting frustrated, even if no angry word is used.
The problem: words alone can mislead. "Great, just great." looks happy as text, but it is often said in an angry way. This is where the voice comes into the picture.
Step 2: Detecting the emotion from the voice
The second signal is the sound of the voice. Finding the emotion from the sound of the voice is called Speech Emotion Recognition (SER).
A speech emotion model listens to the raw audio, not the text. It looks at things like:
- Pitch: an angry or excited voice often goes higher and changes more.
- Loudness: an angry voice is often louder.
- Speed: a stressed person often talks faster, and a sad person often talks slower.
- Pauses: long pauses can mean confusion or sadness.
The model is trained on many audio clips where humans have marked the emotion, so it learns which patterns of sound go with which feeling. It runs on the same audio that goes to the Speech-to-Text, at the same time.
The output is usually a label with a score, like below:
{ "emotion": "angry", "confidence": 0.78 }
Here, emotion is the feeling the model hears, and confidence is how sure the model is, from 0 to 1. Some systems give a score for each emotion, because real feelings are often mixed.
Planning your move into AI?
No matter which tech domain you work in today, with your effort, you can transition to these roles:
- AI Engineer
- Forward Deployed Engineer
- AI Agent Engineer
- Harness Engineer
- Voice AI Engineer
- AI Architect
- LLM Engineer
- LLM Inference Engineer
- Gen AI Engineer
- MLOps Engineer
- ML Engineer
- Deep Learning Engineer
Our AI and Machine Learning Program at Outcome School takes you there.
Step 3: Combining both signals
Now, we have two signals: one from the words and one from the voice. Each one can be wrong on its own, but together they give a better picture.
Let's go back to the example "Great, just great."
- From the words: happy.
- From the voice: loud, sharp, and fast, so angry.
In this case, the voice is the better guide, because the tone of the voice shows the sarcasm that the words hide. So, the agent must decide that the user is angry.
A simple way to combine them is to give each signal a weight and add the scores. Let's see the code for the same:
def combine(text_scores, voice_scores, voice_weight=0.6):
text_weight = 1 - voice_weight
combined = {}
for emotion in text_scores:
combined[emotion] = (
text_weight * text_scores[emotion]
+ voice_weight * voice_scores[emotion]
)
# pick the emotion with the highest score
return max(combined, key=combined.get)
text_scores = {"happy": 0.7, "angry": 0.2, "neutral": 0.1}
voice_scores = {"happy": 0.1, "angry": 0.8, "neutral": 0.1}
print(combine(text_scores, voice_scores))
Here, we are giving the voice a weight of 0.6 and the words a weight of 0.4. Let's do the math for each emotion:
- happy: 0.4 * 0.7 + 0.6 * 0.1 = 0.28 + 0.06 = 0.34
- angry: 0.4 * 0.2 + 0.6 * 0.8 = 0.08 + 0.48 = 0.56
- neutral: 0.4 * 0.1 + 0.6 * 0.1 = 0.04 + 0.06 = 0.10
It will print the following:
angry
Here, we can see that even though the words looked happy, the combined result is angry.
Note: Some systems use one model that takes both the audio and the text together, instead of two separate signals.
A quick note for you
No matter which tech domain you work in, get familiar with these topics:
- LLM
- RAG
- MCP
- Agent
- Fine-tuning
- Quantization
We put it all together in one video:
AI Engineering Explained: LLM, RAG, MCP, Agent, Fine-Tuning, and Quantization
No need to stop reading - bookmark it and watch later when you get time. Future you will thank you.
Now, let's get back to the topic.
Step 4: Deciding the tone of the reply
Now, the agent knows how the user feels. The next big question is: how must the reply feel?
There are two common ways to decide this.
Way 1: Simple rules. We write a fixed mapping in our code, like the table we saw earlier. If the user is angry, use the "calm" style. If the user is confused, use the "patient" style. This is easy to build and easy to test.
Way 2: Let the LLM decide. We pass the detected emotion to the LLM along with the text of the user, and we tell it in the system prompt how to respond to each feeling. Let's see an example of the input that the LLM receives:
User said: "Great, just great. My order is late again."
Detected emotion: angry (confidence 0.78)
And the system prompt can have a rule like below:
If the user sounds angry or upset, first acknowledge the feeling
in one short sentence, then give the next step. Keep the reply
calm and short. Never sound cheerful.
Here, the LLM reads both the words and the detected emotion, and writes a reply with the right feeling. It can also return a style label for the voice, like "calm" or "warm", for the next step.
We can also use a mix of both: rules for the clear cases and the LLM for the rest.
To learn Prompt Engineering, Large Language Models (LLMs), and how to Design a Real-Time Voice AI Agent from the ground up, we can check out our AI and Machine Learning Program at Outcome School.
Step 5: Choosing the right words
Tone is not only about the voice. The words of the reply also carry the feeling.
Let's see how the same answer changes based on the feeling of the user:
- Neutral user: "Your order will arrive on Friday."
- Angry user: "I am really sorry about the delay. Your order will arrive on Friday."
- Confused user: "No problem. Your order is on the way, and it will arrive on Friday."
- User in a hurry: "Friday."
Here, we can notice that an upset user first needs to hear that their feeling is understood, a confused user needs simple words, and a user in a hurry needs the shortest answer.
One more thing to notice: long replies feel like the agent is not listening. So, the angrier the user, the shorter and clearer the reply must be.
Step 6: Speaking with the right tone
Now, the agent has the right words. The last step is to speak them with the right feeling, which is the job of the TTS engine. There are three common ways to control the tone of a TTS voice.
Way 1: Prosody controls with SSML. SSML (Speech Synthesis Markup Language) is a standard way to add tags to text that tell the TTS how to speak it. The prosody tag can change the speed, pitch, and volume. We can write it as below:
<speak>
<prosody rate="slow" pitch="low" volume="soft">
I am really sorry about the delay.
</prosody>
<break time="300ms"/>
Your order will arrive on Friday.
</speak>
Here, we have made the apology slower, lower, and softer, which sounds calm and caring. Then, we have added a pause of 300 milliseconds, so that the apology does not feel rushed.
Way 2: Style or emotion settings. Some TTS voices come with ready-made speaking styles, like "cheerful", "calm", "sad", or "empathetic". Our code picks the style that matches the decision from Step 4.
Way 3: Plain-language instructions. Some TTS models accept a short instruction along with the text, like "Speak in a calm, warm, and slow voice, like a caring support agent." The model then speaks the text in that way.
The flow with all the steps now looks like below:
User speaks
↓
Speech-to-Text + Speech Emotion Recognition
↓
Combine the emotion from the words and the voice
↓
LLM writes the reply and picks a style
↓
TTS speaks with that style
↓
Agent speaks with the right tone
Speech-to-speech models
So far, the agent had separate parts for STT, LLM, and TTS. Now, it's time to learn about a different way.
A speech-to-speech model takes the audio of the user directly as input and produces audio directly as output. There is no step in the middle where the voice becomes plain text.
Because the model hears the audio itself, it can learn to notice the pitch, speed, and loudness of the user. And because it creates the audio itself, it can speak back with a matching feeling, without separate SSML or style tags.
Advantage: the feeling of the user is not lost in the middle, and the reply can sound more natural.
Disadvantage: we have less direct control. With separate parts, we can see the detected emotion and the chosen style in our logs, and we can fix the rules. With a speech-to-speech model, it is harder to see why it chose a certain tone.
So, we must choose based on our use case. If we need control and clear logs, separate parts are better. If we need the most natural feel, a speech-to-speech model is a good choice. We have a detailed blog on Cascaded vs Speech-to-Speech that explains how to choose the right architecture step by step.
Stay updated: Subscribe to our newsletter to get our latest AI and Machine Learning blogs straight to your inbox.
Keeping the tone steady across the call
A call is not one sentence. It is many turns. The feeling of the user can change during the call.
Let's say the user is angry, then says one neutral sentence like "My order number is 4521." If the agent suddenly becomes cheerful, it feels like it forgot that the user was upset a moment ago.
So, the agent must not react only to the last sentence. It must look at the feeling over the last few turns. A simple way is to keep a running score:
- When the user sounds angry, the "upset" score goes up.
- When the user sounds calm, the score goes down slowly, not all at once.
For example, the upset score is 0.8 after an angry turn, then 0.6 after the next calm turn, then 0.4 after one more calm turn. The agent keeps a calm style while the score is above 0.5.
This way, the agent keeps the calm style for one more turn after the user calms down, like a caring human would.
The agent must also notice when the feeling gets worse. If the user keeps getting more upset, the agent can offer to connect them to a human. Handing the call to a human is called escalation.
Where it works well and where it fails
Where it works well:
- Customer support calls, where upset users need a calm voice.
- Healthcare calls, where users can be worried and need a gentle tone.
- Strong feelings, like loud anger or clear happiness, which are easy to detect.
Where it fails:
- Hidden feelings and sarcasm: a person can sound calm but be very upset inside, and "Oh, wonderful." is hard to read even for humans.
- Culture and language: the same tone can mean different things in different cultures. A loud voice is normal for some people and angry for others.
- Noisy calls: background noise and poor phone lines change the sound and confuse the emotion model.
- Wrong guesses: if the agent says "I can hear that you are upset" to a user who is not upset, it feels strange. So, the agent must act on emotion only when the confidence is high, and must avoid naming the feeling of the user too directly.
- Delay: every extra model adds a little time. In a voice call, even a small delay is noticed, so the emotion step must be fast.
Now we must have understood how a voice agent matches its tone and emotion to the user, how it detects the feeling, how it decides the tone of the reply, and how it speaks with that tone.
Frequently Asked Questions
Why does a voice agent lose the emotion of the user?
A voice agent loses most of the emotion when the voice of the user becomes plain text in the Speech-to-Text step. The pitch, speed, and loudness are gone, so the text "Okay, fine." does not tell us if the user was happy or angry. This is why the agent needs a separate signal that listens to the feeling in the voice.
What is the difference between emotion classification and sentiment analysis?
Emotion classification reads a sentence and gives a label like "angry", "happy", or "neutral". Sentiment analysis is a simpler version that only says if the feeling is positive, negative, or neutral. Both work on the text of the user, and both are fast and cheap, so a voice agent can run them on every turn.
Can a voice agent detect sarcasm?
Sometimes. Words alone can mislead, because "Great, just great." looks happy as text but is often said in an angry way. When the agent combines the words with the sound of the voice, the tone of the voice can show the sarcasm that the words hide. Still, sarcasm remains hard, and "Oh, wonderful." is hard to read even for humans.
Should a voice agent tell the user that it can hear they are upset?
Usually not. If the agent says "I can hear that you are upset" to a user who is not upset, it feels strange. So, the agent must act on emotion only when the confidence is high, and must avoid naming the feeling of the user too directly. It can show care through the right words and a calm voice instead.
Does emotion detection make a voice agent slower?
It can. Every extra model adds a little time, and in a voice call even a small delay is noticed, so the emotion step must be fast. The speech emotion model runs on the same audio that goes to the Speech-to-Text, at the same time, and the classifier models that read the text are fast and cheap.
That's it for now.
Thanks
Amit Shekhar
Founder @ Outcome School
You can connect with me on:
Follow Outcome School on:
