Skip to content

[FEATURE]: Speech to Text Userscript #11

@bittricky

Description

@bittricky

Implement Speech-to-Text

Description

Enhance the userscript by providing reliable speech-to-text functionality with proper network error handling. The script should allow users to input text via speech in any text input field or textarea on web pages. It must also handle various errors gracefully, including network issues, no speech detection, and browser support limitations.

Acceptance Criteria

  • Detect and initialize the appropriate SpeechRecognition API (webkitSpeechRecognition or SpeechRecognition).
  • Display a microphone button next to applicable input fields (input[type="text"], input[type="search"], textarea).
  • Capture speech and insert the transcribed text into the focused input field at the cursor position.
  • Provide visual feedback when:
    • Listening starts.
    • Text is captured.
    • Errors occur (e.g., network failure, no speech detected, microphone access denied).
  • Implement retry logic for network errors:
    • Retry up to 3 times with a 1-second delay.
    • If retries fail, display an appropriate message.
  • Handle other common errors:
    • No speech detected → Display a message and stop listening.
    • Microphone access denied → Inform the user to enable permissions.
    • Audio capture error → Notify if no microphone is detected.
    • Aborted recording → Provide relevant feedback.
  • Ensure compatibility with dynamically loaded content:
    • Observe the DOM and attach buttons to new input fields when added.
  • Optimize UI elements:
    • Ensure the microphone button does not interfere with user input.
    • Provide a smooth transition for feedback messages.

Implementation Notes

  • The script should gracefully degrade if speech recognition is unsupported in the browser.
  • Avoid excessive re-initialization to maintain performance.
  • Ensure the UI elements (button and feedback messages) are visually non-intrusive but accessible.

JavaScript APIs

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew functionality or capability

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions