fix: flowise

This commit is contained in:
stream 2025-12-05 17:04:51 +08:00
parent bc6be908b6
commit 8e9312482f
9 changed files with 5317 additions and 87 deletions

View File

@ -7,9 +7,11 @@ import com.cmvr.test.service.FlowiseActionService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@Api(tags = "测试--flowise服务") @Api(tags = "测试--flowise服务")
@ -22,9 +24,15 @@ public class TeFlowiseController extends BaseController {
private final FlowiseActionService flowiseActionService; private final FlowiseActionService flowiseActionService;
@ApiOperation("执行指令") @ApiOperation("执行指令")
@PostMapping("/action") @PostMapping("/command")
public AjaxResult action(@RequestBody FlowiseActionRequestVO request) { public AjaxResult command(@RequestBody FlowiseActionRequestVO request) {
return AjaxResult.ok(flowiseActionService.execute(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));
}
} }

View File

@ -173,20 +173,40 @@ public class EdgeBioHeadServiceImpl implements EdgeBioHeadService {
// 请求头 // 请求头
Common.CommandHeader.Request header = EdgeCommonUtil.buildRequest(deviceId); Common.CommandHeader.Request header = EdgeCommonUtil.buildRequest(deviceId);
if (expressKey == 1) { switch (expressKey) {
BioheadCommand.Happy.Request happy = BioheadCommand.Happy.Request.newBuilder().setHeader(header).build(); case 1:
BioheadCommand.Happy.Feedback happyBack = stub.happy(happy); // 高兴
return JSON.toJSONString(happyBack.getHeader()); BioheadCommand.Happy.Request happy = BioheadCommand.Happy.Request.newBuilder().setHeader(header).build();
}else if (expressKey == 2) { BioheadCommand.Happy.Feedback happyBack = stub.happy(happy);
BioheadCommand.Surprise.Request surprise = BioheadCommand.Surprise.Request.newBuilder().setHeader(header).build(); return JSON.toJSONString(happyBack.getHeader());
BioheadCommand.Surprise.Feedback surpriseBack = stub.surprise(surprise); case 2:
return JSON.toJSONString(surpriseBack.getHeader()); // 惊讶
} else if (expressKey == 3) { BioheadCommand.Surprise.Request surprise = BioheadCommand.Surprise.Request.newBuilder().setHeader(header).build();
BioheadCommand.ExpressionTired.Request tired = BioheadCommand.ExpressionTired.Request.newBuilder().setHeader(header).build(); BioheadCommand.Surprise.Feedback surpriseBack = stub.surprise(surprise);
BioheadCommand.ExpressionTired.Feedback tiredBack = stub.expressionTired(tired); return JSON.toJSONString(surpriseBack.getHeader());
return JSON.toJSONString(tiredBack.getHeader()); case 3:
}else { // 愤怒
throw new GlobalException("错误的传参1:高兴,2:惊讶,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:打哈欠");
} }
} }
} }

View File

