fix: flowise
This commit is contained in:
parent
bc6be908b6
commit
8e9312482f
@ -7,9 +7,11 @@ import com.cmvr.test.service.FlowiseActionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = "测试--flowise服务")
|
||||
@ -22,9 +24,15 @@ public class TeFlowiseController extends BaseController {
|
||||
private final FlowiseActionService flowiseActionService;
|
||||
|
||||
@ApiOperation("执行指令")
|
||||
@PostMapping("/action")
|
||||
public AjaxResult action(@RequestBody FlowiseActionRequestVO request) {
|
||||
return AjaxResult.ok(flowiseActionService.execute(request));
|
||||
@PostMapping("/command")
|
||||
public AjaxResult command(@RequestBody FlowiseActionRequestVO request) {
|
||||
return AjaxResult.ok(flowiseActionService.command(request));
|
||||
}
|
||||
|
||||
@GetMapping("/chat")
|
||||
public AjaxResult chat(@RequestParam("terminalId") String terminalId,
|
||||
@RequestParam("text") String text,
|
||||
@RequestParam("bioId") String bioId) {
|
||||
return AjaxResult.success(flowiseActionService.chat(terminalId, text,bioId));
|
||||
}
|
||||
}
|
||||
@ -173,20 +173,40 @@ public class EdgeBioHeadServiceImpl implements EdgeBioHeadService {
|
||||
// 请求头
|
||||
Common.CommandHeader.Request header = EdgeCommonUtil.buildRequest(deviceId);
|
||||
|
||||
if (expressKey == 1) {
|
||||
BioheadCommand.Happy.Request happy = BioheadCommand.Happy.Request.newBuilder().setHeader(header).build();
|
||||
BioheadCommand.Happy.Feedback happyBack = stub.happy(happy);
|
||||
return JSON.toJSONString(happyBack.getHeader());
|
||||
}else if (expressKey == 2) {
|
||||
BioheadCommand.Surprise.Request surprise = BioheadCommand.Surprise.Request.newBuilder().setHeader(header).build();
|
||||
BioheadCommand.Surprise.Feedback surpriseBack = stub.surprise(surprise);
|
||||
return JSON.toJSONString(surpriseBack.getHeader());
|
||||
} else if (expressKey == 3) {
|
||||
BioheadCommand.ExpressionTired.Request tired = BioheadCommand.ExpressionTired.Request.newBuilder().setHeader(header).build();
|
||||
BioheadCommand.ExpressionTired.Feedback tiredBack = stub.expressionTired(tired);
|
||||
return JSON.toJSONString(tiredBack.getHeader());
|
||||
}else {
|
||||
throw new GlobalException("错误的传参,1:高兴,2:惊讶,3:疲惫");
|
||||
switch (expressKey) {
|
||||
case 1:
|
||||
// 高兴
|
||||
BioheadCommand.Happy.Request happy = BioheadCommand.Happy.Request.newBuilder().setHeader(header).build();
|
||||
BioheadCommand.Happy.Feedback happyBack = stub.happy(happy);
|
||||
return JSON.toJSONString(happyBack.getHeader());
|
||||
case 2:
|
||||
// 惊讶
|
||||
BioheadCommand.Surprise.Request surprise = BioheadCommand.Surprise.Request.newBuilder().setHeader(header).build();
|
||||
BioheadCommand.Surprise.Feedback surpriseBack = stub.surprise(surprise);
|
||||
return JSON.toJSONString(surpriseBack.getHeader());
|
||||
case 3:
|
||||
// 愤怒
|
||||
BioheadCommand.ExpressionAngry.Request angry = BioheadCommand.ExpressionAngry.Request.newBuilder().setHeader(header).build();
|
||||
BioheadCommand.ExpressionAngry.Feedback angryBack = stub.expressionAngry(angry);
|
||||
return JSON.toJSONString(angryBack.getHeader());
|
||||
case 4:
|
||||
// 悲伤
|
||||
BioheadCommand.ExpressionSadness.Request sadness = BioheadCommand.ExpressionSadness.Request.newBuilder().setHeader(header).build();
|
||||
BioheadCommand.ExpressionSadness.Feedback sadnessBack = stub.expressionSadness(sadness);
|
||||
return JSON.toJSONString(sadnessBack.getHeader());
|
||||
case 5:
|
||||
// 睡觉
|
||||
BioheadCommand.ExpressionTired.Request tired = BioheadCommand.ExpressionTired.Request.newBuilder().setHeader(header).build();
|
||||
BioheadCommand.ExpressionTired.Feedback tiredBack = stub.expressionTired(tired);
|
||||
return JSON.toJSONString(tiredBack.getHeader());
|
||||
case 6:
|
||||
// 打哈欠
|
||||
BioheadCommand.ExpressionYawn.Request yawn = BioheadCommand.ExpressionYawn.Request.newBuilder().setHeader(header).build();
|
||||
BioheadCommand.ExpressionYawn.Feedback yawnBack = stub.expressionYawn(yawn);
|
||||
return JSON.toJSONString(yawnBack.getHeader());
|
||||
default:
|
||||
throw new GlobalException("错误的传参,1:高兴,2:惊讶,3:愤怒,4:悲伤,5:睡觉,6:打哈欠");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,6 +297,99 @@ public final class BioHeadServiceGrpc {
|
||||
return getExpressionTiredMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<cmvr.api.BioheadCommand.ExpressionAngry.Request,
|
||||
cmvr.api.BioheadCommand.ExpressionAngry.Feedback> getExpressionAngryMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "ExpressionAngry",
|
||||
requestType = cmvr.api.BioheadCommand.ExpressionAngry.Request.class,
|
||||
responseType = cmvr.api.BioheadCommand.ExpressionAngry.Feedback.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<cmvr.api.BioheadCommand.ExpressionAngry.Request,
|
||||
cmvr.api.BioheadCommand.ExpressionAngry.Feedback> getExpressionAngryMethod() {
|
||||
io.grpc.MethodDescriptor<cmvr.api.BioheadCommand.ExpressionAngry.Request, cmvr.api.BioheadCommand.ExpressionAngry.Feedback> getExpressionAngryMethod;
|
||||
if ((getExpressionAngryMethod = BioHeadServiceGrpc.getExpressionAngryMethod) == null) {
|
||||
synchronized (BioHeadServiceGrpc.class) {
|
||||
if ((getExpressionAngryMethod = BioHeadServiceGrpc.getExpressionAngryMethod) == null) {
|
||||
BioHeadServiceGrpc.getExpressionAngryMethod = getExpressionAngryMethod =
|
||||
io.grpc.MethodDescriptor.<cmvr.api.BioheadCommand.ExpressionAngry.Request, cmvr.api.BioheadCommand.ExpressionAngry.Feedback>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "ExpressionAngry"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
cmvr.api.BioheadCommand.ExpressionAngry.Request.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
cmvr.api.BioheadCommand.ExpressionAngry.Feedback.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new BioHeadServiceMethodDescriptorSupplier("ExpressionAngry"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getExpressionAngryMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<cmvr.api.BioheadCommand.ExpressionSadness.Request,
|
||||
cmvr.api.BioheadCommand.ExpressionSadness.Feedback> getExpressionSadnessMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "ExpressionSadness",
|
||||
requestType = cmvr.api.BioheadCommand.ExpressionSadness.Request.class,
|
||||
responseType = cmvr.api.BioheadCommand.ExpressionSadness.Feedback.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<cmvr.api.BioheadCommand.ExpressionSadness.Request,
|
||||
cmvr.api.BioheadCommand.ExpressionSadness.Feedback> getExpressionSadnessMethod() {
|
||||
io.grpc.MethodDescriptor<cmvr.api.BioheadCommand.ExpressionSadness.Request, cmvr.api.BioheadCommand.ExpressionSadness.Feedback> getExpressionSadnessMethod;
|
||||
if ((getExpressionSadnessMethod = BioHeadServiceGrpc.getExpressionSadnessMethod) == null) {
|
||||
synchronized (BioHeadServiceGrpc.class) {
|
||||
if ((getExpressionSadnessMethod = BioHeadServiceGrpc.getExpressionSadnessMethod) == null) {
|
||||
BioHeadServiceGrpc.getExpressionSadnessMethod = getExpressionSadnessMethod =
|
||||
io.grpc.MethodDescriptor.<cmvr.api.BioheadCommand.ExpressionSadness.Request, cmvr.api.BioheadCommand.ExpressionSadness.Feedback>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "ExpressionSadness"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
cmvr.api.BioheadCommand.ExpressionSadness.Request.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
cmvr.api.BioheadCommand.ExpressionSadness.Feedback.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new BioHeadServiceMethodDescriptorSupplier("ExpressionSadness"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getExpressionSadnessMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<cmvr.api.BioheadCommand.ExpressionYawn.Request,
|
||||
cmvr.api.BioheadCommand.ExpressionYawn.Feedback> getExpressionYawnMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "ExpressionYawn",
|
||||
requestType = cmvr.api.BioheadCommand.ExpressionYawn.Request.class,
|
||||
responseType = cmvr.api.BioheadCommand.ExpressionYawn.Feedback.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<cmvr.api.BioheadCommand.ExpressionYawn.Request,
|
||||
cmvr.api.BioheadCommand.ExpressionYawn.Feedback> getExpressionYawnMethod() {
|
||||
io.grpc.MethodDescriptor<cmvr.api.BioheadCommand.ExpressionYawn.Request, cmvr.api.BioheadCommand.ExpressionYawn.Feedback> getExpressionYawnMethod;
|
||||
if ((getExpressionYawnMethod = BioHeadServiceGrpc.getExpressionYawnMethod) == null) {
|
||||
synchronized (BioHeadServiceGrpc.class) {
|
||||
if ((getExpressionYawnMethod = BioHeadServiceGrpc.getExpressionYawnMethod) == null) {
|
||||
BioHeadServiceGrpc.getExpressionYawnMethod = getExpressionYawnMethod =
|
||||
io.grpc.MethodDescriptor.<cmvr.api.BioheadCommand.ExpressionYawn.Request, cmvr.api.BioheadCommand.ExpressionYawn.Feedback>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "ExpressionYawn"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
cmvr.api.BioheadCommand.ExpressionYawn.Request.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
cmvr.api.BioheadCommand.ExpressionYawn.Feedback.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new BioHeadServiceMethodDescriptorSupplier("ExpressionYawn"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getExpressionYawnMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new async stub that supports all call types for the service
|
||||
*/
|
||||
@ -426,6 +519,27 @@ public final class BioHeadServiceGrpc {
|
||||
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getExpressionTiredMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void expressionAngry(cmvr.api.BioheadCommand.ExpressionAngry.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionAngry.Feedback> responseObserver) {
|
||||
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getExpressionAngryMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void expressionSadness(cmvr.api.BioheadCommand.ExpressionSadness.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionSadness.Feedback> responseObserver) {
|
||||
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getExpressionSadnessMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void expressionYawn(cmvr.api.BioheadCommand.ExpressionYawn.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionYawn.Feedback> responseObserver) {
|
||||
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getExpressionYawnMethod(), responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
@ -491,6 +605,27 @@ public final class BioHeadServiceGrpc {
|
||||
cmvr.api.BioheadCommand.ExpressionTired.Request,
|
||||
cmvr.api.BioheadCommand.ExpressionTired.Feedback>(
|
||||
this, METHODID_EXPRESSION_TIRED)))
|
||||
.addMethod(
|
||||
getExpressionAngryMethod(),
|
||||
io.grpc.stub.ServerCalls.asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
cmvr.api.BioheadCommand.ExpressionAngry.Request,
|
||||
cmvr.api.BioheadCommand.ExpressionAngry.Feedback>(
|
||||
this, METHODID_EXPRESSION_ANGRY)))
|
||||
.addMethod(
|
||||
getExpressionSadnessMethod(),
|
||||
io.grpc.stub.ServerCalls.asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
cmvr.api.BioheadCommand.ExpressionSadness.Request,
|
||||
cmvr.api.BioheadCommand.ExpressionSadness.Feedback>(
|
||||
this, METHODID_EXPRESSION_SADNESS)))
|
||||
.addMethod(
|
||||
getExpressionYawnMethod(),
|
||||
io.grpc.stub.ServerCalls.asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
cmvr.api.BioheadCommand.ExpressionYawn.Request,
|
||||
cmvr.api.BioheadCommand.ExpressionYawn.Feedback>(
|
||||
this, METHODID_EXPRESSION_YAWN)))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@ -598,6 +733,30 @@ public final class BioHeadServiceGrpc {
|
||||
io.grpc.stub.ClientCalls.asyncUnaryCall(
|
||||
getChannel().newCall(getExpressionTiredMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void expressionAngry(cmvr.api.BioheadCommand.ExpressionAngry.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionAngry.Feedback> responseObserver) {
|
||||
io.grpc.stub.ClientCalls.asyncUnaryCall(
|
||||
getChannel().newCall(getExpressionAngryMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void expressionSadness(cmvr.api.BioheadCommand.ExpressionSadness.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionSadness.Feedback> responseObserver) {
|
||||
io.grpc.stub.ClientCalls.asyncUnaryCall(
|
||||
getChannel().newCall(getExpressionSadnessMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void expressionYawn(cmvr.api.BioheadCommand.ExpressionYawn.Request request,
|
||||
io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionYawn.Feedback> responseObserver) {
|
||||
io.grpc.stub.ClientCalls.asyncUnaryCall(
|
||||
getChannel().newCall(getExpressionYawnMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -687,6 +846,27 @@ public final class BioHeadServiceGrpc {
|
||||
return io.grpc.stub.ClientCalls.blockingUnaryCall(
|
||||
getChannel(), getExpressionTiredMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public cmvr.api.BioheadCommand.ExpressionAngry.Feedback expressionAngry(cmvr.api.BioheadCommand.ExpressionAngry.Request request) {
|
||||
return io.grpc.stub.ClientCalls.blockingUnaryCall(
|
||||
getChannel(), getExpressionAngryMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public cmvr.api.BioheadCommand.ExpressionSadness.Feedback expressionSadness(cmvr.api.BioheadCommand.ExpressionSadness.Request request) {
|
||||
return io.grpc.stub.ClientCalls.blockingUnaryCall(
|
||||
getChannel(), getExpressionSadnessMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public cmvr.api.BioheadCommand.ExpressionYawn.Feedback expressionYawn(cmvr.api.BioheadCommand.ExpressionYawn.Request request) {
|
||||
return io.grpc.stub.ClientCalls.blockingUnaryCall(
|
||||
getChannel(), getExpressionYawnMethod(), getCallOptions(), request);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -784,6 +964,30 @@ public final class BioHeadServiceGrpc {
|
||||
return io.grpc.stub.ClientCalls.futureUnaryCall(
|
||||
getChannel().newCall(getExpressionTiredMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<cmvr.api.BioheadCommand.ExpressionAngry.Feedback> expressionAngry(
|
||||
cmvr.api.BioheadCommand.ExpressionAngry.Request request) {
|
||||
return io.grpc.stub.ClientCalls.futureUnaryCall(
|
||||
getChannel().newCall(getExpressionAngryMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<cmvr.api.BioheadCommand.ExpressionSadness.Feedback> expressionSadness(
|
||||
cmvr.api.BioheadCommand.ExpressionSadness.Request request) {
|
||||
return io.grpc.stub.ClientCalls.futureUnaryCall(
|
||||
getChannel().newCall(getExpressionSadnessMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<cmvr.api.BioheadCommand.ExpressionYawn.Feedback> expressionYawn(
|
||||
cmvr.api.BioheadCommand.ExpressionYawn.Request request) {
|
||||
return io.grpc.stub.ClientCalls.futureUnaryCall(
|
||||
getChannel().newCall(getExpressionYawnMethod(), getCallOptions()), request);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int METHODID_SET_EXPRESSION = 0;
|
||||
@ -794,7 +998,10 @@ public final class BioHeadServiceGrpc {
|
||||
private static final int METHODID_HAPPY = 5;
|
||||
private static final int METHODID_SURPRISE = 6;
|
||||
private static final int METHODID_EXPRESSION_TIRED = 7;
|
||||
private static final int METHODID_STREAM_EXPRESSION = 8;
|
||||
private static final int METHODID_EXPRESSION_ANGRY = 8;
|
||||
private static final int METHODID_EXPRESSION_SADNESS = 9;
|
||||
private static final int METHODID_EXPRESSION_YAWN = 10;
|
||||
private static final int METHODID_STREAM_EXPRESSION = 11;
|
||||
|
||||
private static final class MethodHandlers<Req, Resp> implements
|
||||
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
|
||||
@ -845,6 +1052,18 @@ public final class BioHeadServiceGrpc {
|
||||
serviceImpl.expressionTired((cmvr.api.BioheadCommand.ExpressionTired.Request) request,
|
||||
(io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionTired.Feedback>) responseObserver);
|
||||
break;
|
||||
case METHODID_EXPRESSION_ANGRY:
|
||||
serviceImpl.expressionAngry((cmvr.api.BioheadCommand.ExpressionAngry.Request) request,
|
||||
(io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionAngry.Feedback>) responseObserver);
|
||||
break;
|
||||
case METHODID_EXPRESSION_SADNESS:
|
||||
serviceImpl.expressionSadness((cmvr.api.BioheadCommand.ExpressionSadness.Request) request,
|
||||
(io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionSadness.Feedback>) responseObserver);
|
||||
break;
|
||||
case METHODID_EXPRESSION_YAWN:
|
||||
serviceImpl.expressionYawn((cmvr.api.BioheadCommand.ExpressionYawn.Request) request,
|
||||
(io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionYawn.Feedback>) responseObserver);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
@ -918,6 +1137,9 @@ public final class BioHeadServiceGrpc {
|
||||
.addMethod(getHappyMethod())
|
||||
.addMethod(getSurpriseMethod())
|
||||
.addMethod(getExpressionTiredMethod())
|
||||
.addMethod(getExpressionAngryMethod())
|
||||
.addMethod(getExpressionSadnessMethod())
|
||||
.addMethod(getExpressionYawnMethod())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -24,7 +24,7 @@ public final class BioheadService {
|
||||
static {
|
||||
java.lang.String[] descriptorData = {
|
||||
"\n\036cmvr/api/biohead_service.proto\022\010cmvr.a" +
|
||||
"pi\032\036cmvr/api/biohead_command.proto2\375\005\n\016B" +
|
||||
"pi\032\036cmvr/api/biohead_command.proto2\224\010\n\016B" +
|
||||
"ioHeadService\022`\n\rSetExpression\022%.cmvr.ap" +
|
||||
"i.SetFacialExpression.Request\032&.cmvr.api" +
|
||||
".SetFacialExpression.Feedback\"\000\022k\n\020Strea" +
|
||||
@ -44,7 +44,14 @@ public final class BioheadService {
|
||||
"\033.cmvr.api.Surprise.Feedback\"\000\022Z\n\017Expres" +
|
||||
"sionTired\022!.cmvr.api.ExpressionTired.Req" +
|
||||
"uest\032\".cmvr.api.ExpressionTired.Feedback" +
|
||||
"\"\000b\006proto3"
|
||||
"\"\000\022Z\n\017ExpressionAngry\022!.cmvr.api.Express" +
|
||||
"ionAngry.Request\032\".cmvr.api.ExpressionAn" +
|
||||
"gry.Feedback\"\000\022`\n\021ExpressionSadness\022#.cm" +
|
||||
"vr.api.ExpressionSadness.Request\032$.cmvr." +
|
||||
"api.ExpressionSadness.Feedback\"\000\022W\n\016Expr" +
|
||||
"essionYawn\022 .cmvr.api.ExpressionYawn.Req" +
|
||||
"uest\032!.cmvr.api.ExpressionYawn.Feedback\"" +
|
||||
"\000b\006proto3"
|
||||
};
|
||||
descriptor = com.google.protobuf.Descriptors.FileDescriptor
|
||||
.internalBuildGeneratedFileFrom(descriptorData,
|
||||
|
||||
@ -196,7 +196,7 @@ message SpeakStop {
|
||||
|
||||
|
||||
|
||||
// 表情控制 - 高兴
|
||||
// 表情控制 - 微笑
|
||||
message Happy {
|
||||
message Request {
|
||||
CommandHeader.Request header = 1; // 通用命令头
|
||||
@ -220,7 +220,7 @@ message Surprise {
|
||||
}
|
||||
|
||||
|
||||
|
||||
//表情控制-疲惫
|
||||
message ExpressionTired {
|
||||
message Request {
|
||||
CommandHeader.Request header = 1;
|
||||
@ -229,4 +229,41 @@ message ExpressionTired {
|
||||
message Feedback {
|
||||
CommandHeader.Feedback header = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//表情控制-愤怒
|
||||
message ExpressionAngry {
|
||||
message Request {
|
||||
CommandHeader.Request header = 1;
|
||||
}
|
||||
|
||||
message Feedback {
|
||||
CommandHeader.Feedback header = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//表情控制-悲伤
|
||||
message ExpressionSadness {
|
||||
message Request {
|
||||
CommandHeader.Request header = 1;
|
||||
}
|
||||
|
||||
message Feedback {
|
||||
CommandHeader.Feedback header = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//表情控制-打哈欠
|
||||
message ExpressionYawn {
|
||||
message Request {
|
||||
CommandHeader.Request header = 1;
|
||||
}
|
||||
|
||||
message Feedback {
|
||||
CommandHeader.Feedback header = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -31,6 +31,10 @@ service BioHeadService {
|
||||
|
||||
rpc ExpressionTired(ExpressionTired.Request) returns (ExpressionTired.Feedback){};
|
||||
|
||||
rpc ExpressionAngry(ExpressionAngry.Request) returns (ExpressionAngry.Feedback){};
|
||||
|
||||
rpc ExpressionSadness(ExpressionSadness.Request) returns (ExpressionSadness.Feedback){};
|
||||
|
||||
rpc ExpressionYawn(ExpressionYawn.Request) returns (ExpressionYawn.Feedback){};
|
||||
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.cmvr.test.flow.runtime.operator.edge.vi;
|
||||
|
||||
import cmvr.api.SpeakerCommand;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.cmvr.common.exception.GlobalException;
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
@ -40,37 +41,59 @@ public class ViPlayOperateService implements EdgeOperateService {
|
||||
if (!action.equals(ActionEnum.VI_PLAY_CORPUS)) {
|
||||
throw new GlobalException("播放语料的action不是VI_PLAY_CORPUS");
|
||||
}
|
||||
|
||||
JSONObject inputParams = message.getInputParams();
|
||||
String deviceId = inputParams.getString("deviceId");
|
||||
String bioId = inputParams.getString("bioId");
|
||||
String audioPath = inputParams.getString("audioPath");
|
||||
String terminalId = message.getTerminalId();
|
||||
// 播放前调用张嘴
|
||||
EdgeCommonVO edgeCommonVO = new EdgeCommonVO();
|
||||
edgeCommonVO.setDeviceId(deviceId);
|
||||
edgeCommonVO.setTerminalId(terminalId);
|
||||
edgeBioHeadService.speakStart(edgeCommonVO);
|
||||
|
||||
// 仅当 bioId 不为空时才构造 VO
|
||||
EdgeCommonVO edgeCommonVO = null;
|
||||
boolean needBioSpeak = StrUtil.isNotEmpty(bioId);
|
||||
if (needBioSpeak) {
|
||||
edgeCommonVO = new EdgeCommonVO();
|
||||
edgeCommonVO.setDeviceId(bioId);
|
||||
edgeCommonVO.setTerminalId(terminalId);
|
||||
}
|
||||
|
||||
try {
|
||||
// 播放音频
|
||||
edgeSpeakerService.playAudio(terminalId, deviceId, audioPath);
|
||||
// 等待播放完成
|
||||
while (true) {
|
||||
|
||||
// 播放开始时,若 bioId 存在才张嘴
|
||||
if (needBioSpeak) {
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
edgeBioHeadService.speakStart(edgeCommonVO);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SpeakerCommand.GetSpeakerStateCommand.Feedback status = edgeSpeakerService.getStatus(terminalId, deviceId);
|
||||
boolean isRunning = status.getState().getIsRunning();
|
||||
if (!isRunning) {
|
||||
}
|
||||
|
||||
// 等待播放完成
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
SpeakerCommand.GetSpeakerStateCommand.Feedback status =
|
||||
edgeSpeakerService.getStatus(terminalId, deviceId);
|
||||
|
||||
if (!status.getState().getIsRunning()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
// 播放完成调用闭嘴
|
||||
edgeBioHeadService.speakStop(edgeCommonVO);
|
||||
// 播放完成后,若 bioId 存在才闭嘴
|
||||
if (needBioSpeak) {
|
||||
edgeBioHeadService.speakStop(edgeCommonVO);
|
||||
}
|
||||
}
|
||||
|
||||
// todo 本机测试播放
|
||||
// playAudio(audioPath);
|
||||
return TaskNodeExecuteResult.success();
|
||||
}
|
||||
|
||||
|
||||
@ -1,83 +1,68 @@
|
||||
package com.cmvr.test.service;
|
||||
|
||||
import cmvr.api.SpeakerCommand;
|
||||
import com.cmvr.common.utils.http.CallAPIUtil;
|
||||
import com.cmvr.edge.client.model.EdgeCommonVO;
|
||||
import com.cmvr.edge.client.service.EdgeBioHeadService;
|
||||
import com.cmvr.edge.client.service.EdgeSpeakerService;
|
||||
import com.cmvr.test.enums.FlowiseActionEnum;
|
||||
import com.cmvr.test.model.vo.FlowiseActionRequestVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class FlowiseActionService {
|
||||
private final EdgeBioHeadService edgeBioHeadService;
|
||||
private final EdgeSpeakerService edgeSpeakerService;
|
||||
|
||||
public String execute(FlowiseActionRequestVO request) {
|
||||
public String command(FlowiseActionRequestVO request) {
|
||||
String terminalId = "4ed1246c465b97975f96c9ef8371a3bd";
|
||||
String spkId = "spk1";
|
||||
String bioId = "bio_head";
|
||||
String action = request.getAction();
|
||||
FlowiseActionEnum actionEnum = FlowiseActionEnum.fromAction(action);
|
||||
String result;
|
||||
switch (actionEnum) {
|
||||
// ==== 说话 ====
|
||||
case SPEAK:
|
||||
EdgeCommonVO edgeCommonVO = new EdgeCommonVO();
|
||||
edgeCommonVO.setTerminalId(terminalId);
|
||||
edgeCommonVO.setDeviceId(bioId);
|
||||
try {
|
||||
edgeBioHeadService.speakStart(edgeCommonVO);
|
||||
result = edgeSpeakerService.playAudio(
|
||||
terminalId,
|
||||
spkId,
|
||||
"/home/share/assets/audio/show_1114/单次对话_标准女_中性_四川话_关闭主驾车窗,调高空调温度,切换为外循环,开启空气净化.wav");
|
||||
|
||||
// 等待播放完成
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SpeakerCommand.GetSpeakerStateCommand.Feedback status = edgeSpeakerService.getStatus(terminalId, spkId);
|
||||
boolean isRunning = status.getState().getIsRunning();
|
||||
if (!isRunning) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} finally {
|
||||
edgeBioHeadService.speakStop(edgeCommonVO);
|
||||
}
|
||||
return result;
|
||||
|
||||
// ==== 表情 ====
|
||||
case SMILE:
|
||||
return "微笑";
|
||||
return edgeBioHeadService.specialExpression(terminalId, bioId, 1);
|
||||
case SURPRISED:
|
||||
return "惊讶";
|
||||
return edgeBioHeadService.specialExpression(terminalId, bioId, 2);
|
||||
case ANGRY:
|
||||
return "愤怒";
|
||||
return edgeBioHeadService.specialExpression(terminalId, bioId, 3);
|
||||
case SAD:
|
||||
return "悲伤";
|
||||
return edgeBioHeadService.specialExpression(terminalId, bioId, 4);
|
||||
case SLEEP:
|
||||
return "睡觉";
|
||||
return edgeBioHeadService.specialExpression(terminalId, bioId, 5);
|
||||
case YAWN:
|
||||
return "打哈欠";
|
||||
return edgeBioHeadService.specialExpression(terminalId, bioId, 6);
|
||||
|
||||
// ==== 动作 ====
|
||||
|
||||
default:
|
||||
throw new UnsupportedOperationException("未实现的 Flowise Action: " + action);
|
||||
}
|
||||
}
|
||||
|
||||
public String chat(String terminalId, String text, String bioId) {
|
||||
// 播放前调用张嘴
|
||||
EdgeCommonVO edgeCommonVO = new EdgeCommonVO();
|
||||
edgeCommonVO.setDeviceId(bioId);
|
||||
edgeCommonVO.setTerminalId(terminalId);
|
||||
try {
|
||||
Map<String, String> body = new HashMap<>();
|
||||
body.put("text", text);
|
||||
body.put("voice", "x4_yezi");
|
||||
|
||||
// edgeBioHeadService.speakStart(edgeCommonVO);
|
||||
CallAPIUtil.doPostJson("192.168.0.222:8080/tts/play", null, body);
|
||||
} finally {
|
||||
// 播放完成调用闭嘴
|
||||
// edgeBioHeadService.speakStop(edgeCommonVO);
|
||||
}
|
||||
|
||||
return "ok";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user