transcribe rejects public YouTube URLs even though the Gemini API supports them

未关闭
#176 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
api, cli

调研方向

Start with internal/cli/custom/media.go for input policy and URL classification, then internal/cli/custom/transcribe.go for model routing, prompts, and artifact rendering. Review the existing transcription behavior and related issue #144 before tracing how video inputs and output formats are handled. Done means public YouTube URLs work across the requested formats, existing audio behavior remains intact, and the listed regression cases and help documentation are covered.

由索引模型根据 Issue 内容生成。

描述

Problem

I expected gemini-api transcribe to accept a public YouTube URL and transcribe the video's spoken audio directly. Instead, the CLI rejects the URL before making an API request and recommends downloading or uploading the media.

This is a CLI restriction, not a missing Gemini API capability. analyze -i <YouTube URL> and agent run -i <YouTube URL> already support passing the URL as a video input. The command users would naturally look for, transcribe, does not.

The CLI should make supported Gemini Developer API capabilities easy to discover and use. Direct YouTube transcription should be a first-class workflow.

Reproduction

Tested with installed gemini-api 0.4.2 and source at 3a9106d94e0522d0b5d9003b5b1c3d262e7d4692 on macOS.

gemini-api transcribe \
  -i 'https://www.youtube.com/watch?v=rRJ7Jhun12I' \
  --dry-run

The CLI exits with code 2:

YouTube URLs are not supported by transcribe
Download the media locally or upload it with "gemini-api files upload <path>"

Expected: accept the URL as a video input, generate a complete transcript, and support the existing Markdown, text, JSON, and SRT output formats without requiring a local download or Files API upload.

Official API support

The Gemini API video-understanding guide documents direct public YouTube inputs. With the currently supported v1beta content-array shape, the relevant input is:

{
  "type": "video",
  "uri": "https://www.youtube.com/watch?v=rRJ7Jhun12I"
}

This uses the Gemini Developer API at generativelanguage.googleapis.com, not Vertex AI. The guide documents public-video support and describes the feature as preview.

Live validation

I tested NASA's approximately five-minute Webb Spies Rain Clouds, New Molecule on Titan, using NASA's published reference captions for comparison. The video and reference are linked from NASA's source page.

  • gemini-3.8-flash transcribed the URL directly, including the final spoken sentence, without downloading or uploading the video.
  • One schema-constrained JSON run returned 39 segments and 725 normalized spoken-word tokens versus 723 in the reference.
  • Word error rate was 1.24%: 9 word-level insertions, deletions, or substitutions divided by 723 reference words, after lowercasing, splitting into alphanumeric tokens, and excluding caption sound-effect labels.
  • All 78 aligned segment start/end boundaries fell within, or at most 1.367 seconds outside, the NASA caption cue containing the corresponding boundary word. This is a comparison with caption intervals, not a claim of word-level timing precision.
  • A local prototype produced timestamped Markdown and valid SRT directly from the URL.

There is also a formatting trap: repeated free-form requests returned the transcript but omitted timestamps even though the prompt explicitly requested them. Merely allowing the URL and adding a transcription prompt is not sufficient to honor the command's default timestamp behavior.

Recommended implementation

  1. Remove the YouTube-specific rejection from transcription input validation. Reuse the existing URL classification and URI-backed video content handling used by analyze. Do not add a downloader or require an upload.
  2. Route by content type, not only MIME type. Keep gemini-3.5-transcribe for audio. Route YouTube/video inputs to the video-capable default, currently gemini-3.8-flash, unless a compatible model is explicitly selected. A YouTube video block has no required MIME type, so the current MIME-only fallback will miss it. Inspect the video content block itself; do not invent a MIME type to trigger routing.
  3. Handle explicit audio-only models clearly. If a user explicitly selects gemini-3.5-transcribe for a YouTube URL, explain that it accepts audio only and suggest omitting --model or choosing a video-capable model.
  4. Request structured transcript segments for every YouTube output format. Require content, plus speaker and start_time/end_time when requested. Render Markdown, text, JSON, and SRT locally from those segments. This prevents a successful-looking Markdown file from silently dropping timestamps. Preserve --no-speakers and --no-timestamps behavior; SRT still requires timing.
  5. Ask for complete, verbatim speech. Explicitly prohibit summaries, paraphrases, omitted sections, and added visual descriptions; mark unclear words rather than inventing them. Preserve existing non-success/incomplete response handling.
  6. Make the capability visible. Mention public YouTube URLs in the root command description, transcribe --help, --input description, machine-readable usage, and README. Add runnable Markdown and SRT examples. Explain automatic model selection and that video speaker labels/timestamps are model-generated estimates.
  7. Preserve the existing output contract. Continue writing artifacts, printing their paths by default, reporting the effective model per input in machine output, and sending store: false.

Relevant implementation:

Related: #144 covers the dedicated audio transcription model. Its audio behavior should be preserved while adding direct YouTube support.

Regression coverage

  • Watch URLs, short youtu.be URLs, and supported mobile/Shorts forms are sent as video URIs.
  • Default model selection works even when the URI has no MIME type; explicit compatible models remain honored.
  • Explicit audio-only models fail before an interaction is sent.
  • All four artifact formats preserve requested fields; missing requested timestamps fail without writing an incomplete artifact.
  • --dry-run previews the correct request without network calls or file writes.
  • Existing local-file/uploaded-file transcription and mixed-input behavior keep working.
  • Help and README make the direct URL workflow discoverable.

Current workaround

gemini-api analyze \
  -i 'https://www.youtube.com/watch?v=rRJ7Jhun12I' \
  --api-version v1beta \
  'Transcribe all spoken audio verbatim from beginning to end. Do not summarize, paraphrase, omit sections, or add visual descriptions.' \
  > episode.txt

This produces text, but free-form output does not reliably honor timestamp requests. The separate version-compatibility regression is tracked in #177; --api-version v1beta is intentional here.

主要语言
Go
星标
514
派生
84
平均合并
1 天 15 小时
30 天内合并 PR
69

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

google-gemini/gemini-api-cli 的其他 Issue

查看 google-gemini/gemini-api-cli 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。