convertVoiceToText method

Future<V2TimValueCallback<String>> convertVoiceToText({
  1. required String msgID,
  2. required String language,
  3. String? webMessageInstance,
})

Implementation

Future<V2TimValueCallback<String>> convertVoiceToText({
  required String msgID,
  required String language, // "zh (cmn-Hans-CN)" "yue-Hant-HK" "en-US" "ja-JP",
  String? webMessageInstance,
}) async {
  try {
    final res = await wrappedPromiseToFuture(
      timeweb!.convertVoiceToText(
        mapToJSObj(
          {
            "message": parse(webMessageInstance ?? ""),
            "language": language,
          },
        ),
      ),
    );
    if (res.code == 0) {
      final text = jsToMap(res.data)['result'];
      return CommonUtils.returnSuccess<String>(text);
    }
    return CommonUtils.returnSuccess<String>("");
  } catch (error) {
    return CommonUtils.returnErrorForValueCb(error.toString());
  }
}