Skip to content

Speech & feedback ​

Speak a piece of text on its own (without captions), show a toast to the user, hide a window from screen recording / screen sharing.


Speak (standalone TTS) ​

python
host.speak(text: str, voice: str | None = None, language: str | None = None) -> bool
host.stop_speak() -> bool
host.is_speaking() -> bool
  • No captions — it only synthesises and plays; a failure returns False (no exception).
  • When voice / language is omitted, the current TTS engine's default voice / target language is used.
  • stop_speak() interrupts the current lightweight speak queue.
  • For "translation + caption + speak" as one unit, use feed_direct_caption(..., tts=True) — do not combine speak() + feed().

UI feedback ​

python
host.show_toast(message: str, level: str = "info", timeout_ms: int = 2500) -> bool
host.show_error(message: str, source: str = "plugin") -> bool
  • show_toast: level ∈ info | success | warning | error; goes through the host's unified toast channel. Good for light hints such as "switching device" or "voice registered".
  • show_error: writes to the host's errorOccurred channel (the same UI as built-in errors); for genuine errors.
  • Both are signals into the UI and can be called from any thread.
  • User-facing copy must speak plainly (do not expose internal exception stacks); stacks belong in host.log("error", ...).

Anti screen-recording / anti screen-sharing ​

python
host.set_window_excluded_from_capture(window: Any, exclude: bool = True) -> bool
  • On Windows it uses SetWindowDisplayAffinity(0x00000011): the window becomes completely invisible in screen sharing on Tencent Meeting / Zoom / Teams and the like.
  • Returns False on non-Windows platforms.
  • Pass the QML-side window instance as window: bridge.setWindowExcludedFromCapture(this, true).

Copilot window control ​

python
host.set_copilot_visible(visible: bool) -> bool
host.toggle_copilot_window() -> bool

Only meaningful when the plugin mounts the copilot_window slot or is itself an assistant type plugin; other plugins can ignore it.


Usage recommendations ​

NeedUse
Speak the translation after a text selectionhost.speak(translation)
Speak the translation + show captions at the same timehost.feed_direct_caption(text, tts=True)
Interrupt the current speakhost.stop_speak()
Light hint (1–3 seconds)host.show_toast("…", level="info")
A genuine errorhost.show_error("human-readable reason", source=self.id)
Anti-peeking for an interview assistantbridge.setWindowExcludedFromCapture(this, true)

TransBox — empowering borderless cross-language communication for everyone