Browse SDKs · uni-app / uni-app x
Platform
SDKsuni-app / uni-app xEnterprise

Check speech-to-text availability

Query supported audio formats, sample rates, and limits for the speech-to-text engine.

Copy

Speech-to-text transcription is a Commercial Edition capability. Prior to exposing a transcription button or capturing audio for transcription, invoke getSpeechToTextCapabilities() to query the formats and size limits supported by the backend speech service. This method accepts no parameters.

Code example

import { getSpeechToTextCapabilities } from '@/uni_modules/unix-openim-sdk'

const capabilities = await getSpeechToTextCapabilities()

if (capabilities == null) {
  disableSpeechToText()
}

Return value

The Promise resolves with an OpenIMSpeechToTextCapabilitiesResult | null object:

FieldTypeDescription
formatstring[] | nullAudio container and codec formats supported by the service (for example, ['m4a', 'wav']).
sampleRateHznumber[] | nullList of supported sample rates in Hertz.
maxRecordTimeMsnumber | nullMaximum allowable recording duration in milliseconds.
maxFileSizenumber | nullMaximum audio file size in bytes.
providerstring | nullActive transcription provider identifier.
requestTypestring | nullProtocol request type used by the transcription engine.
crossDomainboolean | nullWhether the provider supports cross-domain requests.

All fields are optional in the public type declarations. Validate only those restrictions explicitly returned by the server. When the call returns null, fails, or lacks critical capabilities, hide or disable the transcription entry point rather than guessing support boundaries.

State changes after the call

This call is a read-only capability query and does not record audio, transcribe speech, or emit message events.