Skip to content

Doubao-powered voice input for Linux, Wayland and Omarchy

feat(asr): expose Deepgram English recognition

quanrucdb1b6bfe055
diff --git a/README.md b/README.md
index 129d71b..2c89dff 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
A standalone GTK4 voice-input application for Linux (Hyprland/Wayland and native X11). It uses Doubao
web-account recognition by default and can optionally use the official Volcengine
-Seed ASR 2.0 API. English by default. Settings offers **System / English /
+Seed ASR 2.0 API or Deepgram Nova-3 for English dictation. English by default. Settings offers **System / English /
简体中文** and saves each choice automatically. System follows the session's language preferences,
uses Simplified Chinese for Chinese locales, and falls back to English otherwise.
Optional Omarchy integration manages the **same application**, not another engine.
@@ -26,7 +26,8 @@ then finish onboarding. Removal differs from the offline archive. Do not mix bot
Open **Doubao Say** from your application launcher:
1. **Recognition** — use the default Doubao web sign-in, or select
- **Volcengine official API** in Settings and add your own speech API key.
+ **Volcengine official API** or **Deepgram Nova-3 (English)** in Settings and
+ add your own speech API key.
Credentials stay on this device.
2. **Microphone** — choose a PipeWire input, then run a three-second,
device-only check with actionable feedback. Device changes save immediately.
@@ -63,6 +64,21 @@ See [Doubao and the official Volcengine speech API](docs/volcengine-asr.md) for
backend differences, new-console activation, bidirectional streaming limitations,
and troubleshooting.
+### Optional Deepgram English recognition
+
+Open **Settings → Recognition service**, select **Deepgram Nova-3 (English)**,
+and enter an API key from the Deepgram console. Use **Test API key** before the
+voice test. Doubao Say streams 16 kHz mono PCM to Deepgram's Nova-3 live endpoint
+with US English, interim results, punctuation, and smart formatting enabled.
+Partial text appears while you speak and the finalized transcript is returned
+after recording stops. Deepgram bills usage to your account.
+
+The API key is stored in `~/.config/doubao-say/deepgram_api_key` (or the
+equivalent `XDG_CONFIG_HOME` path) with owner-only permissions. It is excluded
+from settings, diagnostics, logs, bundles, and reports. The app currently fixes
+this provider to US English; other Deepgram languages and multilingual mode are
+not exposed yet.
+
### Optional voice polishing
During polishing, a separate status row and softly pulsing stars sit above the
@@ -242,8 +258,8 @@ Automatic detection of every desktop shortcut conflict is not supported.
After a recording gesture is confirmed, the default unofficial backend sends the
locally buffered and live microphone audio to Doubao and depends on its web protocol.
-The optional official backend sends it to Volcengine under the user's API account
-and terms. Cancelled, double-tap and microphone-only checks do not upload audio.
+The optional API backends send it to Volcengine or Deepgram under the user's API
+account and terms. Cancelled, double-tap and microphone-only checks do not upload audio.
The hosted sign-in website controls its own language.
When optional polishing is enabled, recognized text—including provisional text
sent after a pause—is transmitted to the OpenAI-compatible endpoint configured by
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 9063186..d07d391 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -3,7 +3,7 @@
[English](README.md)
独立的 Linux GTK4 语音输入应用,支持 Hyprland / Wayland 和原生 X11。默认使用豆包网页账号识别,也可选择
-火山引擎官方 Seed ASR 2.0 API。
+火山引擎官方 Seed ASR 2.0 API,也可使用 Deepgram Nova-3 做英语听写。
默认英文,设置提供 **System(跟随系统)/ English / 简体中文**,选择后自动保存并立即生效。
System 读取桌面会话的语言偏好,中文区域使用简体中文,其他不支持的语言回退为英文。
可选的 Omarchy 集成管理的是**同一个应用**,不是另一套语音引擎。
@@ -21,8 +21,8 @@ System 读取桌面会话的语言偏好,中文区域使用简体中文,其
从应用菜单打开**豆包说(Doubao Say)**:
-1. **语音识别**:使用默认的豆包网页登录,或在设置中选择**火山引擎官方 API**并填写
- 自己的语音 API Key;凭证均保存在本机。
+1. **语音识别**:使用默认的豆包网页登录,或在设置中选择**火山引擎官方 API**、
+ **Deepgram Nova-3(英语)**并填写自己的语音 API Key;凭证均保存在本机。
2. **麦克风**:选择 PipeWire 输入设备,再进行三秒的本机检测;此步骤不上传音频,切换设备后立即保存。
3. **快捷键**:选择 Fn、Ctrl、Alt 或功能键预设后立即生效;也可选择下拉框最后一项
**录制快捷键…**,录制出的组合键会完整替换当前快捷键。
@@ -47,6 +47,18 @@ API Key 保存在 `~/.config/doubao-say/volcengine_api_key`(或对应的
两种识别方式的区别、新版控制台开通步骤、双向流式限制与排障方法见
[豆包与火山引擎官方语音识别](docs/volcengine-asr.zh-CN.md)。
+### 可选 Deepgram 英语识别
+
+打开**设置 → 语音识别服务**,选择 **Deepgram Nova-3(英语)**,填写 Deepgram
+控制台签发的 API Key。建议先点击**测试 API Key**,再进行试说。应用会把 16 kHz
+单声道 PCM 音频流式发送到 Deepgram Nova-3 实时接口,固定使用美式英语,并启用
+中间结果、标点和智能格式化。说话时会显示增量文字,录音结束后返回最终结果;用量由
+Deepgram 向你的账号计费。
+
+API Key 保存在 `~/.config/doubao-say/deepgram_api_key`(或对应的
+`XDG_CONFIG_HOME` 路径),权限仅限当前用户读取;不会进入设置文件、诊断信息、日志、
+安装包或测试报告。目前界面还没有开放 Deepgram 的其他语言和多语种模式。
+
### 可选语音润色
润色时,独立状态栏和缓慢闪烁的星星位于正文上方;等待三秒后显示快捷键提示。
@@ -182,7 +194,7 @@ X11 窗口信息缺失、窗口关闭或焦点在本应用窗口时,均不自
## 隐私与限制
录音手势确认后,默认的非官方后端会把本地预录音和后续实时音频上传到豆包,并依赖豆包
-网页协议;可选的官方后端会按用户的 API 账号和服务条款向火山引擎上传音频。双击、取消和
+网页协议;可选的 API 后端会按用户的账号和服务条款向火山引擎或 Deepgram 上传音频。双击、取消和
单独的麦克风检测不上传音频;登录网页的语言由豆包网站决定。
开启可选润色后,识别文字(包括停顿后用于预润色的临时文字)会发送到用户配置的
OpenAI 兼容接口,并适用该接口运营方的数据留存、训练及隐私政策。
diff --git a/src/doubao_input/app.py b/src/doubao_input/app.py
index 6ed1a81..36485b8 100644
--- a/src/doubao_input/app.py
+++ b/src/doubao_input/app.py
@@ -26,10 +26,6 @@ from doubao_input.inject.target import focused_target
from doubao_input.result import RecentResult
from doubao_input.doubao.params_store import ParamsStore
from doubao_input.doubao.transcription import TranscriptionManager
-from doubao_input.doubao.volcengine_asr_client import VolcengineASRClient
-from doubao_input.doubao.volcengine_credentials import (
- VolcengineCredentials, VolcengineCredentialsStore,
-)
from doubao_input.inject.injector import Injector
from doubao_input.trigger.reader import TriggerReader
from doubao_input.trigger.controller import TriggerController
@@ -239,9 +235,9 @@ class DoubaoInputApp(Gtk.Application):
test_polish=self._test_polish,
apply_microphone=self._apply_microphone,
apply_asr_provider=self._apply_asr_provider,
- asr_has_key=self._official_has_key,
- save_asr=self._save_official_key,
- test_asr=self._test_official_asr,
+ asr_has_key=self._api_key_has_saved,
+ save_asr=self._save_asr_key,
+ test_asr=self._test_asr_key,
),
)
self._update_checker = UpdateChecker(GLib.idle_add, self._update_available)
@@ -815,7 +811,6 @@ class DoubaoInputApp(Gtk.Application):
self._login_window = None
provider = recognition_provider(
getattr(getattr(self, "settings", None), "asr_provider", "doubao"))
- official = provider.id == "volcengine"
store = provider.credential_store
try:
store.clear()
@@ -823,8 +818,8 @@ class DoubaoInputApp(Gtk.Application):
raise ValueError(tr("Could not clear saved credentials. Check configuration folder permissions.",
"无法清除保存的凭证,请检查配置目录权限。")) from error
self.app_state.login_status = LoginStatus.NOT_LOGGED_IN
- message = (tr("Official API key cleared.", "已清除官方 API Key。")
- if official else
+ message = (tr("API key cleared.", "已清除 API Key。")
+ if provider.uses_api_key else
tr("Saved credentials cleared. Website sessions may require signing out separately.",
"已清除保存的凭证;网站会话可能还需单独退出登录。"))
self._control.set_feedback(message)
@@ -855,8 +850,8 @@ class DoubaoInputApp(Gtk.Application):
capture_key=self._begin_key_capture, cancel_capture=self._end_key_capture,
sign_out=self._sign_out, restart=self._restart, login=self._show_login,
preview=self._preview_overlay, apply_key=self._apply_trigger_key,
- asr_has_key=self._official_has_key, save_asr=self._save_official_key,
- clear_asr=self._clear_official_key, test_asr=self._test_official_asr,
+ asr_has_key=self._api_key_has_saved, save_asr=self._save_asr_key,
+ clear_asr=self._clear_asr_key, test_asr=self._test_asr_key,
diagnostic_report=lambda: diagnostic_report(
self.settings, recording=self.app_state.is_recording,
trace=self._diagnostics))
@@ -915,45 +910,60 @@ class DoubaoInputApp(Gtk.Application):
self._login_window.show()
def _connect_recognition(self) -> None:
- if self.settings.asr_provider == "volcengine":
+ provider = recognition_provider(self.settings.asr_provider)
+ if provider.uses_api_key:
self._control.set_feedback(tr(
- "Add or test your Volcengine API key in Settings.",
- "请在设置中填写或测试火山引擎 API Key。"))
+ "Add or test your speech API key in Settings.",
+ "请在设置中填写或测试语音 API Key。"))
self._show_settings()
else:
self._show_login()
- def _official_has_key(self):
- return VolcengineCredentialsStore.has_saved()
+ def _api_key_has_saved(self):
+ provider = recognition_provider(self.settings.asr_provider)
+ return provider.uses_api_key and provider.credential_store.has_saved()
- def _save_official_key(self, key):
+ def _save_asr_key(self, key):
if self._busy():
raise ValueError(tr("Finish the current operation first.", "请先结束当前操作。"))
+ provider = recognition_provider(self.settings.asr_provider)
+ if not provider.uses_api_key:
+ raise ValueError(tr(
+ "The selected service does not use an API key.",
+ "当前服务不使用 API Key。"))
if key:
- VolcengineCredentialsStore.save(VolcengineCredentials(key.strip()))
+ provider.credential_store.save(
+ provider.credentials_from_secret(key.strip()))
self._sync_recognition_status()
if self._control:
self._control.refresh()
- def _clear_official_key(self):
+ def _clear_asr_key(self):
if self._busy():
raise ValueError(tr("Finish the current operation first.", "请先结束当前操作。"))
- VolcengineCredentialsStore.clear()
+ provider = recognition_provider(self.settings.asr_provider)
+ if provider.uses_api_key:
+ provider.credential_store.clear()
self._sync_recognition_status()
if self._control:
self._control.refresh()
- def _test_official_asr(self, key, completed):
+ def _test_asr_key(self, key, completed):
if self._busy():
raise ValueError(tr("Finish the current operation first.", "请先结束当前操作。"))
- credentials = (VolcengineCredentials(key.strip()) if key else
- VolcengineCredentialsStore.load())
+ provider = recognition_provider(self.settings.asr_provider)
+ if not provider.uses_api_key:
+ raise ValueError(tr(
+ "The selected service does not use an API key.",
+ "当前服务不使用 API Key。"))
+ credentials = (provider.credentials_from_secret(key.strip()) if key else
+ provider.credential_store.load())
if credentials is None:
raise ValueError(tr("Enter an API key first.", "请先填写 API Key。"))
credentials.validate()
if self._asr_probe:
self._asr_probe.disconnect()
- probe = self._asr_probe = VolcengineASRClient()
+ probe = self._asr_probe = provider.new_client()
finished = False
def deliver(result, error):
nonlocal finished
@@ -967,8 +977,8 @@ class DoubaoInputApp(Gtk.Application):
if self._control:
self._control.refresh()
GLib.idle_add(completed, result, error)
- # The server's initial protocol response is the credential/resource
- # acknowledgement. No microphone data is needed for this settings test.
+ # A successful WebSocket handshake validates the provider credential.
+ # No microphone data is needed for this settings test.
probe.on_open = lambda: deliver(tr("API key accepted", "API Key 可用"), "")
probe.on_auth_error = lambda: deliver(None, tr(
"API key rejected; check service activation and project access",
@@ -1041,10 +1051,11 @@ class DoubaoInputApp(Gtk.Application):
def _on_auth_expired(self) -> None:
self._login_attempt = None
self.app_state.login_status = LoginStatus.NOT_LOGGED_IN
- if self.settings.asr_provider == "volcengine":
+ provider = recognition_provider(self.settings.asr_provider)
+ if provider.uses_api_key:
self._control.set_feedback(tr(
- "Volcengine rejected the saved API key. Update or test it in Settings.",
- "火山引擎拒绝了已保存的 API Key,请在设置中更新或测试。"))
+ "The recognition service rejected the saved API key. Update or test it in Settings.",
+ "语音识别服务拒绝了已保存的 API Key,请在设置中更新或测试。"))
self._show_settings()
else:
self._show_login()
diff --git a/src/doubao_input/recognition_providers.py b/src/doubao_input/recognition_providers.py
index 3c6eb26..bf94376 100644
--- a/src/doubao_input/recognition_providers.py
+++ b/src/doubao_input/recognition_providers.py
@@ -15,6 +15,9 @@ class CredentialStore(Protocol):
@classmethod
def clear(cls) -> None: ...
+ @classmethod
+ def save(cls, credentials) -> None: ...
+
@classmethod
def has_saved(cls) -> bool: ...
@@ -28,6 +31,15 @@ class RecognitionProvider:
credential_store_factory: Callable[[], type[CredentialStore]]
interactive_auth: bool
clear_rejected_credentials: bool
+ secret_credentials_factory: Callable[[str], object] | None
+ setup_heading_en: str
+ setup_heading_zh: str
+ setup_body_en: str
+ setup_body_zh: str
+ credential_help_en: str
+ credential_help_zh: str
+ privacy_en: str
+ privacy_zh: str
@property
def name(self) -> str:
@@ -40,6 +52,31 @@ class RecognitionProvider:
def credential_store(self) -> type[CredentialStore]:
return self.credential_store_factory()
+ @property
+ def uses_api_key(self) -> bool:
+ return self.secret_credentials_factory is not None
+
+ @property
+ def setup_heading(self) -> str:
+ return tr(self.setup_heading_en, self.setup_heading_zh)
+
+ @property
+ def setup_body(self) -> str:
+ return tr(self.setup_body_en, self.setup_body_zh)
+
+ @property
+ def credential_help(self) -> str:
+ return tr(self.credential_help_en, self.credential_help_zh)
+
+ @property
+ def privacy(self) -> str:
+ return tr(self.privacy_en, self.privacy_zh)
+
+ def credentials_from_secret(self, secret: str):
+ if self.secret_credentials_factory is None:
+ raise ValueError("Recognition provider does not use an API key")
+ return self.secret_credentials_factory(secret)
+
def _doubao_client():
from doubao_input.doubao.asr_client import ASRClient
@@ -61,6 +98,26 @@ def _volcengine_store():
return VolcengineCredentialsStore
+def _volcengine_credentials(secret):
+ from doubao_input.doubao.volcengine_credentials import VolcengineCredentials
+ return VolcengineCredentials(secret)
+
+
+def _deepgram_client():
+ from doubao_input.deepgram.asr_client import DeepgramASRClient
+ return DeepgramASRClient()
+
+
+def _deepgram_store():
+ from doubao_input.deepgram.credentials import DeepgramCredentialsStore
+ return DeepgramCredentialsStore
+
+
+def _deepgram_credentials(secret):
+ from doubao_input.deepgram.credentials import DeepgramCredentials
+ return DeepgramCredentials(secret)
+
+
_PROVIDERS = (
RecognitionProvider(
id="doubao",
@@ -70,6 +127,15 @@ _PROVIDERS = (
credential_store_factory=_doubao_store,
interactive_auth=True,
clear_rejected_credentials=True,
+ secret_credentials_factory=None,
+ setup_heading_en="Your voice, wherever you type.",
+ setup_heading_zh="让声音变成文字。",
+ setup_body_en="Connect your Doubao account in a secure web window. Complete the sign-in method offered by Doubao, then return here. We never ask you to type a password into this app's settings.\n\nAudio is sent to Doubao only during recording. Sign-in data is stored on this device. This is an unofficial client.",
+ setup_body_zh="在网页窗口中连接豆包账号。按照豆包页面提供的方式完成登录,再回到这里;无需在本软件设置中填写密码。\n\n仅录音期间会向豆包发送音频。登录信息保存在本机。这是非官方客户端。",
+ credential_help_en="",
+ credential_help_zh="",
+ privacy_en="Doubao receives audio during dictation and voice tests. Microphone checks stay local. No recording files or transcript history are saved. Recent text stays in memory until cleared or the app exits.",
+ privacy_zh="听写和语音测试会向豆包发送音频,麦克风检查仅在本机进行。不保存录音文件和转写历史,最近文字仅在内存保留,清除或退出后消失。",
),
RecognitionProvider(
id="volcengine",
@@ -79,6 +145,33 @@ _PROVIDERS = (
credential_store_factory=_volcengine_store,
interactive_auth=False,
clear_rejected_credentials=False,
+ secret_credentials_factory=_volcengine_credentials,
+ setup_heading_en="Use the official Volcengine speech API.",
+ setup_heading_zh="使用火山引擎官方语音 API。",
+ setup_body_en="Add your API key in Settings. Audio is sent to Volcengine only while recording; usage is billed by Volcengine to your account. The key is stored separately on this device with owner-only permissions.",
+ setup_body_zh="请在设置中填写 API Key。仅录音期间会向火山引擎发送音频,用量由火山引擎向你的账号计费。API Key 单独保存在本机,且仅当前用户可读。",
+ credential_help_en="The new Doubao Speech console uses one API Key. Resource ID volc.seedasr.sauc.duration is built in. App ID and Access Key are only for the legacy console and are not required here.",
+ credential_help_zh="新版豆包语音控制台只使用一个 API Key;资源 ID volc.seedasr.sauc.duration 已内置。App ID 和 Access Key 仅用于旧版控制台,这里不需要填写。",
+ privacy_en="Volcengine receives audio during dictation and voice tests. Usage and data handling follow your Volcengine account and service terms. Microphone checks stay local. No recording files or transcript history are saved; recent text stays in memory until cleared or the app exits.",
+ privacy_zh="听写和试说时会向火山引擎发送音频,用量和数据处理遵循你的火山引擎账号及服务条款。麦克风检查仅在本机进行。不保存录音文件和转写历史;最近文字仅在内存保留,清除或退出后消失。",
+ ),
+ RecognitionProvider(
+ id="deepgram",
+ name_en="Deepgram Nova-3 (English)",
+ name_zh="Deepgram Nova-3(英语)",
+ client_factory=_deepgram_client,
+ credential_store_factory=_deepgram_store,
+ interactive_auth=False,
+ clear_rejected_credentials=False,
+ secret_credentials_factory=_deepgram_credentials,
+ setup_heading_en="Use Deepgram Nova-3 for English dictation.",
+ setup_heading_zh="使用 Deepgram Nova-3 进行英语听写。",
+ setup_body_en="Add a Deepgram API key in Settings. Audio is streamed to Deepgram only while recording. Usage is billed to your Deepgram account, and the key is stored separately on this device with owner-only permissions.",
+ setup_body_zh="请在设置中填写 Deepgram API Key。仅录音期间会向 Deepgram 流式发送音频,用量由 Deepgram 向你的账号计费。API Key 单独保存在本机,且仅当前用户可读。",
+ credential_help_en="Uses Deepgram Nova-3 with US English, interim results, punctuation, and smart formatting. Create and manage the API key in the Deepgram console.",
+ credential_help_zh="使用 Deepgram Nova-3 美式英语模型,并启用中间结果、标点和智能格式化。请在 Deepgram 控制台创建和管理 API Key。",
+ privacy_en="Deepgram receives audio during dictation and voice tests. Usage and data handling follow your Deepgram account and service terms. Microphone checks stay local. No recording files or transcript history are saved; recent text stays in memory until cleared or the app exits.",
+ privacy_zh="听写和试说时会向 Deepgram 发送音频,用量和数据处理遵循你的 Deepgram 账号及服务条款。麦克风检查仅在本机进行。不保存录音文件和转写历史;最近文字仅在内存保留,清除或退出后消失。",
),
)
diff --git a/src/doubao_input/ui/control_window.py b/src/doubao_input/ui/control_window.py
index c87c892..d40cb35 100644
--- a/src/doubao_input/ui/control_window.py
+++ b/src/doubao_input/ui/control_window.py
@@ -10,7 +10,10 @@ from doubao_input.ui.polish_settings import PolishSettings
from doubao_input.ui.style import apply_window_style
from doubao_input.product import VERSION
from doubao_input.settings import ASR_PROVIDERS
-from doubao_input.recognition_providers import recognition_providers
+from doubao_input.recognition_providers import (
+ recognition_provider,
+ recognition_providers,
+)
class ControlWindow:
@@ -44,6 +47,7 @@ class ControlWindow:
self._asr_provider = None
self._changing_asr_provider = False
self._asr_details = None
+ self._asr_help = None
self._asr_key = None
self._asr_key_save_source = 0
self._asr_test_button = None
@@ -145,17 +149,13 @@ class ControlWindow:
return
logged_in = self._app_state.login_status == LoginStatus.LOGGED_IN
summary = self._actions.summary()
- official = summary.get("asr_provider") == "volcengine"
+ provider = recognition_provider(summary.get("asr_provider", "doubao"))
+ uses_api_key = provider.uses_api_key
if self._page_headings:
- self._page_titles["account"] = tr("Recognition", "语音识别") if official else tr("Sign in", "登录")
- self._page_headings["account"].set_text(
- tr("Use the official Volcengine speech API.", "使用火山引擎官方语音 API。")
- if official else tr("Your voice, wherever you type.", "让声音变成文字。"))
- self._page_bodies["account"].set_text(tr(
- "Add your API key in Settings. Audio is sent to Volcengine only while recording; usage is billed by Volcengine to your account. The key is stored separately on this device with owner-only permissions.",
- "请在设置中填写 API Key。仅录音期间会向火山引擎发送音频,用量由火山引擎向你的账号计费。API Key 单独保存在本机,且仅当前用户可读。") if official else tr(
- "Connect your Doubao account in a secure web window. Complete the sign-in method offered by Doubao, then return here. We never ask you to type a password into this app's settings.\n\nAudio is sent to Doubao only during recording. Sign-in data is stored on this device. This is an unofficial client.",
- "在网页窗口中连接豆包账号。按照豆包页面提供的方式完成登录,再回到这里;无需在本软件设置中填写密码。\n\n仅录音期间会向豆包发送音频。登录信息保存在本机。这是非官方客户端。"))
+ self._page_titles["account"] = (tr("Recognition", "语音识别")
+ if uses_api_key else tr("Sign in", "登录"))
+ self._page_headings["account"].set_text(provider.setup_heading)
+ self._page_bodies["account"].set_text(provider.setup_body)
if self._account_status:
self._changing_asr_provider = True
try:
@@ -163,7 +163,7 @@ class ControlWindow:
summary.get("asr_provider", "doubao")))
finally:
self._changing_asr_provider = False
- if official:
+ if uses_api_key:
self._account_status.set_text(tr(
"API key saved · run the connection test in Settings or continue to a voice test.",
"API Key 已保存 · 可在设置中测试连接,或继续进行试说。") if logged_in else tr(
@@ -177,9 +177,11 @@ class ControlWindow:
self._login_button.set_label(tr("Sign in again / change account", "重新登录或更换账号") if logged_in else
tr("Open Doubao sign-in", "打开豆包登录"))
self._login_button.set_visible(True)
- self._asr_details.set_visible(official)
- if official:
- self._status_label.set_text(tr("Official API ready · test your voice to verify", "官方 API 已就绪 · 请试说一句验证")
+ self._asr_details.set_visible(uses_api_key)
+ if self._asr_help:
+ self._asr_help.set_text(provider.credential_help)
+ if uses_api_key:
+ self._status_label.set_text(tr("Speech API ready · test your voice to verify", "语音 API 已就绪 · 请试说一句验证")
if logged_in else tr("Add an API key to get started", "请先填写 API Key"))
else:
self._status_label.set_text(tr("Sign-in saved · test your voice to verify", "登录信息已保存 · 请试说一句验证")
@@ -192,7 +194,7 @@ class ControlWindow:
if self._trigger_picker:
self._trigger_picker.sync(summary.get("key_code", 464), summary.get("key_modifiers", ()))
if self._summary_label:
- requirement = (tr("Credentials required", "需要配置凭证") if official else
+ requirement = (tr("Credentials required", "需要配置凭证") if uses_api_key else
tr("Sign-in required", "需要登录"))
self._summary_label.set_text((state_names[state] if logged_in else requirement) + " · " +
tr("Service: ", "服务:") + summary.get("asr_provider_name", "Doubao") + "\n" +
@@ -346,17 +348,17 @@ class ControlWindow:
self._asr_key.connect("changed", self._queue_asr_key_save)
key_row.append(self._asr_key)
self._asr_details.append(key_row)
- self._asr_details.append(label(tr(
- "The new Doubao Speech console uses one API Key. Resource ID volc.seedasr.sauc.duration is built in. App ID and Access Key are only for the legacy console and are not required here.",
- "新版豆包语音控制台只使用一个 API Key;资源 ID volc.seedasr.sauc.duration 已内置。App ID 和 Access Key 仅用于旧版控制台,这里不需要填写。"), secondary=True))
+ selected_provider = recognition_provider(
+ self._actions.summary().get("asr_provider", "doubao"))
+ self._asr_help = label(selected_provider.credential_help, secondary=True)
+ self._asr_details.append(self._asr_help)
self._asr_test_button = Gtk.Button(label=tr("Test API key", "测试 API Key"))
self._asr_test_button.connect("clicked", self._test_asr_clicked)
self._asr_details.append(self._asr_test_button)
self._asr_status = label("")
self._asr_status.add_css_class("accent")
self._asr_details.append(self._asr_status)
- self._asr_details.set_visible(
- self._actions.summary().get("asr_provider") == "volcengine")
+ self._asr_details.set_visible(selected_provider.uses_api_key)
account.append(self._asr_details)
self._account_status = label("")
account.append(self._account_status)
@@ -364,8 +366,8 @@ class ControlWindow:
mic = page("microphone", tr("Microphone", "麦克风"),
tr("Let's make sure we can hear you.", "先确认能听到你的声音。"),
- tr("Choose an input, then press Check microphone and speak normally for three seconds. This check stays on your device: no audio is sent to Doubao.",
- "选择输入设备,然后点击检查麦克风并正常说话三秒。此项检查只在本机进行,不向豆包发送音频。"))
+ tr("Choose an input, then press Check microphone and speak normally for three seconds. This check stays on your device: no audio is sent to the recognition service.",
+ "选择输入设备,然后点击检查麦克风并正常说话三秒。此项检查只在本机进行,不向语音识别服务发送音频。"))
selected_microphone = self._actions.summary().get("microphone_id", "")
self._microphone_sources = [("", tr("System default", "系统默认"))] + microphones()
if (selected_microphone and
@@ -566,7 +568,7 @@ class ControlWindow:
self._asr_test_button.set_sensitive(False)
self._asr_test_button.set_label(tr("Testing…", "正在测试…"))
self._asr_status.set_text(tr(
- "Testing official recognition…", "正在测试官方语音识别…"))
+ "Testing speech recognition…", "正在测试语音识别…"))
try:
self._actions.test_asr(
self._asr_key.get_text().strip() or None, self._asr_tested)
diff --git a/src/doubao_input/ui/settings_window.py b/src/doubao_input/ui/settings_window.py
index 0289e49..5ca6f0b 100644
--- a/src/doubao_input/ui/settings_window.py
+++ b/src/doubao_input/ui/settings_window.py
@@ -9,7 +9,10 @@ from doubao_input.product import VERSION
from doubao_input.settings import INPUT_METHODS, WAVEFORM_STYLES
from doubao_input.ui.style import apply_window_style
from doubao_input.settings import ASR_PROVIDERS
-from doubao_input.recognition_providers import recognition_providers
+from doubao_input.recognition_providers import (
+ recognition_provider,
+ recognition_providers,
+)
class SettingsWindow:
@@ -28,6 +31,7 @@ class SettingsWindow:
self._restart = restart
self._updating = False
self._asr_has_key = asr_has_key()
+ self._asr_has_key_func = asr_has_key
self._save_asr = save_asr
self._clear_asr = clear_asr
self._test_asr = test_asr
@@ -119,9 +123,10 @@ class SettingsWindow:
key_row.append(Gtk.Label(label="API Key", xalign=0, hexpand=True, wrap=True))
key_row.append(self.asr_key)
self.asr_details.append(key_row)
- self.asr_details.append(Gtk.Label(xalign=0, wrap=True, label=tr(
- "Uses the official Seed ASR 2.0 hourly API. Audio streams while you speak; the complete result returns after you finish. The key is stored separately with owner-only permissions.",
- "使用官方 Seed ASR 2.0 小时版。说话时流式上传音频,结束后返回完整结果。API Key 单独保存且仅当前用户可读。")))
+ selected_provider = recognition_provider(settings.asr_provider)
+ self.asr_help = Gtk.Label(
+ xalign=0, wrap=True, label=selected_provider.credential_help)
+ self.asr_details.append(self.asr_help)
asr_actions = Gtk.Box(spacing=8, homogeneous=True)
self.asr_test_button = Gtk.Button(label=tr("Test API key", "测试 API Key"))
self.asr_test_button.connect("clicked", self._test_asr_clicked)
@@ -133,7 +138,7 @@ class SettingsWindow:
self.asr_status = Gtk.Label(xalign=0, wrap=True, selectable=True)
self.asr_status.add_css_class("accent")
self.asr_details.append(self.asr_status)
- self.asr_details.set_visible(settings.asr_provider == "volcengine")
+ self.asr_details.set_visible(selected_provider.uses_api_key)
box.append(self.asr_details)
section(tr("Input", "输入"))
@@ -444,23 +449,24 @@ class SettingsWindow:
def _asr_provider_changed(self, *_):
if self._updating:
return
- official = ASR_PROVIDERS[self.asr_provider.get_selected()] == "volcengine"
self._sync_provider_details()
- if self._save_current() and official and not self._asr_has_key:
+ provider = recognition_provider(
+ ASR_PROVIDERS[self.asr_provider.get_selected()])
+ if self._save_current():
+ self._asr_has_key = self._asr_has_key_func()
+ if provider.uses_api_key and not self._asr_has_key:
self.asr_status.set_text(tr(
- "Enter an API key before using official recognition.",
- "使用官方识别前请填写 API Key。"))
+ "Enter an API key before using this recognition service.",
+ "使用当前语音识别服务前请填写 API Key。"))
def _sync_provider_details(self):
- official = ASR_PROVIDERS[self.asr_provider.get_selected()] == "volcengine"
- self.asr_details.set_visible(official)
- self.login_button.set_visible(not official)
- self.clear_credentials_button.set_visible(not official)
- self.privacy_copy.set_text(tr(
- "Volcengine receives audio during dictation and voice tests. Usage and data handling follow your Volcengine account and service terms. Microphone checks stay local. No recording files or transcript history are saved; recent text stays in memory until cleared or the app exits.",
- "听写和试说时会向火山引擎发送音频,用量和数据处理遵循你的火山引擎账号及服务条款。麦克风检查仅在本机进行。不保存录音文件和转写历史;最近文字仅在内存保留,清除或退出后消失。") if official else tr(
- "Doubao receives audio during dictation and voice tests. Microphone checks stay local. No recording files or transcript history are saved. Recent text stays in memory until cleared or the app exits.",
- "听写和语音测试会向豆包发送音频,麦克风检查仅在本机进行。不保存录音文件和转写历史,最近文字仅在内存保留,清除或退出后消失。"))
+ provider = recognition_provider(
+ ASR_PROVIDERS[self.asr_provider.get_selected()])
+ self.asr_details.set_visible(provider.uses_api_key)
+ self.login_button.set_visible(provider.interactive_auth)
+ self.clear_credentials_button.set_visible(provider.interactive_auth)
+ self.asr_help.set_text(provider.credential_help)
+ self.privacy_copy.set_text(provider.privacy)
def _queue_asr_key_save(self, *_):
if self._updating or not self.asr_key.get_text().strip():
@@ -527,7 +533,7 @@ class SettingsWindow:
self.asr_test_button.set_sensitive(False)
self.asr_test_button.set_label(tr("Testing…", "正在测试…"))
self.asr_status.set_text(tr(
- "Testing official recognition…", "正在测试官方语音识别…"))
+ "Testing speech recognition…", "正在测试语音识别…"))
try:
self._test_asr(self.asr_key.get_text().strip() or None, self._asr_tested)
except (ValueError, OSError) as error:
diff --git a/tests/e2e/README.md b/tests/e2e/README.md
index cb062be..07e62f3 100644
--- a/tests/e2e/README.md
+++ b/tests/e2e/README.md
@@ -117,7 +117,8 @@ This demonstrates visual testing of a Wayland desktop through a VM bridge.
`cases/onboarding-regressions.yaml` covers ten focused cases: sign-in
cancellation and persistence, disabled and custom triggers, polishing state,
endpoint recovery, microphone checks and device changes, voice-test
-cancellation, and official Volcengine API configuration. `cases/runtime.yaml`
+cancellation, Volcengine API configuration, and Deepgram English API configuration.
+`cases/runtime.yaml`
adds successful and cancelled F8 dictation delivery. The Ubuntu project runs
these alongside the successful onboarding case.
diff --git a/tests/e2e/cases/onboarding-regressions.yaml b/tests/e2e/cases/onboarding-regressions.yaml
index d2f2773..93b647f 100644
--- a/tests/e2e/cases/onboarding-regressions.yaml
+++ b/tests/e2e/cases/onboarding-regressions.yaml
@@ -177,6 +177,19 @@ cases:
- aiAssert: The result says API key accepted by synthetic endpoint and the page reports that the official API is ready.
- aiTap: Right-arrow Next button in the fixed top navigation
- aiAssert: The current step is Microphone and the heading Let's make sure we can hear you is visible.
+ - name: Switch to Deepgram English recognition
+ tags: [shard-3]
+ steps:
+ - fixture.prepare: { mode: deepgram }
+ - aiAct: In Recognition service, select Deepgram Nova-3 English exactly once.
+ - aiAct: Scroll down inside the central content panel until the API Key field and Test API key button are both visible.
+ - aiAssert: The page is Recognition, explains Deepgram Nova-3 English dictation, shows an empty API Key field, and hides Open Doubao sign-in.
+ - computer.inputText:
+ target: API Key field
+ value: synthetic-deepgram-key
+ - aiTap: Test API key button below the API Key field
+ - wait: { duration: 750 }
+ - aiAssert: The result says API key accepted by synthetic endpoint and the page reports that the speech API is ready.
- name: Changing microphone requires another check
tags: [shard-2]
steps:
diff --git a/tests/e2e/gtk_onboarding_fixture.py b/tests/e2e/gtk_onboarding_fixture.py
index b23879c..5f88534 100644
--- a/tests/e2e/gtk_onboarding_fixture.py
+++ b/tests/e2e/gtk_onboarding_fixture.py
@@ -235,13 +235,18 @@ def build_onboarding_fixture(mode):
)
def apply_asr_provider(provider):
+ provider_names = {
+ "doubao": "Doubao",
+ "volcengine": "Volcengine",
+ "deepgram": "Deepgram Nova-3 (English)",
+ }
summary.update(
asr_provider=provider,
- asr_provider_name=("Volcengine" if provider == "volcengine" else "Doubao"),
+ asr_provider_name=provider_names[provider],
)
state.login_status = (
LoginStatus.LOGGED_IN
- if provider == "volcengine" and holder["asr_key"]
+ if provider != "doubao" and holder["asr_key"]
else LoginStatus.NOT_LOGGED_IN
)
GLib.idle_add(refresh)
diff --git a/tests/manual/refactor_smoke.py b/tests/manual/refactor_smoke.py
index 945b4c3..13685f4 100644
--- a/tests/manual/refactor_smoke.py
+++ b/tests/manual/refactor_smoke.py
@@ -52,10 +52,10 @@ def main():
window = SettingsWindow(app._control.window, app.settings, app.apply_settings,
capture_key=app._begin_key_capture, cancel_capture=app._end_key_capture,
apply_key=app._apply_trigger_key,
- asr_has_key=app._official_has_key,
- save_asr=app._save_official_key,
- clear_asr=app._clear_official_key,
- test_asr=app._test_official_asr)
+ asr_has_key=app._api_key_has_saved,
+ save_asr=app._save_asr_key,
+ clear_asr=app._clear_asr_key,
+ test_asr=app._test_asr_key)
window.window.realize()
if language == "en":
window.asr_provider.set_selected(1)
diff --git a/tests/unit/test_app_edges.py b/tests/unit/test_app_edges.py
index b3e8921..e72cbdf 100644
--- a/tests/unit/test_app_edges.py
+++ b/tests/unit/test_app_edges.py
@@ -6,6 +6,8 @@ from doubao_input.app import DoubaoInputApp
from doubao_input.doubao.app_state import AppState, LoginStatus, RecordingState
from doubao_input.doubao.volcengine_asr_client import VolcengineASRClient
from doubao_input.doubao.volcengine_credentials import VolcengineCredentialsStore
+from doubao_input.deepgram.asr_client import DeepgramASRClient
+from doubao_input.deepgram.credentials import DeepgramCredentialsStore
from doubao_input.result import RecentResult
from doubao_input.settings import Settings
@@ -151,16 +153,26 @@ class AppSetupEdgesTest(TestCase):
completed = Mock()
app = SimpleNamespace(_busy=lambda: False, _asr_probe=None,
_sync_recognition_status=Mock(), _control=Mock())
- with patch("doubao_input.app.VolcengineASRClient") as client_type, \
+ app.settings = Settings(asr_provider="volcengine")
+ with patch("doubao_input.doubao.volcengine_asr_client.VolcengineASRClient") as client_type, \
patch("doubao_input.app.GLib.idle_add") as idle_add:
probe = client_type.return_value
- DoubaoInputApp._test_official_asr(app, "test-key", completed)
+ DoubaoInputApp._test_asr_key(app, "test-key", completed)
probe.on_open()
probe.disconnect.assert_called_once_with()
app._sync_recognition_status.assert_called_once_with()
app._control.refresh.assert_called_once_with()
idle_add.assert_called_once_with(completed, "API key accepted", "")
+ def test_deepgram_provider_builds_api_key_backend(self):
+ app = SimpleNamespace(settings=Settings(asr_provider="deepgram"),
+ app_state=AppState())
+ manager = DoubaoInputApp._new_transcription_manager(app)
+ self.addCleanup(manager.asr_client.disconnect)
+ self.assertIsInstance(manager.asr_client, DeepgramASRClient)
+ self.assertIs(manager.credential_store, DeepgramCredentialsStore)
+ self.assertFalse(manager.interactive_auth)
+
def test_microphone_selection_uses_normal_settings_pipeline(self):
app = SimpleNamespace(settings=Settings(microphone=""), apply_settings=Mock())
DoubaoInputApp._apply_microphone(app, "desk-mic")
diff --git a/tests/unit/test_recognition_providers.py b/tests/unit/test_recognition_providers.py
index 4df4050..6302ff4 100644
--- a/tests/unit/test_recognition_providers.py
+++ b/tests/unit/test_recognition_providers.py
@@ -4,6 +4,8 @@ from doubao_input.doubao.asr_client import ASRClient
from doubao_input.doubao.params_store import ParamsStore
from doubao_input.doubao.volcengine_asr_client import VolcengineASRClient
from doubao_input.doubao.volcengine_credentials import VolcengineCredentialsStore
+from doubao_input.deepgram.asr_client import DeepgramASRClient
+from doubao_input.deepgram.credentials import DeepgramCredentialsStore
from doubao_input.recognition_providers import (
RECOGNITION_PROVIDER_IDS,
recognition_provider,
@@ -20,7 +22,11 @@ class RecognitionProviderRegistryTest(TestCase):
)
self.assertEqual(
[provider.name for provider in providers],
- ["Doubao account", "Volcengine official API"],
+ [
+ "Doubao account",
+ "Volcengine official API",
+ "Deepgram Nova-3 (English)",
+ ],
)
def test_registry_owns_runtime_backend_configuration(self):
@@ -32,6 +38,11 @@ class RecognitionProviderRegistryTest(TestCase):
self.assertIsInstance(official.new_client(), VolcengineASRClient)
self.assertIs(official.credential_store, VolcengineCredentialsStore)
self.assertFalse(official.interactive_auth)
+ deepgram = recognition_provider("deepgram")
+ self.assertIsInstance(deepgram.new_client(), DeepgramASRClient)
+ self.assertIs(deepgram.credential_store, DeepgramCredentialsStore)
+ self.assertTrue(deepgram.uses_api_key)
+ self.assertIn("Nova-3", deepgram.credential_help)
def test_unknown_provider_is_rejected(self):
with self.assertRaisesRegex(ValueError, "Unsupported recognition service"):