Skip to main content

ShuoType

ShuoType(说字输入)

在 GNOME / Wayland 桌面用语音代替键盘输入,支持两种识别模式:

  • 一句话识别:全局热键录音,松开后由阿里云识别,可选 DeepSeek 去语气词/润色,结果自动粘贴到当前窗口
  • 流式识别:长按热键 1 秒开始/停止,边说边识别,中间结果实时输入当前窗口(不支持 DeepSeek 润色)

适用于 Claude Code CLI、终端、编辑器和浏览器。

快速使用

pip3 install shuotype
shuotype init    # 首次使用:按提示填写阿里云 AccessKey ID/Secret 与 AppKey
shuotype setup   # 安装开机自启动并启动 daemon

在任意窗口长按右 Ctrl 1 秒开始录音,说话,松开右 Ctrl 结束,识别结果会自动粘贴到当前焦点窗口。

如果读到警告 无法读取 /dev/input/event*,重新运行 shuotype setup 会自动把当前用户加入 input 组,按提示重启系统即可,详见安装与排障。

功能

一句话识别(默认)

  • 长按右 Ctrl 满 1 秒开始录音,松开结束
  • 松开后由阿里云一句话识别(16 kHz 单声道 PCM)
  • 可选 DeepSeek 去语气词/润色(polish_mode,默认关闭)
  • 识别结果自动粘贴到当前焦点窗口

流式识别

  • 长按右 Ctrl 满 1 秒开始,再长按满 1 秒结束(点按不触发,避免误按)
  • 边说边识别,中间结果实时输入当前焦点窗口,支持实时修正
  • 持续 10 秒无语音输入自动结束录音,避免忘记长按停止
  • 不支持 DeepSeek 润色,输入原始识别文本

两种模式通用

  • 热键可配置为修饰键或 F1–F12 组合(如 右Ctrl、左Alt+F9)
  • 单次录音上限 max_seconds(默认 60 秒)
  • 系统托盘图标:录音时闪烁、识别/润色时蓝色呼吸、出错时红色闪烁;菜单可开始/结束录音、退出
  • 录音/识别/润色/完成状态不再弹桌面通知,失败时仍会通知原因
  • daemon 日志同时写入文件并输出到标准输出
  • 识别/润色进行中再次触发热键会被忽略,不会打断状态机

依赖

  • Python 3.11+
  • 系统:portaudio、wl-clipboard、ydotool、libnotify(notify-send)
  • 托盘图标:libayatana-appindicator、python-gobject;GNOME 需启用 AppIndicator 扩展
  • 阿里云智能语音交互的 AccessKey ID/Secret 与项目 AppKey
  • 可选:DeepSeek API Key(仅开启润色时需要)

Arch Linux 安装系统依赖:

sudo pacman -S --needed portaudio wl-clipboard ydotool libnotify \
  libayatana-appindicator python-gobject gnome-shell-extension-appindicator

安装

pip3 install shuotype

安装完成后运行一次:

shuotype setup

会安装开机自启动、检查 /dev/input 权限、输出各项配置状态,并启动 daemon。正常输出类似:

配置文件: ~/.config/shuotype/config.json(已存在)
阿里云凭据: 已配置
识别模式: oneshot(一句话识别,长按开始、松开结束)
DeepSeek 润色: 未启用
开机自启动: 已创建 ~/.config/autostart/shuotype.desktop
全局热键权限: 正常(当前用户已在 input 组)
daemon: 已启动
全局热键: 右Ctrl(长按 1 秒开始,松开结束)

再次运行时,已配置的项会显示当前状态(如 开机自启动: 已存在,无需变更、daemon: 已在运行),缺少的配置会明确列出。

如果当前用户读不到 /dev/input/event*,shuotype setup 会自动执行:

正在将当前用户加入 input 组(读取全局热键需要):
  sudo usermod -aG input lyuqiang

需要输入 sudo 密码;拒绝或失败时会打印手动执行的命令。加入 input 组后需重启系统才能让当前登录会话获得权限,setup 会给出提示:

全局热键权限: 已将当前用户加入 input 组,重启系统后生效

如果用户已在 input 组但当前会话尚未生效,则提示:

全局热键权限: 当前用户已在 input 组,但当前登录会话尚未生效,请重启系统后生效

重启前 daemon 仍会启动,但无法监听全局热键;重启后热键即可生效。

如暂不重启,可先停止当前 daemon,再以 input 组身份临时启动:

shuotype quit && sleep 1 && newgrp input -c "nohup shuotype daemon >/dev/null 2>&1 &"

该方式只在当前会话有效;重启系统后,开机自启动的 daemon 会自动带上 input 组。

/dev/uinput 与 /dev/input 权限

ydotoold 需要访问 /dev/uinput,全局热键需要读取 /dev/input/event*,两者都依赖当前用户在 input 组:

  • shuotype setup 会自动把当前用户加入 input 组,并提示重启系统。
  • ydotool 软件包自带的 udev 规则 80-uinput.rules 已将 /dev/uinput 设为 root:input 0660,加入 input 组即可写入,无需额外 udev 规则。若系统上 /dev/uinput 权限不同,可自行添加 KERNEL=="uinput", GROUP="input", MODE="0660" 规则。

确认当前用户在 input 组:id | grep input(加入后需重启系统生效)。

配置

shuotype init

配置写入 ~/.config/shuotype/config.json(0600)。关键字段:

  • polish_mode:off(默认)/ fillers / polish
  • asr_mode:oneshot(默认,先录音再识别)/ streaming(边说边识别,实时输入中间结果);修改后需重启 daemon
  • hotkey:默认 右Ctrl(长按右 Ctrl 1 秒开始,松开结束)。支持:
    • 通用修饰键:Ctrl、Alt、Shift、Super(Windows/Meta 键),左右任意一侧均可
    • 指定左右:左Ctrl、右Ctrl、左Alt、右Alt、左Shift、右Shift、左Super、右Super
    • 功能键:F1–F12,可与修饰键组合,例如 F9、左Alt+F9
    • 不支持会产生字符的组合(如 Alt+/、Ctrl+V)
  • paste_keys:默认 ctrl+shift+v(终端);GUI 应用可改 ctrl+v
  • audio_device:默认 pulse,也可填设备名(如 "hw:1,0")或索引(如 2)
  • max_seconds:默认 60

deepseek_api_key 可由环境变量 DEEPSEEK_API_KEY 覆盖,默认留空。如果环境变量 DEEPSEEK_API_KEY 已设置,shuotype init 会把它写入配置文件(0600);默认值仍为空,polish_mode=off 时不会调用 DeepSeek。

阿里云凭据也可由环境变量提供,优先级高于配置文件:

  • SHUOTYPE_AK_ID → access_key_id
  • SHUOTYPE_AK_SECRET → access_key_secret
  • SHUOTYPE_APPKEY → app_key

适合通过 shell、密码管理器或 systemd 环境文件注入凭据,避免明文写入 config.json。shuotype init 会把这些变量作为输入默认值,接受后即写入配置文件;若三项均已通过环境变量提供,也可跳过 shuotype init,shuotype setup、shuotype check、shuotype test-asr 和 daemon 都会直接读取环境变量。

使用

shuotype setup   # 安装开机自启动并启动 daemon
# 在任意窗口长按右 Ctrl 1 秒开始录音,说话,松开右 Ctrl 结束
# 不足 1 秒松开不会录音;录音期间按其他键不会停止,松开热键才停止

修改 ~/.config/shuotype/config.json 后无需重启 daemon,下一次按热键时自动生效;hotkey 修改后数秒内自动重载,asr_mode 修改后需重启 daemon。

流式识别

将配置中的 asr_mode 改为 streaming,或临时用启动参数覆盖:

shuotype daemon --asr-mode streaming

流式模式下热键改为长按 1 秒切换:按住右 Ctrl 满 1 秒开始录音,随后可松手;结束时再按住满 1 秒。未满 1 秒松开不会触发,避免误按;说话期间也无需一直按住 Ctrl,避免实时替换文本时的退格被识别成 Ctrl+Backspace。