@ -297,6 +297,99 @@ public final class BioHeadServiceGrpc {
return getExpressionTiredMethod; 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 * 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); 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() { @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod( .addMethod(
@ -491,6 +605,27 @@ public final class BioHeadServiceGrpc {
cmvr.api.BioheadCommand.ExpressionTired.Request, cmvr.api.BioheadCommand.ExpressionTired.Request,
cmvr.api.BioheadCommand.ExpressionTired.Feedback>( cmvr.api.BioheadCommand.ExpressionTired.Feedback>(
this, METHODID_EXPRESSION_TIRED))) 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(); .build();
} }
} }
@ -598,6 +733,30 @@ public final class BioHeadServiceGrpc {
io.grpc.stub.ClientCalls.asyncUnaryCall( io.grpc.stub.ClientCalls.asyncUnaryCall(
getChannel().newCall(getExpressionTiredMethod(), getCallOptions()), request, responseObserver); 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( return io.grpc.stub.ClientCalls.blockingUnaryCall(
getChannel(), getExpressionTiredMethod(), getCallOptions(), request); 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( return io.grpc.stub.ClientCalls.futureUnaryCall(
getChannel().newCall(getExpressionTiredMethod(), getCallOptions()), request); 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; 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_HAPPY = 5;
private static final int METHODID_SURPRISE = 6; private static final int METHODID_SURPRISE = 6;
private static final int METHODID_EXPRESSION_TIRED = 7; 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 private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>, io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
@ -845,6 +1052,18 @@ public final class BioHeadServiceGrpc {
serviceImpl.expressionTired((cmvr.api.BioheadCommand.ExpressionTired.Request) request, serviceImpl.expressionTired((cmvr.api.BioheadCommand.ExpressionTired.Request) request,
(io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionTired.Feedback>) responseObserver); (io.grpc.stub.StreamObserver<cmvr.api.BioheadCommand.ExpressionTired.Feedback>) responseObserver);
break; 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: default:
throw new AssertionError(); throw new AssertionError();
} }
@ -918,6 +1137,9 @@ public final class BioHeadServiceGrpc {
.addMethod(getHappyMethod()) .addMethod(getHappyMethod())
.addMethod(getSurpriseMethod()) .addMethod(getSurpriseMethod())
.addMethod(getExpressionTiredMethod()) .addMethod(getExpressionTiredMethod())
.addMethod(getExpressionAngryMethod())
.addMethod(getExpressionSadnessMethod())
.addMethod(getExpressionYawnMethod())
.build(); .build();
} }
} }

View File

