1import base64
2from pathlib import Path
3
4from kern.agent import Agent
5from kern.models.openai import OpenAIResponses
6from kern.tools.models.groq import GroqTools
7from kern.utils.media import save_base64_data
8
9path = "tmp/sample-fr.mp3"
10
11agent = Agent(
12 name="Groq Translation Agent",
13 model=OpenAIResponses(id="gpt-5.2"),
14 tools=[GroqTools()],
15 cache_session=True,
16)
17
18response = agent.run(
19 f"Let's transcribe the audio file located at '{path}' and translate it to English. After that generate a new music audio file using the translated text."
20)
21
22if response and response.audio:
23 base64_audio = base64.b64encode(response.audio[0].content).decode("utf-8")
24 save_base64_data(base64_audio, Path("tmp/sample-en.mp3")) # type: ignore