bricks/dist/docs/en/webspeech.md
yumoqing 1291f7fee3 fix: UiCode build_options uses valueField/textField fallback to 'value'/'text'
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.
2026-05-29 23:03:52 +08:00

40 lines
1.8 KiB
Markdown

# WebTTS
**Widget Functionality**: Implements browser-based Text-to-Speech (TTS) functionality, supporting multiple languages, pitch, and speech rate settings, along with event callbacks during the speech synthesis process.
**Type**: Container widget
**Parent Widget**: bricks.VBox
## Initialization Parameters
- `opts`: Inherits initialization parameters from `bricks.VBox`, used to configure layout and basic properties.
- Supports all common configuration options of a VBox container (such as styles, child widgets, etc.).
## Main Events
No custom events are triggered; however, the following speech synthesis events are internally used for status monitoring:
- `onstart`: Logs a message when speech synthesis begins.
- `onend`: Logs a message when speech synthesis ends.
- `onerror`: Outputs error information if speech synthesis fails.
> Note: This widget performs speech playback by calling the `speak(text)` method and does not rely on external event binding mechanisms to trigger UI changes.
---
# WebASR
**Widget Functionality**: Implements browser-based Speech Recognition functionality, converting user's spoken input into text content and dispatching recognition results via events.
**Type**: Container widget
**Parent Widget**: bricks.VBox
## Initialization Parameters
- `opts`: Inherits initialization parameters from `bricks.VBox`, used to configure layout and basic properties.
- Supports all common configuration options of a VBox container.
## Main Events
- `asr_result`: Triggered when speech recognition successfully returns a result, carrying the recognized text content.
- Data format: `{ content: string }`
- Example: `{ content: "Hello World" }`
> Note: Requires browser support for the `SpeechRecognition` API; otherwise, a "not supported" message will be logged.