Skip to content

Doubao-powered voice input for Linux, Wayland and Omarchy

feat(onboarding): switch recognition service on sign-in page

quanruebd45e2f47a6
diff --git a/docs/volcengine-asr.md b/docs/volcengine-asr.md
index f188586..a13d648 100644
--- a/docs/volcengine-asr.md
+++ b/docs/volcengine-asr.md
@@ -33,8 +33,8 @@ Official references:
## Configure Doubao Say
-1. Open **Settings → Recognition service**.
-2. Select **Volcengine official API**.
+1. On the initial **Sign in** page, switch **Recognition service** to **Volcengine official API**. You can also switch it later under **Settings → Recognition service**; both controls save immediately and stay in sync.
+2. Select **Open recognition settings**.
3. Paste the API key. It saves automatically.
4. Select **Test API key**. A successful test verifies authentication and entitlement without uploading a recording.
5. Run the real voice test. Incremental text should appear in the overlay before recording finishes.
diff --git a/docs/volcengine-asr.zh-CN.md b/docs/volcengine-asr.zh-CN.md
index e7a2583..dd11407 100644
--- a/docs/volcengine-asr.zh-CN.md
+++ b/docs/volcengine-asr.zh-CN.md
@@ -38,8 +38,8 @@
## 在豆包说中配置
-1. 打开“设置 → 语音识别服务”。
-2. 选择“火山引擎官方 API”。
+1. 在首次设置的“登录”页直接把“语音识别服务”切换为“火山引擎官方 API”;也可以稍后在“设置 → 语音识别服务”中切换。两处会立即保存并保持同步。
+2. 点击“打开语音识别设置”。
3. 粘贴刚才创建的 API Key。修改会自动保存,不需要额外点击保存。
4. 点击“测试 API Key”。看到“API Key 可用”只代表鉴权和服务权限正常,不会上传录音。
5. 回到引导页执行“试说一句”。说话过程中应在悬浮窗看到增量文字,结束后得到最终结果。
diff --git a/src/doubao_input/app.py b/src/doubao_input/app.py
index 3fb562c..a7addf2 100644
--- a/src/doubao_input/app.py
+++ b/src/doubao_input/app.py
@@ -233,6 +233,7 @@ class DoubaoInputApp(Gtk.Application):
save_polish=self._save_polish,
test_polish=self._test_polish,
apply_microphone=self._apply_microphone,
+ apply_asr_provider=self._apply_asr_provider,
),
)
self._update_checker = UpdateChecker(GLib.idle_add, self._update_available)
@@ -303,6 +304,10 @@ class DoubaoInputApp(Gtk.Application):
from dataclasses import replace
self.apply_settings(replace(self.settings, microphone=device))
+ def _apply_asr_provider(self, provider):
+ from dataclasses import replace
+ self.apply_settings(replace(self.settings, asr_provider=provider))
+
def apply_settings(self, settings):
settings.validate()
if settings.autostart and "/omarchy/plugins/" in __file__:
diff --git a/src/doubao_input/ui/control_window.py b/src/doubao_input/ui/control_window.py
index 33b56c8..0621246 100644
--- a/src/doubao_input/ui/control_window.py
+++ b/src/doubao_input/ui/control_window.py
@@ -9,6 +9,7 @@ from doubao_input.ui.trigger_picker import TriggerPicker
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
class ControlWindow:
@@ -39,6 +40,8 @@ class ControlWindow:
self._summary_label = None
self._account_status = None
self._login_button = None
+ self._asr_provider = None
+ self._changing_asr_provider = False
self._trigger_picker = None
self._microphone = None
self._microphone_sources = []
@@ -141,6 +144,12 @@ class ControlWindow:
"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仅录音期间会向豆包发送音频。登录信息保存在本机。这是非官方客户端。"))
if self._account_status:
+ self._changing_asr_provider = True
+ try:
+ self._asr_provider.set_selected(ASR_PROVIDERS.index(
+ summary.get("asr_provider", "doubao")))
+ finally:
+ self._changing_asr_provider = False
if official:
self._account_status.set_text(tr(
"API key saved · run the connection test in Settings or continue to a voice test.",
@@ -293,6 +302,20 @@ class ControlWindow:
tr("Your voice, wherever you type.", "让声音变成文字。"),
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仅录音期间会向豆包发送音频。登录信息保存在本机。这是非官方客户端。"))
+ provider_row = Gtk.Box(spacing=12)
+ provider_row.add_css_class("settings-row")
+ provider_row.append(Gtk.Label(
+ label=tr("Recognition service", "语音识别服务"),
+ xalign=0, hexpand=True, wrap=True))
+ self._asr_provider = Gtk.DropDown.new_from_strings([
+ tr("Doubao account", "豆包账号"),
+ tr("Volcengine official API", "火山引擎官方 API"),
+ ])
+ self._asr_provider.set_selected(ASR_PROVIDERS.index(
+ self._actions.summary().get("asr_provider", "doubao")))
+ self._asr_provider.connect("notify::selected", self._asr_provider_changed)
+ provider_row.append(self._asr_provider)
+ account.append(provider_row)
self._account_status = label("")
account.append(self._account_status)
self._login_button = button(account, tr("Open Doubao sign-in", "打开豆包登录"), self._on_login, True)
@@ -433,6 +456,22 @@ class ControlWindow:
self.set_feedback(tr("Microphone saved. Run the three-second check.",
"麦克风已保存,请进行三秒检查。"))
+ def _asr_provider_changed(self, *_):
+ if self._changing_asr_provider:
+ return
+ selected = self._asr_provider.get_selected()
+ if selected >= len(ASR_PROVIDERS):
+ return
+ try:
+ self._actions.apply_asr_provider(ASR_PROVIDERS[selected])
+ except (ValueError, OSError) as error:
+ self.set_feedback(str(error))
+ self._refresh()
+ return
+ self.set_feedback(tr(
+ "Recognition service switched. Configure its credentials below to continue.",
+ "语音识别服务已切换,请在下方配置对应凭证后继续。"))
+
def _continue_from_trigger(self):
picker = self._trigger_picker
if picker.listening:
diff --git a/src/doubao_input/ui/setup_actions.py b/src/doubao_input/ui/setup_actions.py
index f16a152..eac68cd 100644
--- a/src/doubao_input/ui/setup_actions.py
+++ b/src/doubao_input/ui/setup_actions.py
@@ -19,3 +19,4 @@ class SetupActions:
save_polish: Callable = lambda settings, key: None
test_polish: Callable = lambda settings, key, done: None
apply_microphone: Callable[[str], None] = lambda device: None
+ apply_asr_provider: Callable[[str], None] = lambda provider: None
diff --git a/tests/test_app_edges.py b/tests/test_app_edges.py
index 06eff00..a0ad39d 100644
--- a/tests/test_app_edges.py
+++ b/tests/test_app_edges.py
@@ -167,6 +167,13 @@ class AppSetupEdgesTest(TestCase):
saved = app.apply_settings.call_args.args[0]
self.assertEqual(saved.microphone, "desk-mic")
+ def test_onboarding_provider_selection_uses_normal_settings_pipeline(self):
+ app = SimpleNamespace(settings=Settings(asr_provider="doubao"),
+ apply_settings=Mock())
+ DoubaoInputApp._apply_asr_provider(app, "volcengine")
+ saved = app.apply_settings.call_args.args[0]
+ self.assertEqual(saved.asr_provider, "volcengine")
+
def test_summary_contains_only_user_facing_state(self):
app = SimpleNamespace(settings=Settings(doubao_key=100, microphone="desk-mic"),
recent=RecentResult(text="result", status="failed"))
diff --git a/tests/test_setup_actions.py b/tests/test_setup_actions.py
index df953d2..9fc2948 100644
--- a/tests/test_setup_actions.py
+++ b/tests/test_setup_actions.py
@@ -73,6 +73,34 @@ class SetupActionsTest(unittest.TestCase):
control.set_feedback.assert_called_once_with("busy")
control._refresh.assert_called_once_with()
+ def test_recognition_service_selection_applies_immediately(self):
+ control = SimpleNamespace(
+ _changing_asr_provider=False,
+ _asr_provider=Mock(),
+ _actions=Mock(),
+ set_feedback=Mock(),
+ _refresh=Mock(),
+ )
+ control._asr_provider.get_selected.return_value = 1
+ ControlWindow._asr_provider_changed(control)
+ control._actions.apply_asr_provider.assert_called_once_with("volcengine")
+ control.set_feedback.assert_called_once()
+ control._refresh.assert_not_called()
+
+ def test_rejected_recognition_service_selection_restores_saved_value(self):
+ control = SimpleNamespace(
+ _changing_asr_provider=False,
+ _asr_provider=Mock(),
+ _actions=Mock(),
+ set_feedback=Mock(),
+ _refresh=Mock(),
+ )
+ control._asr_provider.get_selected.return_value = 1
+ control._actions.apply_asr_provider.side_effect = ValueError("busy")
+ ControlWindow._asr_provider_changed(control)
+ control.set_feedback.assert_called_once_with("busy")
+ control._refresh.assert_called_once_with()
+
def test_endpoint_test_has_adjacent_loading_and_success_feedback(self):
view = SimpleNamespace(
_testing=False,