nextalk icon indicating copy to clipboard operation
nextalk copied to clipboard

AudioCaptureError.streamOpenFailed

Open e3e0261f opened this issue 10 months ago • 14 comments

.local/share/nextalk
❯ tree
.
├── logs
│   └── diagnostic.log
├── models
│   ├── sensevoice
│   │   ├── export-onnx.py
│   │   ├── LICENSE
│   │   ├── model.int8.onnx
│   │   ├── model.onnx
│   │   ├── README.md
│   │   ├── sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17.tar.bz2
│   │   ├── test_wavs
│   │   │   ├── en.wav
│   │   │   ├── ja.wav
│   │   │   ├── ko.wav
│   │   │   ├── yue.wav
│   │   │   └── zh.wav
│   │   └── tokens.txt
│   └── vad
│       └── silero_vad.onnx
└── shared_preferences.json

6 directories, 15 files

OS: Debian GNU/Linux 13.2 (trixie) x86_64 Kernel: 6.12.57+deb13-amd64

[2026-01-10T07:24:46.905309] [INFO] [DiagnosticLogger] 日志系统初始化完成
[2026-01-10T07:24:46.905426] [INFO] [main] 应用启动 (SCP-002 极简架构)
[2026-01-10T07:24:46.922608] [INFO] [main] 设置服务初始化完成
[2026-01-10T07:24:46.922712] [INFO] [main] 语言服务初始化完成
[2026-01-10T07:24:46.957184] [WARN] [main] ⚠️ 音频设备预热失败: AudioCaptureError.streamOpenFailed
[2026-01-10T07:24:46.957418] [INFO] [main] 创建 ASR 引擎: EngineType.sensevoice
[2026-01-10T07:24:50.267171] [INFO] [main] ✅ ASR 引擎预初始化完成
[2026-01-10T07:24:50.267377] [INFO] [main] 应用初始化完成
[2026-01-10T07:25:24.391548] [INFO] [main] 收到命令: toggle
Image

e3e0261f avatar Jan 09 '26 23:01 e3e0261f

Hi @e3e0261f,

We've released v0.1.7 which includes more detailed error logging for audio device issues. Could you please:

  1. Download and install the latest release from the Releases page
  2. Run the application again
  3. If the error persists, please share the updated logs from ~/.local/share/nextalk/logs/diagnostic.log

Note: We've tested on the same system (Debian 13.2 trixie) and it works correctly on our end. This appears to be an environment-specific issue, so the detailed logs will help us identify the root cause.

Thanks for your patience!

gonewx avatar Jan 10 '26 03:01 gonewx

Thanks bro @gonewx After enabling EasyEffects, an “Audio device busy” error occurs. After disabling EasyEffects, version v0.1.7 runs smoothly on Debian 13 systems.

It would be great if I could select the audio device in the settings.yaml file.

[SingleInstance] 收到连接
[SingleInstance] 收到命令: toggle
[HotkeyController] 快捷键按下,当前状态: HotkeyState.idle
[AudioCapture] ✅ 首帧预缓冲完成 (320 samples)
[HotkeyController] 🎤 开始录音
[HotkeyController] 🔔 VAD 端点: isVad=true, text="いいねいいねおいいね。", duration=4225ms, deviceLost=false
[HotkeyController] 🔔 VAD 端点: isVad=true, text="いいねいいねおいいね。时间只在一转烟雨。", duration=8433ms, deviceLost=false

e3e0261f avatar Jan 10 '26 23:01 e3e0261f

Great suggestion! I've put this on the roadmap and we'll prioritize getting it into an upcoming release. Thanks for helping improve the project!

gonewx avatar Jan 11 '26 03:01 gonewx

@e3e0261f

We have fixed this issue based on your feedback in the latest version.

Please download and install the latest release version, then run the application again. If the issue still persists, please continue to provide updated log files so we can further investigate.

If you encounter "Audio device busy" error (e.g., when using EasyEffects), you can select a different audio input device:

Method 1: CLI Interactive Mode

nextalk audio       # Enter interactive mode to select device

Method 2: CLI Direct Selection

nextalk audio --list  # List available devices
nextalk audio 2       # Select device by index
nextalk audio default # Reset to system default

Method 3: System Tray Right-click tray icon → Audio Input Device → Select from available devices

Enjoy using it!

gonewx avatar Jan 12 '26 03:01 gonewx

Thank you @gonewx for taking the time to review my feedback.

After installing the new version, the system exhibited the anomaly shown in the video: Multiple attempts to resolve the recognition issue were unsuccessful. Only after launching pavucontrol once did Nextall's voice recognition functionality resume normal operation. This issue also occurred in previous versions.

