Skip to content

Commit 376ae8d

Browse files
committed
feat:update TTS voice diy and update LLMFactory
1 parent 95659b4 commit 376ae8d

27 files changed

+1644
-615
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mysql,redis,emqx和influxdb环境。
8888
欢迎加入群聊一起交流讨论有关Aiot相关的话题,免费获取智控台的前端源码,链接过期了可以issue或email提醒一下作者。
8989

9090
<div style="width: 250px;margin: 0 auto;">
91-
<img src="./images/f05e3fe25dd4196e9abfbe4d8d2b8ed1.jpg" width="250px"/>
91+
<img src="./images/4540285aafc3cee1c3c117a5fbf2c15c.jpg" width="250px"/>
9292
</div>
9393

9494

165 KB
Loading
-166 KB
Binary file not shown.

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ mysql,redis,emqx和influxdb环境,安装详情请看官方文档。
116116
欢迎加入群聊一起交流讨论有关Aiot相关的话题,有机会获取项目的免费部署咨询,链接过期了可以issue或email提醒一下作者。
117117

118118
<div style="width: 250px;margin: 0 auto;">
119-
<img src="./docs/images/f05e3fe25dd4196e9abfbe4d8d2b8ed1.jpg" width="250px"/>
119+
<img src="./docs/images/4540285aafc3cee1c3c117a5fbf2c15c.jpg" width="250px"/>
120120
</div>
121121

122122
## 致谢

src/main/java/top/rslly/iot/controllers/Tool.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public class Tool {
8383
private ProductToolsBanServiceImpl productToolsBanService;
8484
@Autowired
8585
private AgentLongMemoryServiceImpl agentLongMemoryService;
86+
@Autowired
87+
private ProductVoiceDiyServiceImpl productVoiceDiyService;
8688

8789
@Operation(summary = "用于获取平台运行环境信息", description = "单位为百分比")
8890
@RequestMapping(value = "/machineMessage", method = RequestMethod.GET)
@@ -526,4 +528,44 @@ public JsonResult<?> deleteLongMemory(@RequestParam("id") int id,
526528
return agentLongMemoryService.deleteLongMemory(id);
527529
}
528530

531+
@Operation(summary = "获取产品语音定制", description = "获取产品语音定制")
532+
@RequestMapping(value = "/productVoiceDiy", method = RequestMethod.GET)
533+
public JsonResult<?> getProductVoiceDiy(@RequestParam("productId") int productId,
534+
@RequestHeader("Authorization") String header) {
535+
try {
536+
if (!safetyService.controlAuthorizeProduct(header, productId))
537+
return ResultTool.fail(ResultCode.NO_PERMISSION);
538+
} catch (NullPointerException e) {
539+
return ResultTool.fail(ResultCode.PARAM_NOT_VALID);
540+
}
541+
return productVoiceDiyService.getProductVoiceDiy(productId);
542+
}
543+
544+
@Operation(summary = "提交/修改产品语音定制", description = "提交/修改产品语音定制")
545+
@RequestMapping(value = "/productVoiceDiy", method = RequestMethod.POST)
546+
public JsonResult<?> postProductVoiceDiy(
547+
@Valid @RequestBody ProductVoiceDiy productVoiceDiy,
548+
@RequestHeader("Authorization") String header) {
549+
try {
550+
if (!safetyService.controlAuthorizeProduct(header, productVoiceDiy.getProductId()))
551+
return ResultTool.fail(ResultCode.NO_PERMISSION);
552+
} catch (NullPointerException e) {
553+
return ResultTool.fail(ResultCode.PARAM_NOT_VALID);
554+
}
555+
return productVoiceDiyService.postProductVoiceDiy(productVoiceDiy);
556+
}
557+
558+
@Operation(summary = "删除产品语音定制", description = "删除产品语音定制")
559+
@RequestMapping(value = "/productVoiceDiy", method = RequestMethod.DELETE)
560+
public JsonResult<?> deleteProductVoiceDiy(@RequestParam("id") int id,
561+
@RequestHeader("Authorization") String header) {
562+
try {
563+
if (!safetyService.controlAuthorizeProductVoiceDiy(header, id))
564+
return ResultTool.fail(ResultCode.NO_PERMISSION);
565+
} catch (NullPointerException e) {
566+
return ResultTool.fail(ResultCode.PARAM_NOT_VALID);
567+
}
568+
return productVoiceDiyService.deleteProductVoiceDiy(id);
569+
}
570+
529571
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.dao;
21+
22+
import org.springframework.data.jpa.repository.JpaRepository;
23+
import org.springframework.transaction.annotation.Transactional;
24+
import top.rslly.iot.models.ProductVoiceDiyEntity;
25+
26+
import java.util.List;
27+
28+
public interface ProductVoiceDiyRepository extends JpaRepository<ProductVoiceDiyEntity, Long> {
29+
List<ProductVoiceDiyEntity> findAllById(int id);
30+
31+
List<ProductVoiceDiyEntity> findAllByProductId(int productId);
32+
33+
@Transactional
34+
List<ProductVoiceDiyEntity> deleteAllById(int id);
35+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.models;
21+
22+
import javax.persistence.*;
23+
import java.util.Objects;
24+
25+
@Entity
26+
@Table(name = "product_voice_diy", schema = "cwliot1.8", catalog = "")
27+
public class ProductVoiceDiyEntity {
28+
private int id;
29+
private int productId;
30+
private String pitch;
31+
private String speed;
32+
33+
@Id
34+
@GeneratedValue(strategy = GenerationType.IDENTITY)
35+
@Column(name = "id")
36+
public int getId() {
37+
return id;
38+
}
39+
40+
public void setId(int id) {
41+
this.id = id;
42+
}
43+
44+
@Basic
45+
@Column(name = "product_id")
46+
public int getProductId() {
47+
return productId;
48+
}
49+
50+
public void setProductId(int productId) {
51+
this.productId = productId;
52+
}
53+
54+
@Basic
55+
@Column(name = "pitch")
56+
public String getPitch() {
57+
return pitch;
58+
}
59+
60+
public void setPitch(String pitch) {
61+
this.pitch = pitch;
62+
}
63+
64+
@Basic
65+
@Column(name = "speed")
66+
public String getSpeed() {
67+
return speed;
68+
}
69+
70+
public void setSpeed(String speed) {
71+
this.speed = speed;
72+
}
73+
74+
@Override
75+
public boolean equals(Object o) {
76+
if (this == o)
77+
return true;
78+
if (o == null || getClass() != o.getClass())
79+
return false;
80+
ProductVoiceDiyEntity that = (ProductVoiceDiyEntity) o;
81+
return id == that.id && productId == that.productId && Objects.equals(pitch, that.pitch)
82+
&& Objects.equals(speed, that.speed);
83+
}
84+
85+
@Override
86+
public int hashCode() {
87+
return Objects.hash(id, productId, pitch, speed);
88+
}
89+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.param.request;
21+
22+
import lombok.Data;
23+
24+
import javax.validation.constraints.*;
25+
26+
@Data
27+
public class ProductVoiceDiy {
28+
private int productId;
29+
@NotNull(message = "pitch 不能为空")
30+
@DecimalMin(value = "0.5", message = "pitch 不能小于 0.5")
31+
@DecimalMax(value = "2.0", message = "pitch 不能大于 2.0")
32+
private Float pitch;
33+
34+
@NotNull(message = "speed 不能为空")
35+
@DecimalMin(value = "0.5", message = "speed 不能小于 0.5")
36+
@DecimalMax(value = "2.0", message = "speed 不能大于 2.0")
37+
private Float speed;
38+
}

src/main/java/top/rslly/iot/services/SafetyService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,6 @@ public interface SafetyService {
5757
boolean controlAuthorizeProductRouterSet(String token, int id);
5858

5959
boolean controlAuthorizeAgentLongMemory(String token, int id);
60+
61+
boolean controlAuthorizeProductVoiceDiy(String token, int id);
6062
}

src/main/java/top/rslly/iot/services/SafetyServiceImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ public class SafetyServiceImpl implements SafetyService {
7979
private OtaXiaozhiPassiveServiceImpl otaXiaozhiPassiveService;
8080
@Autowired
8181
private AgentLongMemoryServiceImpl agentLongMemoryService;
82+
@Autowired
83+
private ProductVoiceDiyServiceImpl productVoiceDiyService;
8284

8385
@Override
8486
public boolean controlAuthorizeModel(String token, int modelId) {
@@ -251,6 +253,16 @@ public boolean controlAuthorizeAgentLongMemory(String token, int id) {
251253
agentLongMemoryEntityList.get(0).getProductId());
252254
}
253255

256+
@Override
257+
public boolean controlAuthorizeProductVoiceDiy(String token, int id) {
258+
List<ProductVoiceDiyEntity> productVoiceDiyEntityList =
259+
productVoiceDiyService.findAllById(id);
260+
if (productVoiceDiyEntityList.isEmpty())
261+
throw new NullPointerException("productVoiceDiyId not found!");
262+
return this.controlAuthorizeProduct(token,
263+
productVoiceDiyEntityList.get(0).getProductId());
264+
}
265+
254266
@Override
255267
public boolean controlAuthorizeProduct(String token, int productId) {
256268
String token_deal = token.replace(JwtTokenUtil.TOKEN_PREFIX, "");

0 commit comments

Comments
 (0)