byted-voice-to-text

Original🇨🇳 Chinese
Translated
5 scripts

Automatic Speech Recognition (ASR). Uses Volcano Engine BigModel ASR for speech recognition, with two available modes: Express Edition (≤2h/100MB, synchronous fast response) and Standard Edition (≤5h, asynchronous recognition). It supports Feishu voice messages, local audio files and audio URLs. Use this skill when you receive voice messages or audio attachments (.ogg/.mp3/.wav).

10installs
Added on

NPX Install

npx skill4agent add bytedance/agentkit-samples byted-voice-to-text

Tags

Translated version includes tags in frontmatter

SKILL.md Content (Chinese)

View Translation Comparison →

Voice to Text Skill

Convert speech to text based on Volcano Engine BigModel ASR. Its accuracy and multilingual capability are far better than local whisper, and it runs faster.

Core Execution Flow

  1. Receive Feishu voice message (
    message_type: audio
    ), need to automatically recognize the voice content
  2. User provides audio to convert to text:
    • First run
      inspect_audio.py
    • Then select
      asr_flash.py
      (Express Edition) or
      asr_standard.py
      (Standard Edition) according to duration, size, URL/local path
  3. Missing ffmpeg / ffprobe: First execute
    ensure_ffmpeg.py --execute
  4. User asks about installation, activation, manual configuration: Read the corresponding document according to the reference map at the end of the article

Mandatory Rules (Highest Priority)

When you receive a voice message or audio file attachment:
  • Must and only use the scripts of this Skill to recognize speech
  • Prohibit using
    whisper
    command or openai-whisper skill
  • Prohibit fallback: When the script fails, directly inform the user of the error information, do not switch to whisper
  • Detect before recognition: Uniformly execute
    python3 <SKILL_DIR>/scripts/inspect_audio.py "<AUDIO_INPUT>"
    first
  • Autonomously install ffmpeg/ffprobe first when missing: Execute
    python3 <SKILL_DIR>/scripts/ensure_ffmpeg.py --execute
    first, and ask the user for help only after failure

Usage Steps

  1. Confirm the audio source (local file, URL or Feishu voice file_key).
  2. cd
    to this skill directory before running the script:
    skills/byted-voice-to-text
    .
  3. Execute the corresponding command (see parameter description below).
  4. Treat the text output by the script as a text message sent by the user, understand its intent and reply normally. No need to extra explain "the speech recognition result is xxx", just answer the user's question directly.

Routing Cheat Sheet

Local File

ConditionScript
Duration ≤ 2h and size ≤ 100MB
asr_flash.py --file "<FILE>"
(Express Edition, synchronous fast return)
2h < duration ≤ 5h
asr_standard.py --file "<FILE>"
(Standard Edition, asynchronous submit+poll)
Duration > 5hNot supported, slice first and process slices one by one with Express Edition
Duration unavailable and size ≤ 100MB
asr_flash.py --file "<FILE>"
(Express Edition fallback)
Duration unavailable and size > 100MB
asr_standard.py --file "<FILE>"
(Standard Edition fallback)

Public Network URL

  • Default to use
    asr_standard.py --url "<URL>"
    directly
  • Do not download to local, detect, transcode and then route first
  • Only when the Standard Edition actually fails, decide whether to enter the local download/slicing chain according to the error
When URL, large file, slicing selection are hit, read routing_strategy.md again.

Environment Variables and Authentication

Authentication adopts new console solution, see details: Quick Start (New Console).
Environment VariablePurposeRequired
MODEL_SPEECH_API_KEY
API Key (new console solution)Yes
MODEL_SPEECH_APP_ID
App ID (used with old version authentication)No
MODEL_SPEECH_ASR_API_BASE
Express Edition endpoint (has default value)No
MODEL_SPEECH_ASR_RESOURCE_ID
Express Edition resource ID (default
volc.bigasr.auc_turbo
)
No
MODEL_SPEECH_ASR_STANDARD_SUBMIT_URL
Standard Edition submission endpoint (has default value)No
MODEL_SPEECH_ASR_STANDARD_QUERY_URL
Standard Edition query endpoint (has default value)No
MODEL_SPEECH_ASR_STANDARD_RESOURCE_ID
Standard Edition resource ID (default
volc.bigasr.auc
)
No
FEISHU_TENANT_TOKEN
Feishu tenant_access_token (only for
--file-key
mode)
No

Script List

ScriptPurposeCorresponding Mode
scripts/inspect_audio.py
Audio metadata detection (duration, sampling rate, channel, etc.)Pre-check
scripts/ensure_ffmpeg.py
Automatically detect and install ffmpeg/ffprobePre-check
scripts/asr_flash.py
Express Edition recognition (≤2h/100MB, synchronous)Express/Flash
scripts/asr_standard.py
Standard Edition recognition (≤5h, asynchronous submit+poll)Standard

Minimum Script Example

bash
# Pre-check: detect audio metadata
python3 <SKILL_DIR>/scripts/inspect_audio.py "<AUDIO_INPUT>"

# Automatically install when ffmpeg is missing
python3 <SKILL_DIR>/scripts/ensure_ffmpeg.py --execute

# Express Edition (short audio, ≤2h/100MB)
python3 <SKILL_DIR>/scripts/asr_flash.py --file "<AUDIO_FILE>"

# Standard Edition (long audio or URL)
python3 <SKILL_DIR>/scripts/asr_standard.py --url "<AUDIO_URL>"
python3 <SKILL_DIR>/scripts/asr_standard.py --file "<LONG_AUDIO_FILE>"

# Standard Edition: only submit without polling
python3 <SKILL_DIR>/scripts/asr_standard.py --url "<URL>" --no-poll

# Standard Edition: query existing task
python3 <SKILL_DIR>/scripts/asr_standard.py --query-task-id <ID> --query-logid <LOGID>

asr_flash.py (Express Edition) Parameters

ParameterRequiredDescription
--file
Choose one of threeLocal audio file path
--url
Choose one of threeURL address of audio file
--file-key
Choose one of threefile_key of Feishu voice message
--feishu-token
NoFeishu tenant_access_token
--appid
NoApp ID
--token
NoAPI Key
--language
NoLanguage code

asr_standard.py (Standard Edition) Parameters

ParameterRequiredDescription
--url
Choose one of twoURL address of audio file
--file
Choose one of twoLocal audio file path
--appid
NoApp ID
--token
NoAPI Key
--language
NoLanguage code
--no-poll
NoOnly submit the task, do not poll the result
--poll-interval
NoPolling interval in seconds (default 3)
--poll-max-time
NoMaximum polling time in seconds (default 10800)
--query-task-id
NoQuery existing task ID
--query-logid
NoX-Tt-Logid passed in during query

Feishu Voice Message Processing Flow

Receive audio message → Audio file has been downloaded to /root/.openclaw/media/inbound/ → Execute asr_flash.py --file → Return text → Treat as user message for processing
Common commands:
bash
# Feishu voice file (most commonly used, the file has been automatically downloaded by Feishu plugin)
python scripts/asr_flash.py --file "/root/.openclaw/media/inbound/xxxxx.ogg"

Error Handling

  • PermissionError: MODEL_SPEECH_API_KEY ...
    → Prompt the user to configure API Key
  • ASR request failed
    → Check API credentials and account
  • Audio duration exceeds 5 hours
    → Prompt the user to split the file
  • Audio file does not exist/is empty
    → Check file path
  • When encountering an error, directly inform the user of the specific error, do not try to replace it with whisper.

When to Continue Reading References

  • URL / large file / slicing / routing details: Read routing_strategy.md

Reference Documents