Audio Sentiment Analysis
Analyze sentiment and identify speakers in an audio conversation with Gemini, and persist the session history in SQLite.
Run sentiment analysis on an audio conversation with a multimodal agent.
import requests
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.media import Audio
from agno.models.google import Gemini
agent = Agent(
model=Gemini(id="gemini-3.5-flash"),
add_history_to_context=True,
markdown=True,
db=SqliteDb(
session_table="audio_sentiment_analysis_sessions",
db_file="tmp/audio_sentiment_analysis.db",
),
)
url = "https://agno-public.s3.amazonaws.com/demo_data/sample_conversation.wav"
response = requests.get(url)
response.raise_for_status()
audio_content = response.content
# Give a sentiment analysis of this audio conversation. Use speaker A, speaker B to identify speakers.
agent.print_response(
"Give a sentiment analysis of this audio conversation. Use speaker A, speaker B to identify speakers.",
audio=[Audio(content=audio_content, format="wav")],
stream=True,
)
agent.print_response(
"What else can you tell me about this audio conversation?",
stream=True,
)Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U google-genai sqlalchemy requests agnoExport your Google API key
export GOOGLE_API_KEY="your_google_api_key_here"Run Agent
python audio_sentiment_analysis.pyKey Features
- Audio Processing: Downloads and processes audio files from remote URLs
- Sentiment Analysis: Analyzes emotional tone and sentiment in conversations
- Speaker Identification: Distinguishes between different speakers in the conversation
- Persistent Sessions: Maintains conversation history using SQLite database
- Streaming Response: Real-time response generation for better user experience
Use Cases
- Customer service call analysis
- Meeting sentiment tracking
- Interview evaluation
- Call center quality monitoring