@ -24,7 +24,7 @@ public final class BioheadService {
static { static {
java.lang.String[] descriptorData = { java.lang.String[] descriptorData = {
"\n\036cmvr/api/biohead_service.proto\022\010cmvr.a" + "\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" + "ioHeadService\022`\n\rSetExpression\022%.cmvr.ap" +
"i.SetFacialExpression.Request\032&.cmvr.api" + "i.SetFacialExpression.Request\032&.cmvr.api" +
".SetFacialExpression.Feedback\"\000\022k\n\020Strea" + ".SetFacialExpression.Feedback\"\000\022k\n\020Strea" +
@ -44,7 +44,14 @@ public final class BioheadService {
"\033.cmvr.api.Surprise.Feedback\"\000\022Z\n\017Expres" + "\033.cmvr.api.Surprise.Feedback\"\000\022Z\n\017Expres" +
"sionTired\022!.cmvr.api.ExpressionTired.Req" + "sionTired\022!.cmvr.api.ExpressionTired.Req" +
"uest\032\".cmvr.api.ExpressionTired.Feedback" + "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 descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData, .internalBuildGeneratedFileFrom(descriptorData,

View File

@ -196,7 +196,7 @@ message SpeakStop {
// - // -
message Happy { message Happy {
message Request { message Request {
CommandHeader.Request header = 1; // CommandHeader.Request header = 1; //
@ -220,7 +220,7 @@ message Surprise {
} }
//-
message ExpressionTired { message ExpressionTired {
message Request { message Request {
CommandHeader.Request header = 1; CommandHeader.Request header = 1;
@ -230,3 +230,40 @@ message ExpressionTired {
CommandHeader.Feedback header = 1; 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;
}
}

View File

@ -31,6 +31,10 @@ service BioHeadService {
rpc ExpressionTired(ExpressionTired.Request) returns (ExpressionTired.Feedback){}; 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){};
} }

View File

@ -1,6 +1,7 @@
package com.cmvr.test.flow.runtime.operator.edge.vi; package com.cmvr.test.flow.runtime.operator.edge.vi;
import cmvr.api.SpeakerCommand; import cmvr.api.SpeakerCommand;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.cmvr.common.exception.GlobalException; import com.cmvr.common.exception.GlobalException;
import com.cmvr.edge.client.model.EdgeCommonVO; import com.cmvr.edge.client.model.EdgeCommonVO;
@ -40,37 +41,59 @@ public class ViPlayOperateService implements EdgeOperateService {
if (!action.equals(ActionEnum.VI_PLAY_CORPUS)) { if (!action.equals(ActionEnum.VI_PLAY_CORPUS)) {
throw new GlobalException("播放语料的action不是VI_PLAY_CORPUS"); throw new GlobalException("播放语料的action不是VI_PLAY_CORPUS");
} }
JSONObject inputParams = message.getInputParams(); JSONObject inputParams = message.getInputParams();
String deviceId = inputParams.getString("deviceId"); String deviceId = inputParams.getString("deviceId");
String bioId = inputParams.getString("bioId");
String audioPath = inputParams.getString("audioPath"); String audioPath = inputParams.getString("audioPath");
String terminalId = message.getTerminalId(); String terminalId = message.getTerminalId();
// 播放前调用张嘴
EdgeCommonVO edgeCommonVO = new EdgeCommonVO(); // 仅当 bioId 不为空时才构造 VO
edgeCommonVO.setDeviceId(deviceId); EdgeCommonVO edgeCommonVO = null;
edgeCommonVO.setTerminalId(terminalId); boolean needBioSpeak = StrUtil.isNotEmpty(bioId);
edgeBioHeadService.speakStart(edgeCommonVO); if (needBioSpeak) {
edgeCommonVO = new EdgeCommonVO();
edgeCommonVO.setDeviceId(bioId);
edgeCommonVO.setTerminalId(terminalId);
}
try { try {
// 播放音频
edgeSpeakerService.playAudio(terminalId, deviceId, audioPath); edgeSpeakerService.playAudio(terminalId, deviceId, audioPath);
// 等待播放完成
while (true) { // 播放开始时 bioId 存在才张嘴
if (needBioSpeak) {
try { try {
Thread.sleep(500); Thread.sleep(500);
edgeBioHeadService.speakStart(edgeCommonVO);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(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; break;
} }
} }
} finally { } finally {
// 播放完成调用闭嘴 // 播放完成后 bioId 存在才闭嘴
edgeBioHeadService.speakStop(edgeCommonVO); if (needBioSpeak) {
edgeBioHeadService.speakStop(edgeCommonVO);
}
} }
// todo 本机测试播放
// playAudio(audioPath);
return TaskNodeExecuteResult.success(); return TaskNodeExecuteResult.success();
} }

View File

@ -1,83 +1,68 @@
package com.cmvr.test.service; 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.model.EdgeCommonVO;
import com.cmvr.edge.client.service.EdgeBioHeadService; import com.cmvr.edge.client.service.EdgeBioHeadService;
import com.cmvr.edge.client.service.EdgeSpeakerService;
import com.cmvr.test.enums.FlowiseActionEnum; import com.cmvr.test.enums.FlowiseActionEnum;
import com.cmvr.test.model.vo.FlowiseActionRequestVO; import com.cmvr.test.model.vo.FlowiseActionRequestVO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class FlowiseActionService { public class FlowiseActionService {
private final EdgeBioHeadService edgeBioHeadService; private final EdgeBioHeadService edgeBioHeadService;
private final EdgeSpeakerService edgeSpeakerService;
public String execute(FlowiseActionRequestVO request) { public String command(FlowiseActionRequestVO request) {
String terminalId = "4ed1246c465b97975f96c9ef8371a3bd"; String terminalId = "4ed1246c465b97975f96c9ef8371a3bd";
String spkId = "spk1";
String bioId = "bio_head"; String bioId = "bio_head";
String action = request.getAction(); String action = request.getAction();
FlowiseActionEnum actionEnum = FlowiseActionEnum.fromAction(action); FlowiseActionEnum actionEnum = FlowiseActionEnum.fromAction(action);
String result;
switch (actionEnum) { 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: case SMILE:
return "微笑"; return edgeBioHeadService.specialExpression(terminalId, bioId, 1);
case SURPRISED: case SURPRISED:
return "惊讶"; return edgeBioHeadService.specialExpression(terminalId, bioId, 2);
case ANGRY: case ANGRY:
return "愤怒"; return edgeBioHeadService.specialExpression(terminalId, bioId, 3);
case SAD: case SAD:
return "悲伤"; return edgeBioHeadService.specialExpression(terminalId, bioId, 4);
case SLEEP: case SLEEP:
return "睡觉"; return edgeBioHeadService.specialExpression(terminalId, bioId, 5);
case YAWN: case YAWN:
return "打哈欠"; return edgeBioHeadService.specialExpression(terminalId, bioId, 6);
// ==== 动作 ====
default: default:
throw new UnsupportedOperationException("未实现的 Flowise Action: " + action); 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";
}
} }