Skip to main content
In this case, you’ll use a sound recording of President John F. Kennedy’s 1961 State of the Union address. This guide performs the following tasks:
  1. Prompt Gemini to generate a transcript of the audio recording.
  2. Trace Gemini API calls and send the traces to the Arize AX platform with links to audio file for playback.
  3. Evaluate the transcription output from Gemini for sentiment analysis using Phoenix Evals and Gemini LLM (LLM as a Judge).

Install dependencies

Set your credentials

Copy your Space ID and API key from your Arize AX Space Settings page, and set them alongside your Gemini API key. If you don’t have a Gemini key yet, create one in Google AI Studio.
GOOGLE_CLOUD_PROJECT is used later by the Gemini judge, which reaches the model through Vertex AI rather than the Gemini API.

Load an audio file sample and set the URL

Download the recording locally. The URL is also passed to Arize AX later so you can play the audio back next to the trace.

Tracing setup

You’ll need to set Arize AX variables (Space id, API key and Developer Key) below to send traces to the Arize AX Platform. Sign up for free here.

Configure prompt

Call Gemini

Evaluate Gemini’s output transcript for sentiment analysis

First, export spans from Arize AX that contain transcript output from Arize AX

Evaluation Template

Evaluate transcriptions using Gemini as a LLM as a Judge

GeminiModel reaches Gemini through Vertex AI, so it needs Google Cloud credentials and a project. Run these once, using a project that has the Vertex AI API enabled.

Send evaluations to Arize AX

Next Steps

Useful API references:

More details about Gemini API’s vision capabilities in the documentation. If you want to know about the File API, check its API reference or the File API quickstart. Check this example using the audio files to give you more ideas on what the gemini API can do with them:
  • Share Voice memos with Gemini API and brainstorm ideas

Continue your discovery of the Gemini API

Have a look at the Audio quickstart to learn about another type of media file, then learn more about prompting with media files in the docs, including the supported formats and maximum length for audio files. .