录音期间音频会实时发送到阿里云实时语音识别,中间结果直接输入当前焦点窗口;每句 SentenceEnd 后该句定稿,停止录音后补齐最终文本。文本按最长公共前缀增量更新,正常情况只追加新增的字词,不会整段重刷;只有识别结果修正时才替换变化的后缀。

  • 需要阿里云控制台为项目开通“实时语音识别”;启动失败会自动回退一句话识别并提示错误
  • 持续 10 秒无语音输入时自动结束录音,避免忘记长按热键停止
  • 录音期间切换焦点,退格/粘贴会作用到新窗口
  • 流式模式下 polish_mode 不生效,输入的是原始识别文本

其他命令:

shuotype check
shuotype test-asr sample.wav
shuotype test-polish "嗯那个就是说帮我看看这个函数"
shuotype status
shuotype quit   # 停止守护进程

排障

  • Permission denied 打开 /dev/uinput:确认当前用户在 input 组(运行 shuotype setup 会自动加入并提示重启系统)。
  • 热键无反应或无法读取 /dev/input/event*:运行 shuotype setup,会自动把当前用户加入 input 组并提示重启;也可手动执行 sudo usermod -aG input $USER 后重启系统。
  • 已加入 input 组但暂不想重启:先 shuotype quit,再执行 newgrp input -c "nohup shuotype daemon >/dev/null 2>&1 &" 临时启用热键(仅当前会话有效)。
  • 流式识别启动失败:查看日志中的“流式识别启动失败”,确认阿里云项目已开通实时语音识别;daemon 会自动回退一句话识别。
  • 听不到麦克风:pactl list short sources 查看默认输入;在配置里把 audio_device 改成设备名或索引。
  • 粘贴到 GUI 应用:把 paste_keys 改为 ctrl+v;终端保持 ctrl+shift+v。
  • 日志:~/.cache/shuotype/shuotype.log;前台运行 shuotype daemon 时也会直接输出到终端(systemd 下可用 journalctl 查看)。

隐私

  • 默认 polish_mode=off,识别文本不会发送到 DeepSeek。
  • 开启润色后,识别文本会发送到 DeepSeek API。
  • 流式模式下,录音音频会边录边发送到阿里云实时语音识别。
  • 录音只在内存中保留到识别完成,不落盘。
  • 剪贴板会被识别文本覆盖。
  • daemon 直接读取 /dev/input 键盘事件流以识别热键,只比较键码,不记录、不发送其他按键内容。

已知限制

  • 一句话识别上限 60 秒。
  • 识别期间切换焦点,文字会粘到新焦点窗口。
  • 流式识别的中间结果靠反复退格/粘贴更新,极少数应用可能处理异常;流式模式不支持 polish_mode。
  • 流式识别依赖阿里云实时语音识别服务,未开通时会回退一句话识别。
  • 仅适配 cn-shanghai 地域端点。
  • 热键只能选修饰键或 F1–F12;F 键仍可能触发前台应用自身的快捷键。
  • 热键依赖当前用户可读 /dev/input/event*(input 组)。
  • 纯 PipeWire 环境依赖 pipewire-pulse 兼容层(默认 audio_device=pulse)。
  • 识别语言跟随阿里云 NLS 项目模型配置,本项目不单独指定。
  • 开启润色后,DeepSeek 调用额外增加约 0.5–2 秒延迟。

Metadata

Release files for shuotype 0.5.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for shuotype 0.5.2.2
File Interpreter ABI Platform Actions
shuotype-0.5.2.2-py3-none-any.whl Python 3 none any Details for shuotype-0.5.2.2-py3-none-any.whl

Release files / shuotype-0.5.2.2-py3-none-any.whl

Download URL shuotype-0.5.2.2-py3-none-any.whl
Size 47.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65d87cb58afefc7997117cda4a0f2747c5fc067fd6b913999cef1132778241ae
BLAKE2b-256 checksum
How to use checksums
6a4b20d382be7e64e40f21cb2817e674d49810a87080909d03eaf620f50218f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.9

Security for shuotype 0.5.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page