I'm not sure what the problem is, but it is indeed rather peculiar.

https://github.com/user-attachments/assets/12716937-f93f-49cb-bdf4-d8c74fd03b00

e3e0261f avatar Jan 12 '26 12:01 e3e0261f

@e3e0261f Thank you for providing the detailed feedback and video. The clarity of the video indeed affects our ability to analyze the issue, so we recommend you try the following methods to record a clearer video:

  1. Use screen recording software (such as OBS Studio or Shutter Encoder) to record the process.

  2. Ensure the recording includes the complete steps of the operation, from completely closing the app to when the issue occurs.

Please try recording a clearer video and resubmitting it so that we can diagnose the problem more accurately。

And continue to provide the updated log files so that we can further analyze the problem.

Thank you again for your patience and assistance!

gonewx avatar Jan 12 '26 22:01 gonewx

Thanks @gonewx

  • This video demonstrates node activation failures within the audio system under the PipeWire architecture. When the Easy Effects processing chain is enabled, the WirePlumber session manager's routing policy may enter a suspended state. This prevents applications such as Nextalk, which rely on audio input, from correctly acquiring mount points.
  • At this point, Helvum fails to display an active node topology. Launching pavucontrol triggers an asynchronous query on the pipewire-pulse interface, forcibly awakening the physical sink device from its Suspended state.
  • Nextalk's failure stems from its calls to ALSA devices being mismatched with the current state of PipeWire's virtualised devices. Intervention via graphical tools forces a refresh of the audio server's node graph, thereby resolving the device occupancy conflict.
  • Under specific load conditions, the PipeWire session manager's trigger mechanism has proven ineffective.

https://github.com/e3e0261f/videos/blob/main/input.mp4

e3e0261f avatar Jan 13 '26 07:01 e3e0261f

Hi @e3e0261f ,

Thank you for the detailed analysis of the PipeWire node activation issue. Based on your description, we've implemented a potential fix. Please download and install the latest release version, then run the application again.

Root Cause Analysis

When Easy Effects or similar audio processing chains are enabled, WirePlumber's routing policy may enter a suspended state. Applications querying audio devices via the PulseAudio compatibility layer (pipewire-pulse) may receive incomplete results because the underlying PipeWire nodes haven't been activated.

The Fix

We modified the device enumeration logic in libpulse_ffi.dart to use a two-phase query approach:

Before: connect → get_source_info_list → done After: connect → get_sink_info_list (warmup) → get_source_info_list → done

By querying the sink (output device) list first, we trigger PipeWire to activate its nodes before enumerating input sources. This mimics the behavior of tools like pavucontrol that successfully wake up suspended nodes.

Important Disclaimer

I must be transparent with you:

  1. Limited expertise: My knowledge of complex audio subsystems (PipeWire/WirePlumber/PulseAudio interactions) is limited, so I consulted AI assistance to analyze and implement this fix.
  2. Untested environment: We don't have access to a complex audio setup with Easy Effects + PipeWire + WirePlumber in suspended state, so we cannot accurately reproduce your exact scenario.
  3. Experimental fix: This solution is based on PipeWire documentation and theoretical analysis. It may not fully resolve your issue.

Additional Information Needed

To help us better understand and diagnose this issue, could you please run the following commands and share the output?

echo "=== Desktop ===" && echo $XDG_CURRENT_DESKTOP
echo "=== OS ===" && cat /etc/os-release | grep -E "^(NAME|VERSION)="
echo "=== PipeWire ===" && pipewire --version
echo "=== WirePlumber ===" && which wireplumber && ls -la $(which wireplumber)
echo "=== Node Status ===" && wpctl status

We've observed some unexpected behavior during our investigation, and knowing your specific desktop configuration would help us narrow down the root cause.

Request for Feedback

If you're willing to test a development build with this fix, please let us know. Your feedback would be invaluable in determining whether this approach works or if further investigation is needed.

Thank you for your patience and detailed bug report.

gonewx avatar Jan 13 '26 09:01 gonewx

@gonewx Thank you for your patience in assisting me with my issue. I am also very keen to contribute to the improvement of the Nextalk project, as I have long been seeking a reliable Linux voice input solution. Here is the specific information you requested:

❯ echo "=== Desktop ===" && echo $XDG_CURRENT_DESKTOP
  echo "=== OS ===" && cat /etc/os-release | grep -E "^(NAME|VERSION)="
  echo "=== PipeWire ===" && pipewire --version
  echo "=== WirePlumber ===" && which wireplumber && ls -la $(which wireplumber)
  echo "=== Node Status ===" && wpctl status
=== Desktop ===
KDE
=== OS ===
NAME="Debian GNU/Linux"
VERSION="13 (trixie)"
=== PipeWire ===
pipewire
Compiled with libpipewire 1.4.2
Linked with libpipewire 1.4.2
=== WirePlumber ===
/usr/bin/wireplumber
.rwxr-xr-x 19k root 19 4月   2025 /usr/bin/wireplumber
=== Node Status ===
PipeWire 'pipewire-0' [1.4.2, lee@DEGNU, cookie:221826822]
 └─ Clients:
        33. WirePlumber                         [1.4.2, lee@DEGNU, pid:3377]
        34. pipewire                            [1.4.2, lee@DEGNU, pid:3380]
        47. WirePlumber [export]                [1.4.2, lee@DEGNU, pid:3377]
        84. kwin_wayland                        [1.4.2, lee@DEGNU, pid:3972]
        85. libcanberra                         [1.4.2, lee@DEGNU, pid:4142]
        86.                                     [1.4.2, lee@DEGNU, pid:4142]
        87. xdg-desktop-portal                  [1.4.2, lee@DEGNU, pid:3985]
        88. libcanberra                         [1.4.2, lee@DEGNU, pid:4222]
       127. wpctl                               [1.4.2, lee@DEGNU, pid:1727896]
       156.                                     [1.4.2, lee@DEGNU, pid:4222]
       158. coppwr                              [1.4.7, lee@DEGNU, pid:2]
       185.                                     [1.4.2, lee@DEGNU, pid:4313]
       188. pw-loopback                         [1.4.2, lee@DEGNU, pid:889372]
       212. easyeffects                         [1.4.8, lee@DEGNU, pid:2]
       240. KWin                                [1.4.2, lee@DEGNU, pid:3972]
       265. speech-dispatcher-dummy             [1.4.2, lee@DEGNU, pid:43834]
       319. PipeWire ALSA [nextalk]             [1.4.2, lee@DEGNU, pid:1717286]

Audio
 ├─ Devices:
 │      48. Navi 10 HDMI Audio                  [alsa]
 │      49. Built-in Audio                      [alsa]
 │      50. Steinberg CI1                       [alsa]
 │
 ├─ Sinks:
 │  *   57. Built-in Audio Pro                  [vol: 1.05]
 │      58. Built-in Audio Pro 1                [vol: 1.00]
 │      94. Easy Effects Sink                   [vol: 1.00 MUTED]
 │
 ├─ Sources:
 │      59. Built-in Audio Pro                  [vol: 1.00]
 │      60. Built-in Audio Pro 2                [vol: 1.00]
 │     271. Easy Effects Source                 [vol: 1.00]
 │
 ├─ Filters:
 │    - pro-audio-2
 │      35. alsa_output.usb-Yamaha_Corporation_Steinberg_CI1-01.pro-output-0 [Audio/Sink]
 │  *   46. alsa_input.usb-Yamaha_Corporation_Steinberg_CI1-01.pro-input-0 [Audio/Source]
 │    - loopback-889372-20
 │     135. input.pw-loopback-889372                                     [Stream/Input/Audio]
 │     161. output.pw-loopback-889372                                    [Stream/Output/Audio]
 │
 └─ Streams:
        91. speech-dispatcher-dummy
            210. output_FL       > :input_FL	[init]
            272. output_FR       > :input_FR	[init]
       124. PipeWire ALSA [nextalk]
            280. monitor_FL
            286. input_FL        < Easy Effects Source:capture_FL	[paused]
            287. input_FR        < Easy Effects Source:capture_FR	[paused]
            338. monitor_FR
       134.
            138. input_FL        < speech-dispatcher-dummy:output_FL	[init]
            150. monitor_FL
            151. monitor_FR
            166. input_FR        < speech-dispatcher-dummy:output_FR	[init]

Video
 ├─ Devices:
 │
 ├─ Sinks:
 │
 ├─ Sources:
 │
 ├─ Filters:
 │
 └─ Streams:

Settings
 └─ Default Configured Devices:
         0. Audio/Sink    alsa_output.pci-0000_00_1b.0.pro-output-0
         1. Audio/Source  alsa_input.usb-Yamaha_Corporation_Steinberg_CI1-01.pro-input-0

e3e0261f avatar Jan 13 '26 10:01 e3e0261f

Can the new version work properly?

gonewx avatar Jan 13 '26 10:01 gonewx

@gonewx Version 0.2.6 still requires pavucontrol to be run first for Nextalk to function correctly.

Nextalk requires debug mode to view specific error logs.


