Audio Sentiment Analysis

Give a sentiment analysis of this audio conversation. Use speaker A, speaker B to identify speakers.

Audio Sentiment Analysis.

1"""
2Audio Sentiment Analysis
3=============================
4
5Audio Sentiment Analysis.
6"""
7
8import requests
9from kern.agent import Agent
10from kern.db.sqlite import SqliteDb
11from kern.media import Audio
12from kern.models.google import Gemini
13
14# ---------------------------------------------------------------------------
15# Create Agent
16# ---------------------------------------------------------------------------
17agent = Agent(
18 model=Gemini(id="gemini-3-flash-preview"),
19 add_history_to_context=True,
20 markdown=True,
21 db=SqliteDb(
22 session_table="audio_sentiment_analysis_sessions",
23 db_file="tmp/audio_sentiment_analysis.db",
24 ),
25)
26
27url = "https://kern-public.s3.amazonaws.com/demo_data/sample_conversation.wav"
28
29response = requests.get(url)
30audio_content = response.content
31
32# ---------------------------------------------------------------------------
33# Run Agent
34# ---------------------------------------------------------------------------
35if __name__ == "__main__":
36 # Give a sentiment analysis of this audio conversation. Use speaker A, speaker B to identify speakers.
37 agent.print_response(
38 "Give a sentiment analysis of this audio conversation. Use speaker A, speaker B to identify speakers.",
39 audio=[Audio(content=audio_content)],
40 stream=True,
41 )
42
43 agent.print_response(
44 "What else can you tell me about this audio conversation?",
45 stream=True,
46 )

Run the Example

1# Clone and setup repo
2git clone https://github.com/kern-ai/kern.git
3cd kern/cookbook/02_agents/12_multimodal
4
5# Create and activate virtual environment
6./scripts/demo_setup.sh
7source .venvs/demo/bin/activate
8
9python audio_sentiment_analysis.py