Preface¶
The core design of DeepSeek Harness (DSH) is “everything is a plugin”. When developing agents that need to understand voice, parsing input formats is often the first hurdle. Voice files sent by QQ and WeChat typically carry a #!SILK_V3 header, and the filenames are often incorrectly labeled as .amr. ffmpeg in most environments lacks the SILK decoder, making them impossible to process.
dsh-voice-transcribe is a local voice/video transcription plugin maintained by JackZo400. It converts QQ/WeChat voice messages into text using a SILK decoder and the SenseVoice engine (based on the sherpa-onnx int8 model). The entire process runs locally without consuming any API costs.
Core Features¶
- SILK Audio Decoding: Handles the SILK encoding format specific to QQ/WeChat.
- SenseVoice Local Transcription: Uses the int8-precision SenseVoice model for high-accuracy recognition.
- No API Costs: Full-process local inference.
- Batch Processing: Supports passing multiple files at once, with the model loaded once and reused.
- Proper Noun Correction: Fixes recognition errors via a configuration table.
Installation and Enablement¶
1. Install the Plugin¶
Run the following command in the DSH environment to install:
dsh plugin --profile web add github:JackZo400/dsh-voice-transcribe
2. Install Python Dependencies¶
Install the Python dependency packages (must be installed in the interpreter specified by pythonPath):
pip install -r py/requirements.txt
Note: The Tsinghua mirror typically lacks sherpa-onnx. If installation fails, use the Alibaba mirror or the official source:
pip install -i https://mirrors.aliyun.com/pypi/simple -r py/requirements.txt
3. System Dependencies¶
The system requires ffmpeg to be installed for handling audio/video transcoding of non-SILK formats.
4. Download the Model¶
Download the SenseVoice model (approximately 163 MB compressed, approximately 239 MB for the uncompressed int8 model):
curl -LO https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2024-07-17.tar.bz2
tar xjf sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2024-07-17.tar.bz2
The extracted directory (e.g., sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2024-07-17) is the model directory, whose path needs to be specified in the configuration.
Configuration¶
Add the following content to the DSH configuration file:
- insert:
- id: voice-transcribe
name: dsh-voice-transcribe
config:
pythonPath: python3 # Your Python interpreter path
modelDir: /path/to/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2024-07-17
maxSeconds: 120 # Only transcribe the first N seconds
language: auto # auto / zh / en / ja / ko / yue
fix: '' # Proper noun correction table
maxFiles: 4 # Maximum number of files to transcribe at once
Configuration Notes:
* modelDir: Can also be set via the environment variable AILIN_ASR_SV_DIR. The code does not contain hardcoded paths; it must be explicitly configured.
* fix: Proper noun correction table. The format is wrong=correct,wrong=correct, performing replacements from left to right. Defaults to empty.
Usage¶
Calling from DSH¶
After installation, the Agent gains the transcribe_media tool. You can pass a single or multiple file paths:
// JavaScript example
const svc = ctx.get('voiceTranscribe');
const { results } = await svc.transcribe(['/tmp/voice.amr']);
// Returns results containing file, ok, text, language, duration
Using the Python Script Standalone¶
If you need to debug separately, you can directly use the Python script provided by the plugin.
- SILK Decoding:
python py/silk.py voice.amr --out-dir out/
The output is a standard 16k mono WAV file.
- SenseVoice Transcription:
python py/transcribe.py zh.wav --language zh --model-dir /path/to/model
The output is in JSON format.
Performance Data (Measured)¶
- Model Size: 239 MB (int8).
- Single Item Time: Approximately 0.1 seconds (1.7-second voice sample).
- Loading Time: Approximately 0.9 seconds (loaded only once).
Known Limitations¶
- File Source: Only supports local files, not URLs (to avoid SSRF risks).
- Video Processing: Only transcribes the audio track, does not extract frames.
- Language Limitations: Only supports 5 languages (zh/en/ja/ko/yue).
- Long Audio: Audio exceeding 28 seconds is automatically segmented; the cut point may occasionally interrupt words.
- Hallucination Risk: Pure silence or pure music may generate meaningless characters.
- Noun Correction: SenseVoice does not have a vocabulary interface; proper noun correction relies on the
fixconfiguration table.
Conclusion¶
dsh-voice-transcribe is designed specifically to solve voice parsing problems in IM scenarios. If you are developing agents based on DeepSeek Harness and need to process QQ or WeChat voice messages, this is a solution that requires no API calls and runs entirely locally.