bricks/dist/docs/en/streaming_audio.md
yumoqing 2e22085122 feat: 401后登录成功自动重试原始请求
- withLoginInfo 改为接收完整 opts(含 method/headers/params)
- 等待 login_window 的 destroy 事件(=登录成功信号)
- 登录成功后重试原始请求
- 重试仍401则返回null(避免死循环)
- 用户手动关闭登录窗口时也触发重试,401则返回null
2026-05-27 15:39:34 +08:00

1.9 KiB

StreamAudio

Widget Functionality: Implements real-time audio stream capture, voice activity detection (VAD) triggering, audio upload, and receiving recognized text results returned from the server. Commonly used in speech recognition scenarios.
Type: Container widget
Parent Widget: bricks.VBox

Initialization Parameters

  • opts {Object} - Configuration options object, inherited from VBox, with the following extended properties:
    • name {string} (Optional) - Widget name; defaults to 'asr_text'.
    • height {string} - Fixed height of '100%'; cannot be overridden.
    • Other general parameters supported by VBox (e.g., layout, etc.).

Note

: The constructor automatically sets height='100%' and the default name, and creates internal child widgets (button, spacers, text display, etc.).

Main Events

No custom events are directly exposed externally; however, the following behaviors are handled via binding and callback mechanisms:

  • Button Click Event: A click event is bound to the internal this.button, which triggers the toggle_status() method to start or stop audio stream capture.
  • Speech End Event: Triggered by the onSpeechEnd(audio) callback from vad.MicVAD, which calls handle_audio(audio) to encode and send the audio data.
  • Data Reception Event: In receive_data(), the method continuously reads responses from the server stream using reader.readline(). Each received JSON message updates the displayed text.

ASRText

Widget Functionality: Identical to StreamAudio. It serves as an alias widget, providing a more semantic representation of the speech recognition text output component.
Type: Container widget
Parent Widget: bricks.VBox (inherits the same actual hierarchy as StreamAudio)

Initialization Parameters

Same as StreamAudio.

Main Events

Same as StreamAudio.