[AudioCapture] ⚠️ Failed to open audio stream: -9997 (invalid sample rate)
[AudioCapture] 📋 Device information: ‘HDA Intel PCH: ALC1150 Analog (hw:0,0)’, maxInputChannels=2, defaultSampleRate=44100.0
[AudioCapture] 💡 Possible causes: 1) PulseAudio/PipeWire not running 2) Device occupied 3) Insufficient permissions
  • Stronger Warmup: The current activation mechanism triggered via contextGetSinkInfoList may prove insufficiently robust. It is recommended to establish a brief silent monitoring stream prior to enumeration. This approach typically proves more effective at waking PipeWire nodes than merely querying the list.

  • Adjust main loop waiting strategy: In libpulse_ffi.dart, the current while loop combined with iterations < 1000 constitutes ‘blind waiting’. It is recommended to adopt an event-driven (Callback) mechanism, as seen in pavucontrol, to confirm the Context is fully ready before retrieving the source list upon receiving a change signal.

  • Addressing delayed loading: Observations indicate that Nextalk functions normally after launching pavucontrol, suggesting the issue lies within WirePlumber's node suspension strategy. Consider sending the PA_CONTEXT_AUTHORITATIVE flag during FFI initialisation, or introducing a 100-200ms usleep (at the C layer) before requesting the source list to allow hardware startup time.

  • During initial connection attempts, Discord performs extended ‘probing’ operations and automatically retries connections upon detecting no input.

  • I resolved this issue in my local environment by setting session.suspend-on-idle to false in the WirePlumber configuration file.

e3e0261f avatar Jan 13 '26 10:01 e3e0261f

@e3e0261f

Thank you for the detailed technical analysis and patient collaboration! We've released v0.2.8 with a potential fix for this issue.

What We Changed

  1. libpulse-simple Recording Integration (Primary Change)

    • Replaced PortAudio with libpulse-simple for audio recording
    • This provides automatic sample rate conversion (hardware 44100Hz → app 16000Hz)
    • Direct PulseAudio/PipeWire device specification without going through ALSA
  2. Smart Default Device Selection

    • Filtered out raw ALSA hardware devices (hw:0,0, plughw:0,0)
    • Now prefers PipeWire/PulseAudio virtual devices

Why This Might Help

Based on your error log:

Device: 'HDA Intel PCH: ALC1150 Analog (hw:0,0)', defaultSampleRate=44100.0
Error: -9997 (invalid sample rate)

PortAudio was selecting the raw ALSA device which doesn't support sample rate conversion. By using libpulse-simple, we leverage PulseAudio/PipeWire's built-in resampling (similar to how Discord handles this).

Important Disclaimer

As mentioned before, we don't have access to a complex audio setup with EasyEffects + PipeWire + WirePlumber, so we cannot accurately reproduce your exact scenario. This fix is based on theoretical analysis and may not fully resolve your issue.

Please Test

Please download v0.2.8 and test with your EasyEffects setup. Your feedback would be invaluable in determining whether this approach works.

Thank you again for your patience and detailed bug reports!

gonewx avatar Jan 13 '26 13:01 gonewx

@gonewx

Many thanks to all developers for the v0.2.8 update, which runs exceptionally well on my computer. Firstly, I did not set session.suspend-on-idle = false and restarted the system.

`/etc/config/wireplumber/wireplumber.conf.d`
❯ ls
51-disable-suspension.conf.1
  • Whether Easyeffects is enabled or disabled, it does not affect Nextalk's voice capture functionality.
  • I have recorded the operational process. The current version is now fully functional. Many thanks to @gonewx for his active development efforts.

https://github.com/user-attachments/assets/eb772121-9515-44fa-a0de-845d0e109f59


❯ nextalk
Gdk-Message: 09:54:59.579: Unable to load  from the cursor theme
[SingleInstance] ✅ 主实例启动: /run/user/1000/nextalk.sock
[WindowService] Flutter window backend initialized
LanguageService: 使用已保存的语言: zh
method call InitSystemTray

