# 时间戳

简介 Afarensis Whisper API 引入了一个强大的功能，允许用户在音频转录中包含时间戳。这一功能通过timestamp\_granularities\[]参数实现，支持在输出中以 JSON 格式提供更详细的结构化数据。这对于需要在脚本和视频编辑中实现单词级精度的应用场景尤其有用，因为它允许根据单个单词关联的特定时间戳来编辑或删除音频帧。

时间戳选项 Afarensis Whisper API 提供的时间戳粒度包括：

单词（Word）：为每个单词提供时间戳，适合需要单词级精度的应用。 段落/句子（Segment）（可选）：为音频中的每个逻辑段落或句子提供时间戳，适合于宏观层面的编辑需求。 示例代码 带时间戳的转录输出 from afarensis import AfarensisAPI client = AfarensisAPI()

audio\_file = open("speech.mp3", "rb") transcript = client.audio.transcriptions.create( file=audio\_file, model="whisper-1", response\_format="verbose\_json", timestamp\_granularities=\["word"] )

print(transcript.words) 此代码示例展示了如何生成包含每个单词时间戳的转录输出。设置timestamp\_granularities参数为\["word"]，确保转录结果中包含对于编辑和处理非常有用的时间戳信息。

使用场景 叙述书面内容：将书面博客文章或文档转录为音频时，时间戳可以帮助同步文本与语音。 多语言音频内容：在创建多语言教育材料或媒体内容时，时间戳有助于确保准确的翻译对应和同步。 实时音频输出：在直播或实时流媒体中，时间戳可以用于生成实时字幕或注释。 注意事项 在上传音频文件时，请确保文件符合 API 支持的格式和大小限制。 考虑到输出数据的处理和存储方式，以便于后续编辑和使用。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.afarensis.com/yu-yin-zhuan-wen-ben/shi-jian-chuo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
