目录

class info
com.huawei.hms.mlsdk.aft.cloud.MLRemoteAftEngine
Audio transcription engine on the cloud.

Public Method Summary

Return typeMethod name
voidclose()
MLRemoteAftEnginegetInstance()
voidinit(android.content.Context context)
voidsetAftListener(MLRemoteAftListener listener)
StringshortRecognize(android.net.Uri uri, MLRemoteAftSetting setting)

Public Methods

Method
public void close()
Disables the audio transcription engine to release engine resources.
Method
public static MLRemoteAftEngine getInstance()
Obtains an audio transcription engine instance on the cloud.

Parameters

Parameter nameParameter desc
MLRemoteAftEngineAudio transcription engine instance on the cloud.
Method
public void init(android.content.Context context)
Initializes the audio transcription engine on the cloud and loads engine resources.

Parameters

Parameter nameParameter desc
contextContext.
Method
public void setAftListener(MLRemoteAftListener listener)
Sets the audio transcription listener on the cloud.

Parameters

Parameter nameParameter desc
listenerAudio transcription listener instance on the cloud.
Method
public String shortRecognize(android.net.Uri uri, MLRemoteAftSetting setting)
Converts a short audio file on the cloud.

Parameters

Parameter nameParameter desc
uriAudio file URI. Only local audio files are supported. The value can start with content:// or file://.
settingAudio transcription settings on the cloud.


Return

Typedesc
StringID of the audio transcription task.

Sample Code

  1. MLRemoteAftEngine engine = MLRemoteAftEngine.getInstance();
  2. // Initialize the engine and pass the current context.
  3. engine.init(this);
  4. MLRemoteAftSetting setting = new MLRemoteAftSetting.Factory()
  5. .setLanguageCode("zh")
  6. .create();
  7. // Pass the listener callback (aftListener) to the audio transcription engine.
  8. engine.setAftListener(aftListener);