When valueField/textField are not explicitly set in opts, the auto-select logic (line 1140) and nullable empty-option creation (lines 1144-1145) used data[0][undefined] which returned undefined, causing: - Single-option selects to show blank (auto-select failed) - nullable empty options to have undefined keys Now extracts vf/tf local variables with ||'value'/||'text' fallback at the top of build_options(), used consistently throughout.
1.8 KiB
ASRClient
Widget Functionality: Implements a speech recognition client that communicates with the server via WebSocket, sending audio data in real-time and receiving transcription results. Provides interactive buttons to start/stop recording and triggers corresponding events.
Type: Standard Widget
Parent Widget: bricks.VBox
Initialization Parameters
-
start_icon(String, optional)
Icon path displayed when in the recording-start state. Default isimgs/start_recording.svg. -
stop_icon(String, optional)
Icon path displayed when in the recording-stop state. Default isimgs/stop_recording.svg. -
ws_url(String, required)
WebSocket server address used to establish a connection with the speech recognition backend. -
icon_options(Object, optional)
Configuration options for the icon widget, passed directly to thebricks.Svginstance, allowing customization of icon appearance. -
ws_params(Object, optional)
Additional parameters sent to the WebSocket server, merged and included when transmitting audio data.
Main Events
-
start
Triggered when: The user clicks the icon to begin recording.
Parameters: None -
stop
Triggered when: The user clicks the icon to stop recording.
Parameters: None -
transtext
Triggered when: A speech recognition result is received from the server.
Parameters:{ "content": "Transcribed text content", "speaker": "Speaker identifier (if supported)", "start": "Timestamp indicating the start of the audio segment", "end": "Timestamp indicating the end of the audio segment" }Note: This event is dispatched after the
response_datamethod parses the server message, enabling higher-level components to handle the recognition result.