metadata-generation
bởi google-gemini
Tạo siêu dữ liệu chương trình (JSON) bao gồm bản ghi chép có mã thời gian, tiêu đề, thời lượng, tóm tắt và ngày tháng bằng cách gửi âm thanh và bản ghi chép đến Gemini.
npx skills add https://github.com/google-gemini/gemini-managed-agents-templates --skill metadata-generationMetadata Generation
Generate a structured JSON file containing metadata for the radio show. This is done by sending the final mixed audio file and the original transcript back to Gemini.
Prerequisites
pip install google-genai
Workflow
- Read Inputs: Load the transcript from
./workspace/data/script.mdand the final audio from./workspace/audio/final/ai_radio.mp3. - Upload Audio: Upload the audio file to the Gemini Files API.
- Generate Metadata: Call Gemini (e.g.,
gemini-3-flash-preview) using the Interactions API, passing the uploaded audio file and the transcript. - Save Output: Save the resulting JSON to
./workspace/data/show_notes.json.
Python Code
The skill is implemented in scripts/generate_metadata.py.
# Example usage
python3 skills/metadata-generation/scripts/generate_metadata.py --workspace ./workspace
Output
The skill produces a JSON file at ./workspace/data/show_notes.json with the following structure:
{
"show_title": "...",
"show_duration": "...",
"two_sentence_summary": "...",
"date_of_generation": "YYYY-MM-DD",
"timecoded_transcript": [
{
"timecode": "MM:SS",
"speaker": "...",
"text": "..."
},
...
]
}
Error Handling
- If the audio file is missing, the script will fail.
- If the transcript is missing, it will fail.
- If the Gemini API call fails, it will report the error and exit.