360 Secure SkillHub
360 安全技能中心

Gemini Voice Assistant

通过 Python 脚本调用 Gemini Live API 实现语音到语音对话。支持文本模式(传入消息)和语音模式(传入音频文件路径),返回包含文本回复与语音文件引用的 JSON。需配置 GEMINI_API_KEY,依赖 google-genai、numpy、soundfile、librosa 和 FFmpeg,默认使用 Gemini 原生音频模型。

alimostafaradwan
alimostafaradwan
热度 92.84
最近更新 2026-05-17 12:32:16
分类:自动化依赖:代码执行 / 第三方 API / 内部调用大模型 / 读写文件

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add gemini-voice-assistant
Metadata
name
gemini-voice-assistant
description
Voice-to-voice AI assistant using Gemini Live API. Speak to the AI and get spoken responses. Use when you want to have natural voice conversations with an AI assistant powered by Google's Gemini models.
metadata
{"openclaw":{"emoji":"🎙️"}}

Gemini Voice Assistant

A voice-to-voice AI assistant powered by Google's Gemini Live API. Speak to the AI and it responds with natural-sounding voice.

Usage

Text Mode

cd ~/.openclaw/agents/kashif/skills/gemini-assistant && python3 handler.py "Your question or message"

Voice Mode

cd ~/.openclaw/agents/kashif/skills/gemini-assistant && python3 handler.py --audio /path/to/audio.ogg "optional context"

Response Format

The handler returns a JSON response:

{
  "message": "[[audio_as_voice]]\nMEDIA:/tmp/gemini_voice_xxx.ogg",
  "text": "Text response from Gemini"
}

Configuration

Set your Gemini API key:

export GEMINI_API_KEY="your-api-key-here"

Or create a .env file in the skill directory:

GEMINI_API_KEY=your-api-key-here

Model Options

The default model is gemini-2.5-flash-native-audio-preview-12-2025 for audio support.

To use a different model, edit handler.py:

MODEL = "gemini-2.0-flash-exp"  # For text-only

Requirements

  • google-genai>=1.0.0
  • numpy>=1.24.0
  • soundfile>=0.12.0
  • librosa>=0.10.0 (for audio input)
  • FFmpeg (for audio conversion)

Features

  • 🎙️ Voice input/output support
  • 💬 Text conversations
  • 🔧 Configurable system instructions
  • ⚡ Fast responses with Gemini Flash