Skip to main content

Speech to text

Use speech to text with HDVoiceMessage. Before requesting transcription, check whether the feature is enabled for your app:

Dart
final settings = await NCEngine.getAppSettings();
print('Speech to text enabled: ${settings?.speechToTextEnable}');

Request speech-to-text conversion

Call requestSpeechToText() on an HDVoiceMessage that has already been sent or received.

Method

Dart
Future<int> requestSpeechToText(ErrorHandler handler)

Code example

Dart
final message = receivedMessage as HDVoiceMessage;
await message.requestSpeechToText((error) {
if (error?.isSuccess == true) {
print('Speech-to-text requested');
}
});

Control transcription visibility

Call setSpeechToTextVisible() to control whether the transcription result is visible.

Method

Dart
Future<int> setSpeechToTextVisible(bool visible, ErrorHandler handler)

Parameters

ParameterTypeDescription
visibleboolWhether the speech-to-text result is visible.
handlerErrorHandlerCallback that receives the final result.

Code example

Dart
final message = receivedMessage as HDVoiceMessage;
await message.setSpeechToTextVisible(true, (error) {
if (error?.isSuccess == true) {
print('Speech-to-text visibility updated');
}
});
note

Both methods return Future<int>, which is the immediate operation ID. Use the callback to determine whether the request succeeded.