技能图谱SKILLSGROVE
技能图谱/效率工具/JAICHANGPARK/flutter_gemini_live/gemini-live-translate

gemini-live-translate

安装

$npx skills add https://github.com/JAICHANGPARK/flutter_gemini_live --skill gemini-live-translate
$git clone --depth 1 https://github.com/JAICHANGPARK/flutter_gemini_live.git /tmp/flutter_gemini_live && mkdir -p ~/.claude/skills && cp -r /tmp/flutter_gemini_live/.hermes/skills/gemini-live-translate ~/.claude/skills/gemini-live-translate
请帮我安装这个 Agent Skill:https://github.com/JAICHANGPARK/flutter_gemini_live/tree/8e51a205f69168cc37834c8b0193c83a9f270f5c/.hermes/skills/gemini-live-translate ,先阅读它的 SKILL.md 和脚本,确认安全后再安装到我的技能目录。

简介

原文描述 · BSD-3-ClauseImplement real-time, bidirectional speech-to-speech translation in Flutter using the Gemini Live Translate model. Use when connecting to gemini-3.5-live-translate-preview, configuring TranslationConfig (targetLanguageCode, echoTargetLanguage), or building dual-sided/split-screen interpreter UI applications.
以下 SKILL.md 内容转载自 JAICHANGPARK/flutter_gemini_live(提交 8e51a20),依据 BSD-3-Clause 许可证转载正文(文字未改动;仅省略文件头元数据、将图片显示为链接,超长内容会截断);版权归 2025, Dreamwalker 所有。许可证:LICENSE。仅展示说明文件,附带脚本请在原仓库查看。

Gemini Live Speech-to-Speech Translation Skill

This skill provides instructions for building real-time, low-latency live speech translation applications using Google's dedicated Live Translate model (gemini-3.5-live-translate-preview).


🌐 Model & Translation Configuration

The Live translation model operates as a streaming audio-in, audio-out interpreter:

Parameter Recommended Value Notes
Model ID gemini-3.5-live-translate-preview (LiveModels.gemini35LiveTranslatePreview) Dedicated streaming translation model.
targetLanguageCode BCP-47 tag (e.g., 'es', 'ja', 'ko', 'fr') Language to translate the speaker's voice into.
echoTargetLanguage false (default) If true, repeats the spoken target text before playing translation.
Response Modalities [Modality.AUDIO] Audio output containing the translated voice.

🚀 Setting Up Live Translation Session

import 'package:flutter/material.dart';
import 'package:gemini_live/gemini_live.dart';

Future<void> connectTranslator({
  required GeminiLiveSessionController controller,
  required String targetLanguage, // e.g. 'es' (Spanish), 'ko' (Korean)
  GeminiLiveVoice voice = GeminiLiveVoice.puck,
}) async {
  await controller.connect(
    LiveConnectParameters(
      model: LiveModels.gemini35LiveTranslatePreview,
      config: GenerationConfig(
        responseModalities: [Modality.AUDIO],
        speechConfig: SpeechConfig.fromLiveVoice(voice),
        // Live speech-to-speech translation settings
        translationConfig: TranslationConfig(
          targetLanguageCode: targetLanguage,
          echoTargetLanguage: false,
        ),
      ),
      // Transcribe both user speech and translated model speech
      inputAudioTranscription: AudioTranscriptionConfig(),
      outputAudioTranscription: AudioTranscriptionConfig(),
      callbacks: LiveCallbacks(
        onError: (e, st) => debugPrint('Translation Error: $e'),
      ),
    ),
  );
}

📱 Face-to-Face Dual-Sided UI Pattern

For in-person conversations where two people sit across from each other, render a split screen where the top half is flipped 180 degrees for the counterparty:

Widget buildSplitScreenInterpreter(BuildContext context, GeminiLiveSessionController controller) {
  return Column(
    children: [
      // 1. Counterparty Screen (Rotated 180 degrees)
      Expanded(
        child: RotatedBox(
          quarterTurns: 2, // 180 degree flip for person sitting opposite
          child: Container(
            color: Colors.blueGrey.shade900,
            padding: const EdgeInsets.all(20),
            child: Center(
              child: Text(
                controller.lastModelText ?? 'Listening for counterparty...',
                style: const TextStyle(fontSize: 22, color: Colors.white),
                textAlign: TextAlign.center,
              ),
            ),
          ),
        ),
      ),

      const Divider(height: 2, thickness: 2, color: Colors.amber),

      // 2. User Screen (Normal Orientation)
      Expanded(
        child: Container(
          color: Colors.grey.shade900,
          padding: const EdgeInsets.all(20),
          child: Center(
            child: Text(
              controller.lastUserText ?? 'Speak to translate...',
              style: const TextStyle(fontSize: 22, color: Colors.white),
              textAlign: TextAlign.center,
            ),
          ),
        ),
      ),
    ],
  );
}

🚨 Critical Translation Rules

  1. Always use the dedicated Translate model: Do not use standard gemini-3.8-live with a translation prompt if gemini-3.5-live-translate-preview is available. The dedicated translate model has specialized low-latency streaming pipeline optimizations.
  2. Handle target language switches dynamically: When users switch conversational directions (e.g. English -> Korean to Korean -> English), reconnect with the updated targetLanguageCode.
查看许可证全文(BSD-3-Clause)
BSD 3-Clause License

Copyright (c) 2025, Dreamwalker

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.