让语音输入像键盘操作一样直接。
audiov(Audio + V)是一个使用 Rust 编写的 Linux 全局语音输入守护进程,通过 fcitx5 addon 将识别结果直接提交到当前输入上下文。
- 本地离线识别:基于
whisper.cpp,支持在本机 CPU/GPU 上完成语音转写,数据不离开设备。 - 远端 Whisper 接口:支持通过配置切换到 Whisper 兼容的远端 API。
- fcitx5 直接注入:通过
fcitx5addon 的CommitTextDBus 方法,将文本直接提交给当前聚焦输入上下文。 - KDE 全局快捷键:通过
org.kde.KGlobalAccel注册全局快捷键,默认Meta+H单键切换录音。 - 手动录音模式:保留前台交互录音模式,便于调试与验证链路。
- Capture:监听 KDE 全局快捷键或手动触发,采集麦克风音频(PipeWire/PulseAudio/ALSA)。
- Inference:调用本地
whisper.cpp引擎或远端 HTTP API 完成语音转文本。 - Inject:通过
fcitx5addon DBus 接口将文本直接提交到当前输入上下文。
- Rust 工具链(
cargo) fcitx5(含 audiov addon,见contrib/fcitx5-audiov/)- KDE Plasma(全局快捷键模式)
./contrib/fcitx5-audiov/install-user.sh
./contrib/fcitx5-audiov/restart-fcitx5.sh验证 addon 已加载:
busctl --user introspect org.fcitx.Fcitx5 /org/freedesktop/Fcitx5/Audiovcargo build --release
# KDE 全局快捷键模式(默认)
./target/release/audiov --config ~/.config/audiov/config.toml
# 手动录音模式
./target/release/audiov --manual --config ~/.config/audiov/config.toml配置文件默认查找顺序:
AUDIOV_CONFIG环境变量;~/.config/audiov/config.toml(若存在);- 若均不存在则报错,需通过
--config显式指定。
# 创建 ~/.config/systemd/user/audiov.service
systemctl --user enable --now audiov.service
# 常用命令
systemctl --user status audiov
journalctl --user -fu audiov参见 config.example.toml,主要配置段:
[whisper]
backend = "cpp" # 或 "remote"
[whisper_cpp]
model = "models/ggml-large-v1.bin"
threads = 4
use_gpu = false
[whisper_remote]
enabled = false
endpoint = "https://api.openai.com/v1/audio/transcriptions"
model = "whisper-1"
api_key = ""
timeout_secs = 60[paste]
fcitx5_service = "org.fcitx.Fcitx5"
fcitx5_path = "/org/freedesktop/Fcitx5/Audiov"
fcitx5_interface = "org.fcitx.Fcitx5.Audiov1"[hotkey]
enabled = true
shortcut = "Meta+H"
component_unique = "audiov"
component_friendly = "audiov"
action_unique = "toggle-recording"
action_friendly = "Toggle Recording"第一次按下快捷键开始录音,再次按下停止并转写注入。
[language_detection]
enabled = false
mode = "per_session"
allowed_languages = ["zh", "en"]
confidence_threshold = 0.65
default_language = "zh"
use_detected_language_for_inference = false[recorder]
backend = "auto" # auto | pipewire | pulseaudio | alsa
# input_device = ""| 参数 | 说明 |
|---|---|
--config <path> |
指定配置文件路径 |
--manual |
前台手动模式,按 Enter 开始/停止录音 |
--transcribe-wav <path> |
直接转写 16kHz/mono/PCM16 WAV 文件 |