正在查看: Petal Maps v4.7.0.310001 应用的 VoiceCloneCloudTtsImpl.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Petal Maps v4.7.0.310001 应用的 VoiceCloneCloudTtsImpl.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.huawei.hiai.tts.impl;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
import com.huawei.hiai.pdk.unifiedaccess.HttpConfig;
import com.huawei.hiai.tts.HandlerThreadImpl;
import com.huawei.hiai.tts.constants.BaseConstants;
import com.huawei.hiai.tts.constants.ErrorCode;
import com.huawei.hiai.tts.constants.ParamsVerify;
import com.huawei.hiai.tts.impl.VoiceCloneCloudTtsImpl;
import com.huawei.hiai.tts.network.AsClient;
import com.huawei.hiai.tts.utils.GsonUtil;
import com.huawei.hiai.tts.utils.TLog;
import com.huawei.hiassistant.platform.base.fullduplex.FullDuplex;
import com.huawei.tts.voiceclone.interfaces.IHwTTsModelCallback;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
public class VoiceCloneCloudTtsImpl {
private static final int INVALID_TEXT_IDX = -1;
private static final String REQUEST_ID = "requestId";
private static final String SYNTHESIS_MODEL_LOAD = "synthesisModelLoad";
private static final String SYNTHESIS_MODEL_UNLOAD = "synthesisModelUnload";
private static final String TAG = "VoiceCloneCloudTtsImpl";
private static final int THREAD_PRIORITY = -20;
private static final String TRAIN_ENHANCED_COMMIT = "trainEnhancedCommit";
private static final String TRAIN_MODEL_DELETE = "trainModelDelete";
private static final String TRAIN_MODEL_GET_CORPUS = "trainModelGetCorpus";
private static final String TRAIN_MODEL_INVITE = "trainModelInvite";
private static final String TRAIN_MODEL_QUERY = "trainModelQuery";
private static final String TRAIN_MODEL_QUERY_V2 = "trainModelQueryV2";
private static final String TRAIN_MODEL_UPDATE = "trainModelUpdate";
private static final String TRAIN_NOISE_DETECT = "trainNoiseDetect";
private static final String TRAIN_RECORD_DETECT = "trainRecordDetect";
private static final String TRAIN_TASK_COMMIT = "trainTaskCommit";
private static final String TRAIN_TASK_CREATE = "trainTaskCreate";
private AsClient mAsClient;
private final Context mContext;
private final IHwTTsModelCallback mHwTtsModelCallback;
private Bundle mInitParams;
private final HandlerThreadImpl mAsClientThread = new HandlerThreadImpl();
private final AsClient.AsClientCallback mAsClientCallback = new AsClient.AsClientCallback() {
@Override
public void onError(int i, String str, String str2, String str3) {
TLog.e(VoiceCloneCloudTtsImpl.TAG, "onError utteranceId: " + str3 + ", messageName: " + str2 + ", errorCode: " + i + ", errorMessage: " + str);
if (!TextUtils.equals(VoiceCloneCloudTtsImpl.TRAIN_TASK_COMMIT, str2) || VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback == null) {
return;
}
VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback.onTaskCommit(i, str, new Intent());
}
@Override
public void onResponse(Response response, String str, String str2) {
VoiceCloneCloudTtsImpl.this.handleResponse(response, str);
}
};
private boolean mIsCallbackOnMessage = false;
public class AsWebSocketListener extends WebSocketListener {
private String messageName;
public void onClosed(WebSocket webSocket, int i, String str) {
super.onClosed(webSocket, i, str);
TLog.e(VoiceCloneCloudTtsImpl.TAG, "--- onClosed ---" + i + " : " + str);
if (VoiceCloneCloudTtsImpl.this.mIsCallbackOnMessage) {
return;
}
if (VoiceCloneCloudTtsImpl.TRAIN_NOISE_DETECT.equals(this.messageName)) {
VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback.onNoiseDetectResult(ErrorCode.DO_CLONE_NOISE_DETECT_FAIL, "websocket onClosed " + str);
return;
}
if (!VoiceCloneCloudTtsImpl.TRAIN_RECORD_DETECT.equals(this.messageName)) {
TLog.i(VoiceCloneCloudTtsImpl.TAG, "onClosed do nothing");
return;
}
VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback.onRecordingResult(ErrorCode.DO_CLONE_RECORD_DETECT_FAIL, "websocket onClosed " + str);
}
public void onClosing(WebSocket webSocket, int i, String str) {
super.onClosing(webSocket, i, str);
TLog.e(VoiceCloneCloudTtsImpl.TAG, "--- onClosing ---" + i + " : " + str);
if (VoiceCloneCloudTtsImpl.this.mIsCallbackOnMessage) {
return;
}
if (VoiceCloneCloudTtsImpl.TRAIN_NOISE_DETECT.equals(this.messageName)) {
VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback.onNoiseDetectResult(ErrorCode.DO_CLONE_NOISE_DETECT_FAIL, "websocket onClosing " + str);
return;
}
if (!VoiceCloneCloudTtsImpl.TRAIN_RECORD_DETECT.equals(this.messageName)) {
TLog.i(VoiceCloneCloudTtsImpl.TAG, "onClosing do nothing");
return;
}
VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback.onRecordingResult(ErrorCode.DO_CLONE_RECORD_DETECT_FAIL, "websocket onClosing " + str);
}
public void onFailure(WebSocket webSocket, Throwable th, Response response) {
super.onFailure(webSocket, th, response);
TLog.e(VoiceCloneCloudTtsImpl.TAG, "onFailure = " + th.getMessage());
TLog.e(VoiceCloneCloudTtsImpl.TAG, "onFailure1 = " + Arrays.toString(th.getStackTrace()));
if (response != null) {
try {
ResponseBody body = response.body();
if (body != null) {
TLog.i(VoiceCloneCloudTtsImpl.TAG, "response = " + body.string());
}
} catch (IOException e) {
TLog.d(VoiceCloneCloudTtsImpl.TAG, "onFailure IOException: " + e.getMessage());
TLog.e(VoiceCloneCloudTtsImpl.TAG, "AsWebSocketListener onFailure IOException");
}
}
if (VoiceCloneCloudTtsImpl.this.mIsCallbackOnMessage) {
return;
}
if (VoiceCloneCloudTtsImpl.TRAIN_NOISE_DETECT.equals(this.messageName)) {
VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback.onNoiseDetectResult(ErrorCode.DO_CLONE_NOISE_DETECT_FAIL, th.toString());
} else if (VoiceCloneCloudTtsImpl.TRAIN_RECORD_DETECT.equals(this.messageName)) {
VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback.onRecordingResult(ErrorCode.DO_CLONE_RECORD_DETECT_FAIL, th.toString());
} else {
TLog.i(VoiceCloneCloudTtsImpl.TAG, "onFailure do nothing");
}
}
public void onMessage(WebSocket webSocket, String str) {
super.onMessage(webSocket, str);
TLog.i(VoiceCloneCloudTtsImpl.TAG, "onMessage: " + str);
try {
try {
ph5 ph5Var = (ph5) GsonUtil.fromJson(str, ph5.class);
int h = ph5Var.h();
String i = ph5Var.i();
if (VoiceCloneCloudTtsImpl.TRAIN_NOISE_DETECT.equals(this.messageName)) {
VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback.onNoiseDetectResult(h, i);
VoiceCloneCloudTtsImpl.this.mIsCallbackOnMessage = true;
} else if (VoiceCloneCloudTtsImpl.TRAIN_RECORD_DETECT.equals(this.messageName)) {
VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback.onRecordingResult(h, i);
VoiceCloneCloudTtsImpl.this.mIsCallbackOnMessage = true;
} else {
TLog.i(VoiceCloneCloudTtsImpl.TAG, "onMessage do nothing");
}
} catch (JsonSyntaxException e) {
TLog.e(VoiceCloneCloudTtsImpl.TAG, "onMessage JSONException: " + e.getMessage());
}
webSocket.close(1000, "close old webSocket");
} catch (Throwable th) {
webSocket.close(1000, "close old webSocket");
throw th;
}
}
public void onOpen(WebSocket webSocket, Response response) {
super.onOpen(webSocket, response);
TLog.i(VoiceCloneCloudTtsImpl.TAG, "onOpen ");
if (VoiceCloneCloudTtsImpl.TRAIN_NOISE_DETECT.equals(this.messageName)) {
VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback.onNoiseDetect(0, "trainNoiseDetect success");
} else if (VoiceCloneCloudTtsImpl.TRAIN_RECORD_DETECT.equals(this.messageName)) {
VoiceCloneCloudTtsImpl.this.mHwTtsModelCallback.onRecording(0, "trainRecordDetect success");
} else {
TLog.i(VoiceCloneCloudTtsImpl.TAG, "onOpen do nothing");
}
}
private AsWebSocketListener(String str) {
this.messageName = str;
VoiceCloneCloudTtsImpl.this.mIsCallbackOnMessage = false;
}
}
public VoiceCloneCloudTtsImpl(Context context, IHwTTsModelCallback iHwTTsModelCallback) {
TLog.i(TAG, "VoiceCloneService create");
this.mHwTtsModelCallback = iHwTTsModelCallback;
this.mContext = context;
}
private void executeInAsClientThread(Runnable runnable) {
HandlerThreadImpl handlerThreadImpl = this.mAsClientThread;
if (handlerThreadImpl != null) {
handlerThreadImpl.execute(runnable);
}
}
private ph5 getCallbackInfo(int i, String str) {
ph5 ph5Var = new ph5();
ph5Var.k(i);
ph5Var.l(str);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("resultCode", Integer.valueOf(i));
jsonObject.addProperty("resultMsg", str);
return ph5Var;
}
public void handleResponse(Response response, String str) {
int code;
try {
if (response == null) {
sendCloneCallback(str, getCallbackInfo(-1, HttpConfig.ERROR_MESSAGE_INVALID));
return;
}
try {
try {
code = response.code();
} catch (JsonSyntaxException e) {
TLog.e(TAG, "getCloneResponseInner JSONException");
sendCloneCallback(str, getCallbackInfo(10006, e.toString()));
}
} catch (IOException e2) {
TLog.d(TAG, "getCloneResponseInner IOException: " + e2.getMessage());
TLog.e(TAG, "handleResponse IOException");
sendCloneCallback(str, getCallbackInfo(-1, e2.toString()));
}
if (!response.isSuccessful()) {
ResponseBody body = response.body();
if (body != null) {
TLog.i(TAG, "error response: " + body.string());
}
sendCloneCallback(str, getCallbackInfo(code, "getCloneResponseInner | resp code: " + code));
response.close();
return;
}
ResponseBody body2 = response.body();
if (body2 == null) {
sendCloneCallback(str, getCallbackInfo(code, "getCloneResponseInner | resp body is null"));
response.close();
return;
}
String string = body2.string();
TLog.d(TAG, "respResult = " + string);
ph5 ph5Var = (ph5) GsonUtil.fromJson(string, ph5.class);
if (ph5Var == null) {
sendCloneCallback(str, getCallbackInfo(10005, "parseJson to modelResult is null"));
response.close();
} else {
sendCloneCallback(str, ph5Var);
response.close();
}
} catch (Throwable th) {
response.close();
throw th;
}
}
public void lambda$commitEnhanceTask$16(Intent intent) {
if (this.mAsClient != null) {
Bundle extras = intent.getExtras();
extras.putString("messageName", TRAIN_ENHANCED_COMMIT);
this.mAsClient.doVoiceClone(this.mInitParams, extras);
}
}
public void lambda$commitTask$13(Intent intent) {
if (this.mAsClient != null) {
Bundle extras = intent.getExtras();
extras.putString("messageName", TRAIN_TASK_COMMIT);
this.mAsClient.doVoiceClone(this.mInitParams, extras);
}
}
public void lambda$createTask$12(Intent intent) {
if (this.mAsClient != null) {
Bundle extras = intent.getExtras();
extras.putString("messageName", TRAIN_TASK_CREATE);
this.mAsClient.doVoiceClone(this.mInitParams, extras);
}
}
public void lambda$deleteModel$11(Intent intent) {
if (this.mAsClient != null) {
Bundle extras = intent.getExtras();
extras.putString("messageName", TRAIN_MODEL_DELETE);
this.mAsClient.doVoiceClone(this.mInitParams, extras);
}
}
public void lambda$getCorpus$15() {
if (this.mAsClient != null) {
Bundle bundle = new Bundle();
bundle.putString("messageName", TRAIN_MODEL_GET_CORPUS);
this.mAsClient.doVoiceClone(this.mInitParams, bundle);
}
}
public void lambda$init$0() {
if (this.mAsClient == null) {
this.mAsClient = new AsClient(this.mContext, this.mAsClientCallback);
}
}
public void lambda$inviteModel$14(Intent intent) {
if (this.mAsClient != null) {
Bundle extras = intent.getExtras();
extras.putString("messageName", TRAIN_MODEL_INVITE);
this.mAsClient.doVoiceClone(this.mInitParams, extras);
}
}
public void lambda$loadModel$7(Intent intent) {
Bundle extras = intent.getExtras();
extras.putString("messageName", SYNTHESIS_MODEL_LOAD);
AsClient asClient = this.mAsClient;
if (asClient != null) {
asClient.doVoiceClone(this.mInitParams, extras);
}
}
public void lambda$queryModel$9(Intent intent) {
if (this.mAsClient != null) {
Bundle extras = intent.getExtras();
extras.putString("messageName", TRAIN_MODEL_QUERY_V2);
this.mAsClient.doVoiceClone(this.mInitParams, extras);
}
}
public void lambda$startNoiseDetect$4() {
if (this.mAsClient != null) {
Bundle bundle = new Bundle();
String str = TRAIN_NOISE_DETECT;
bundle.putString("messageName", TRAIN_NOISE_DETECT);
this.mAsClient.doVoiceCloneWs(this.mInitParams, bundle, new AsWebSocketListener(str));
}
}
public void lambda$startRecordDetect$1(Intent intent, String str) {
if (this.mAsClient != null) {
Bundle extras = intent.getExtras();
String str2 = TRAIN_RECORD_DETECT;
extras.putString("messageName", TRAIN_RECORD_DETECT);
extras.putString(BaseConstants.INTENT_SPEAK_TEXT_CONTENT, str);
this.mAsClient.doVoiceCloneWs(this.mInitParams, extras, new AsWebSocketListener(str2));
}
}
public void lambda$stopNoiseDetect$6() {
AsClient asClient = this.mAsClient;
if (asClient != null) {
boolean webSocketSend = asClient.webSocketSend(FullDuplex.Constants.WSS_TERMINATOR);
if (!webSocketSend && !this.mIsCallbackOnMessage) {
this.mHwTtsModelCallback.onNoiseDetectResult(ErrorCode.DO_CLONE_NOISE_DETECT_FAIL, "websocket closed");
this.mIsCallbackOnMessage = true;
}
TLog.e(TAG, "stopNoiseDetect isSuccess:" + webSocketSend + " mIsCallbackOnMessage:" + this.mIsCallbackOnMessage + " errorCode:" + ErrorCode.DO_CLONE_NOISE_DETECT_FAIL + " errorMsg:websocket closed");
}
}
public void lambda$stopRecordDetect$3() {
AsClient asClient = this.mAsClient;
if (asClient != null) {
boolean webSocketSend = asClient.webSocketSend(FullDuplex.Constants.WSS_TERMINATOR);
if (!webSocketSend && !this.mIsCallbackOnMessage) {
this.mHwTtsModelCallback.onRecordingResult(ErrorCode.DO_CLONE_RECORD_DETECT_FAIL, "websocket closed");
}
TLog.e(TAG, "stopRecordDetect isSuccess:" + webSocketSend + " mIsCallbackOnMessage:" + this.mIsCallbackOnMessage + " errorCode:" + ErrorCode.DO_CLONE_RECORD_DETECT_FAIL + " errorMsg:websocket closed");
}
}
public void lambda$unloadModel$8(Intent intent) {
if (this.mAsClient != null) {
Bundle extras = intent.getExtras();
extras.putString("messageName", SYNTHESIS_MODEL_UNLOAD);
this.mAsClient.doVoiceClone(this.mInitParams, extras);
}
}
public void lambda$updateModel$10(Intent intent) {
if (this.mAsClient != null) {
Bundle extras = intent.getExtras();
extras.putString("messageName", TRAIN_MODEL_UPDATE);
this.mAsClient.doVoiceClone(this.mInitParams, extras);
}
}
public void lambda$writeNoisePcm$5(byte[] bArr) {
AsClient asClient = this.mAsClient;
if (asClient != null) {
asClient.webSocketSend(bArr);
}
}
public void lambda$writeRecordDetect$2(byte[] bArr) {
AsClient asClient = this.mAsClient;
if (asClient != null) {
asClient.webSocketSend(bArr);
}
}
private List<aa4> respToCorpusData(String str) {
if (TextUtils.isEmpty(str)) {
return Collections.emptyList();
}
aa4 aa4Var = (aa4) GsonUtil.fromJson(str, aa4.class);
if (aa4Var == null) {
return Collections.emptyList();
}
ArrayList arrayList = new ArrayList();
arrayList.add(aa4Var);
return arrayList;
}
private void sendCloneCallback(String str, ph5 ph5Var) {
int h;
String i;
if (this.mHwTtsModelCallback == null || ph5Var == null) {
TLog.e(TAG, "sendCloneCallback mHwTtsModelCallback or modelResult is null");
return;
}
h = ph5Var.h();
i = ph5Var.i();
TLog.d(TAG, "messageName = " + str + " resultCode = " + h + " resultMsg = " + i);
str.hashCode();
switch (str) {
case "synthesisModelUnload":
this.mHwTtsModelCallback.onModelUnload(h, i);
break;
case "trainEnhancedCommit":
Intent intent = new Intent();
intent.putExtra("estimateLeftTime", ph5Var.b());
this.mHwTtsModelCallback.onEnhanceTaskCommit(h, i, intent);
break;
case "trainModelQuery":
case "trainModelQueryV2":
this.mHwTtsModelCallback.onModelQuery(h, i, ph5Var.g());
break;
case "trainModelGetCorpus":
this.mHwTtsModelCallback.onModelGetCorpus(h, i, respToCorpusData(ph5Var.a()));
break;
case "synthesisModelLoad":
this.mHwTtsModelCallback.onModelLoad(h, i);
break;
case "trainModelDelete":
this.mHwTtsModelCallback.onModelDelete(h, i);
break;
case "trainModelInvite":
this.mHwTtsModelCallback.onModelInvite(h, i, ph5Var.e(), ph5Var.d(), ph5Var.c());
break;
case "trainTaskCommit":
Intent intent2 = new Intent();
intent2.putExtra("estimateLeftTime", ph5Var.b());
this.mHwTtsModelCallback.onTaskCommit(h, i, intent2);
break;
case "trainTaskCreate":
this.mHwTtsModelCallback.onTaskCreate(h, i, ph5Var.j(), ph5Var.f());
break;
case "trainModelUpdate":
this.mHwTtsModelCallback.onModelUpdate(h, i);
break;
default:
TLog.w(TAG, "onCloneResultCode unSupport messageName: " + str);
break;
}
}
public int commitEnhanceTask(final Intent intent) {
TLog.i(TAG, "commitEnhanceTask");
int verifyCommitEnhanceTask = ParamsVerify.verifyCommitEnhanceTask(intent);
if (verifyCommitEnhanceTask != 100) {
return verifyCommitEnhanceTask;
}
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$commitEnhanceTask$16(intent);
}
});
return 100;
}
public int commitTask(final Intent intent) {
TLog.i(TAG, "commitTask");
int verifyCommitTaskParams = ParamsVerify.verifyCommitTaskParams(intent);
if (verifyCommitTaskParams != 100) {
return verifyCommitTaskParams;
}
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$commitTask$13(intent);
}
});
return 100;
}
public int createTask(final Intent intent) {
TLog.i(TAG, "createTask");
int verifyCreateTaskParams = ParamsVerify.verifyCreateTaskParams(intent);
if (verifyCreateTaskParams != 100) {
return verifyCreateTaskParams;
}
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$createTask$12(intent);
}
});
return 100;
}
public int deleteModel(final Intent intent) {
TLog.i(TAG, "deleteModel");
int verifyLoadModelParams = ParamsVerify.verifyLoadModelParams(intent);
if (verifyLoadModelParams != 100) {
return verifyLoadModelParams;
}
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$deleteModel$11(intent);
}
});
return 100;
}
public int getCorpus() {
TLog.i(TAG, "getCorpus");
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$getCorpus$15();
}
});
return 100;
}
public int init(Intent intent) {
int verifyCloudInitParams = ParamsVerify.verifyCloudInitParams(intent);
if (verifyCloudInitParams != 100) {
return verifyCloudInitParams;
}
this.mAsClientThread.initHandlerThread(TAG, -20);
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$init$0();
}
});
this.mInitParams = intent.getExtras();
return 100;
}
public int inviteModel(final Intent intent) {
TLog.i(TAG, "inviteModel");
int verifyInviteModelParams = ParamsVerify.verifyInviteModelParams(intent);
if (verifyInviteModelParams != 100) {
return verifyInviteModelParams;
}
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$inviteModel$14(intent);
}
});
return 100;
}
public int loadModel(final Intent intent) {
TLog.i(TAG, "loadModel");
int verifyLoadModelParams = ParamsVerify.verifyLoadModelParams(intent);
if (verifyLoadModelParams != 100) {
return verifyLoadModelParams;
}
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$loadModel$7(intent);
}
});
return 100;
}
public int queryModel(final Intent intent) {
TLog.i(TAG, "queryModel");
int verifyQueryModelParams = ParamsVerify.verifyQueryModelParams(intent);
if (verifyQueryModelParams != 100) {
return verifyQueryModelParams;
}
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$queryModel$9(intent);
}
});
return 100;
}
public void release() {
TLog.i(TAG, "release");
this.mAsClientThread.releaseHandlerThread(100L);
}
public int startNoiseDetect() {
TLog.i(TAG, "startNoiseDetect");
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$startNoiseDetect$4();
}
});
return 100;
}
public int startRecordDetect(final String str, final Intent intent) {
TLog.i(TAG, "startRecordDetect");
int verifyStartRecordDetect = ParamsVerify.verifyStartRecordDetect(intent);
if (verifyStartRecordDetect != 100) {
return verifyStartRecordDetect;
}
if (TextUtils.isEmpty(str)) {
TLog.e(TAG, "startRecordDetect text is empty ");
return ErrorCode.DO_CLONE_TEXT;
}
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$startRecordDetect$1(intent, str);
}
});
return 100;
}
public void stopNoiseDetect() {
TLog.i(TAG, "stopNoiseDetect");
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$stopNoiseDetect$6();
}
});
}
public void stopRecordDetect() {
TLog.i(TAG, "stopRecordDetect");
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$stopRecordDetect$3();
}
});
}
public int unloadModel(final Intent intent) {
TLog.i(TAG, "unloadModel");
int verifyLoadModelParams = ParamsVerify.verifyLoadModelParams(intent);
if (verifyLoadModelParams != 100) {
return verifyLoadModelParams;
}
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$unloadModel$8(intent);
}
});
return 100;
}
public int updateModel(final Intent intent) {
TLog.i(TAG, "updateModel");
int verifyUpdateModelParams = ParamsVerify.verifyUpdateModelParams(intent);
if (verifyUpdateModelParams != 100) {
return verifyUpdateModelParams;
}
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$updateModel$10(intent);
}
});
return 100;
}
public void writeNoisePcm(final byte[] bArr, int i) {
TLog.i(TAG, "writeNoisePcm");
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$writeNoisePcm$5(bArr);
}
});
}
public void writeRecordDetect(final byte[] bArr, int i) {
TLog.i(TAG, "writeRecordDetect");
if (bArr == null || bArr.length == 0 || i == 0) {
TLog.e(TAG, "writeRecordDetect buff is null or length 0");
} else {
executeInAsClientThread(new Runnable() {
@Override
public final void run() {
VoiceCloneCloudTtsImpl.this.lambda$writeRecordDetect$2(bArr);
}
});
}
}
}