(com.gonewx.nextalk:21354): libayatana-appindicator-WARNING **: 09:54:59.683: libayatana-appindicator is deprecated. Please use libayatana-appindicator-glib in newly written code.
SystemTray::set_system_tray_info title: , icon_path: /opt/nextalk/data/flutter_assets/assets/icons/tray_icon.png, toolTip: Nextalk
[TrayService._buildMenu] actualEngine=EngineType.sensevoice, modelType=ModelType.standard
[TrayService._buildMenu] zipInt8=false, zipStd=false, sense=true
[AudioDeviceService] 📋 开始枚举音频设备...
[AudioDeviceService] 🔍 尝试 libpulse 枚举...
[AudioDeviceService] 📋 libpulse 发现 6 个 source:
[AudioDeviceService]   - "alsa_output.pci-0000_00_1b.0.pro-output-0.monitor" (monitor,跳过)
[AudioDeviceService]   - "alsa_output.pci-0000_00_1b.0.pro-output-1.monitor" (monitor,跳过)
[AudioDeviceService]   ✓ "alsa_input.pci-0000_00_1b.0.pro-input-0" -> "Built-in Audio Pro"
[AudioDeviceService]   ✓ "alsa_input.pci-0000_00_1b.0.pro-input-2" -> "Built-in Audio Pro 2"
[AudioDeviceService]   - "alsa_output.usb-Yamaha_Corporation_Steinberg_CI1-01.pro-output-0.monitor" (monitor,跳过)
[AudioDeviceService]   ✓ "alsa_input.usb-Yamaha_Corporation_Steinberg_CI1-01.pro-input-0" -> "Steinberg CI1 Pro"
[AudioDeviceService] ✓ 使用 libpulse 枚举 (3 个设备)
method call CreateContextMenu
value_to_menu_item type:label, label:Nextalk
value_to_menu_item type:label, label:显示 / 隐藏
value_to_menu_item type:label, label:重新连接 Fcitx5
value_to_menu_item type:submenu, label:模型设置
value_to_menu_item type:submenu, label:Zipformer (流式)
value_to_menu_item type:label, label:int8 模型 (更快)
value_to_menu_item type:label, label:标准模型 (更准)
value_to_menu_item type:label, label:● SenseVoice (离线)
value_to_menu_item type:submenu, label:语言 / Language
value_to_menu_item type:label, label:● 简体中文
value_to_menu_item type:label, label:English
value_to_menu_item type:submenu, label:音频输入设备
value_to_menu_item type:label, label:● 系统默认
value_to_menu_item type:label, label:Built-in Audio Pro
value_to_menu_item type:label, label:Built-in Audio Pro 2
value_to_menu_item type:label, label:Steinberg CI1 Pro
value_to_menu_item type:label, label:设置
value_to_menu_item type:label, label:退出
method call SetContextMenu
[HotkeyService] 从配置文件加载快捷键: altRight + []
[HotkeyService] ✅ 配置加载完成: Right Alt
[AudioCapture] 开始预热音频设备...
[AudioCapture] 📋 配置的设备: default
[AudioCapture] 🔍 尝试使用 libpulse-simple...
[PulseAudioCapture] 📋 初始化 libpulse-simple...
[PulseAudioCapture] 📋 连接设备: default
[PulseAudioCapture] ✓ 初始化成功
[AudioCapture] ✅ 使用 libpulse-simple 预热成功
[EngineInitializer] 尝试初始化配置的引擎: EngineType.sensevoice
[EngineInitializer] ✓ 配置的引擎初始化成功: EngineType.sensevoice
SettingsService: 实际引擎类型已设置为 EngineType.sensevoice
[SherpaFFI] ✅ 库加载成功: /opt/nextalk/lib/libsherpa-onnx-c-api.so
[HotkeyController] ✅ 控制器初始化完成
[SingleInstance] 收到连接
[SingleInstance] 收到命令: toggle
[HotkeyController] 快捷键按下,当前状态: HotkeyState.idle
[PulseAudioCapture] ▶️ 开始录音
[HotkeyController] 🎤 开始录音
[HotkeyController] 🔔 VAD 端点: isVad=true, text="一。", duration=4061ms, deviceLost=false
[SingleInstance] 收到连接
[SingleInstance] 收到命令: toggle
[HotkeyController] 快捷键按下,当前状态: HotkeyState.recording
[PulseAudioCapture] ⏹️ 停止录音
[HotkeyController] 🔔 VAD 端点: isVad=false, text="一。", duration=5123ms, deviceLost=false
[HotkeyController] 📝 最终文本: "一。"
[HotkeyController] 📋 Fcitx5 不可用,使用剪贴板模式
[HotkeyController] 📋 文本已复制到剪贴板: "一。"

e3e0261f avatar Jan 14 '26 02:01 e3e0261f

I'm thrilled to hear that v0.2.8 is working exceptionally well on your system! Thank you so much for your patient collaboration and the technical insights you provided—they were instrumental in helping us implement the right fix.

I'll go ahead and close this issue now. If you encounter any new problems or have further suggestions, please don't hesitate to open a new issue. Happy talking!

gonewx avatar Jan 14 '26 02:01 gonewx