Skip to content

speech_to_text silently fails on Windows if no audio input device available #653

@josh2112

Description

@josh2112

I came across an error when testing this package on Windows 11: Failed to activate dictation. HRESULT: 80070490

After some debugging, I realized I had no webcam or headset plugged in. When an audio input device is available the package works great.

Is it possible to catch this error during initialization and report it back in the error callback? Right now no callacks are called -- no status, no error -- so in the app I have no way to detect that an error happened. The only indication is the HRESULT printed to the console:

Launching lib\main.dart on Windows in debug mode...
√ Built build\windows\x64\runner\Debug\test_local_xlate.exe
SpeechToTextWindowsPlugin created
Connecting to VM Service at ws://127.0.0.1:53489/017PVrypOdg=/ws
Connected to the VM Service.
Method called: initialize
Initializing SAPI speech recognition...
SAPI speech recognition initialized successfully!
Method called: locales
Method called: listen
Starting speech recognition...
Failed to activate dictation. HRESULT: 80070490

Output of flutter doctor -v:

[√] Flutter (Channel stable, 3.38.9, on Microsoft Windows [Version 10.0.22631.6199], locale en-US) [598ms]
    • Flutter version 3.38.9 on channel stable at D:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 67323de285 (3 weeks ago), 2026-01-28 13:43:12 -0800
    • Engine revision 587c18f873
    • Dart version 3.10.8
    • DevTools version 2.51.1
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
      omit-legacy-version-file, enable-lldb-debugging

[√] Windows Version (11 Pro 64-bit, 23H2, 2009) [5.1s]

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [4.7s]
    • Android SDK at C:\Users\jf334.CEM\AppData\Local\Android\sdk
    • Emulator version 35.1.20.0 (build_id 12234392) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • Java binary at: D:\Program Files\Android\Android Studio\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
    • All Android licenses accepted.

[√] Chrome - develop for the web [123ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Professional 2022 17.14.24) [121ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Professional
    • Visual Studio Professional 2022 version 17.14.36908.2
    • Windows 10 SDK version 10.0.26100.0

[√] Connected device (3 available) [400ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22631.6199]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 143.0.7499.193
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 144.0.3719.115

[√] Network resources [415ms]
    • All expected network resources are available.

• No issues found!

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions