Speech input

Updated at:

Introduction

Use the speech input component to capture audio from users.

image

Configuration items

Category

Configuration

Example

Description

Content

Text

The text that the component displays in the stop state. This can be left empty.

Status

The state of the component. Valid values are stop, recording, and processing. If this is empty, the component controls its own state.

  • stop: The component is stopped. It displays custom text and an icon.

  • recording: The component is recording. It displays the recording icon.

  • processing: The component is processing. It displays the loading icon.

Interaction mode

The method for starting a recording. If you select "External control", the component is hidden. Recording can only be started and stopped using the component API.

Speech upload

If enabled, the component automatically uploads the audio file in WebM format to the selected storage path. The URL of the audio file is then saved to the remoteURL property of the component.

Speech storage path

This is required when Speech upload is enabled. Specify the storage path for the audio file.

Extension configuration

The prefix and suffix icons for the component. To display only an icon, leave the text empty and set the prefix or suffix icon.

Interaction

Hidden

Hides the component. For more information, see Common properties.

Style

Height

The height of the component. For more information, see Common properties.

Margin

The margin of the component. For more information, see Common properties.

CSS style

Border radius

The border radius of the component.

Font size

The size of the component's text and icon.

Background color

The background color of the component.

Text color

The color of the component's text and icon.

Active background color

The background color of the component in its active state.

Active text color

The color of the component's text and icon in its active state.

Hover background color

The background color of the component in its hover state.

Hover text color

The color of the component's text and icon in its hover state.

Properties

Name

Type

Example

Description

audioFile

File/MobiFile

audioInput.audioFile

If speech upload is disabled, audioFile is a File object that contains the speech input result. If speech upload is enabled, audioFile is a MobiFile object.

audioURL

string

audioInput.audioURL

The base64 URL of the speech input result.

remoteURL

string

audioInput.remoteURL

This property has a value only when speech upload is enabled. The value is the URL of the uploaded audio file.

status

string

audioInput.status

The internal state of the component.

  • stop: The component is stopped and is not recording.

  • recording: The component is recording.

  • processing: The component is processing, such as during an upload.

uploadMode

string

audioInput.uploadMode

The upload mode. Valid values are 'none' and 'system'.

hidden

boolean

audioInput.hidden

Indicates whether the component is hidden.

Event callbacks

Configuration

Description

An event that triggers before a recording is requested. If this event is set to execute a script and the script returns false, the recording is not requested.

An event that triggers after recording starts.

An event that triggers when recording fails to start. For example, this occurs if the user has not granted access to the microphone.

An event that triggers after recording stops.

An event that triggers after a successful upload. This is effective only when Speech upload is set to "Upload to system file storage".

An event that triggers after a failed upload. This is effective only when Speech upload is set to "Upload to system file storage".

The events are executed in the following order:

  1. Before requesting to record

  2. Recording started / Recording start failed

  3. Recording stopped

  4. Upload successful / Upload failed