Skip to content

Commit 9f22841

Browse files
committed
整合语音识别及大模型生成像素流
1 parent 2b83944 commit 9f22841

File tree

21 files changed

+506
-359
lines changed

21 files changed

+506
-359
lines changed

1691746954524.pcm

720 KB
Binary file not shown.

ruoyi-admin/src/main/resources/application.yml

+11-3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ xss:
129129
excludes: /system/notice
130130
# 匹配链接
131131
urlPatterns: /system/*,/monitor/*,/tool/*
132-
bigModel:
133-
interpreterLocation: C:\Buffer\gpt\gpt-main\webui\python\python
134-
scriptLocation: training_wizardcoder_mydata.py
132+
simulation:
133+
python:
134+
interpreterLocation: C:/Buffer/gpt/gpt-main/webui/python
135+
scriptLocation:
136+
getPaddleSpeechVoice: C:/Buffer/PaddleS/generateVoice.py
137+
getPaddleSpeechText: C:/Buffer/PaddleS/generateText.py
138+
generateCode: C:/Buffer/gpt/gpt-main/webui/training_wizardcoder_mydata.py
139+
matlab:
140+
interpreterLocation: C:/Users/Administrator/Desktop/RoadManager/matlab/matlab_2022b/bin
141+
scriptLocation: C:/Buffer/gpt/gpt-main/webui/sim/main.m
142+
filepath: D:/users/alanYang/documents/accessory/intelligentTraffic/simulation

ruoyi-simulation/lib/engine.jar

433 KB
Binary file not shown.

ruoyi-simulation/lib/javabuilder.jar

220 KB
Binary file not shown.

ruoyi-simulation/pom.xml

+39-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<version>3.8.5</version>
88
</parent>
99
<artifactId>ruoyi-simulation</artifactId>
10-
<packaging>war</packaging>
10+
<packaging>jar</packaging>
1111
<name>ruoyi-simulation Maven Webapp</name>
1212
<url>http://maven.apache.org</url>
1313
<dependencies>
@@ -24,8 +24,46 @@
2424
<groupId>org.springframework.boot</groupId>
2525
<artifactId>spring-boot-starter-websocket</artifactId>
2626
</dependency>
27+
<dependency>
28+
<groupId>commons-io</groupId>
29+
<artifactId>commons-io</artifactId>
30+
<version>2.13.0</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>javazoom</groupId>
34+
<artifactId>jlayer</artifactId>
35+
<version>1.0.1</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>javabuilder</groupId>
39+
<artifactId>javabuilder</artifactId>
40+
<version>2022</version>
41+
<scope>system</scope>
42+
<systemPath>${basedir}/lib/javabuilder.jar</systemPath>
43+
</dependency>
44+
<dependency>
45+
<groupId>engine</groupId>
46+
<artifactId>engine</artifactId>
47+
<version>2022</version>
48+
<scope>system</scope>
49+
<systemPath>${basedir}/lib/engine.jar</systemPath>
50+
</dependency>
2751
</dependencies>
2852
<build>
2953
<finalName>ruoyi-simulation</finalName>
54+
<resources>
55+
<resource>
56+
<directory>lib</directory>
57+
<targetPath>BOOT-INF/lib/</targetPath>
58+
<includes>
59+
<include>lib/javabuilder.jar</include>
60+
<include>lib/engine.jar</include>
61+
</includes>
62+
</resource>
63+
<resource>
64+
<directory>src/main/resources</directory>
65+
<targetPath>BOOT-INF/classes</targetPath>
66+
</resource>
67+
</resources>
3068
</build>
3169
</project>

ruoyi-simulation/src/main/java/com/ruoyi/simulation/config/WebSocketConfig.java

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.springframework.context.annotation.Bean;
44
import org.springframework.context.annotation.Configuration;
55
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
6+
import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
67

78
/**
89
* websocket配置类
@@ -13,4 +14,11 @@ public class WebSocketConfig {
1314
public ServerEndpointExporter serverEndpointExporter(){
1415
return new ServerEndpointExporter();
1516
}
17+
@Bean
18+
public ServletServerContainerFactoryBean createWebSocketContainer(){
19+
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
20+
container.setMaxTextMessageBufferSize(1024*1024);
21+
container.setMaxBinaryMessageBufferSize(1024*1024*50);
22+
return container;
23+
}
1624
}

ruoyi-simulation/src/main/java/com/ruoyi/simulation/service/IScenarioService.java

-17
This file was deleted.

ruoyi-simulation/src/main/java/com/ruoyi/simulation/service/impl/ScenarioServiceImpl.java

-30
This file was deleted.

ruoyi-simulation/src/main/java/com/ruoyi/simulation/util/CallBigModel.java

-104
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.ruoyi.simulation.util;
2+
3+
import com.google.common.io.ByteStreams;
4+
import com.ruoyi.common.core.domain.AjaxResult;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
import org.springframework.core.env.Environment;
8+
import org.springframework.stereotype.Component;
9+
10+
import javax.annotation.Resource;
11+
import java.io.*;
12+
import java.util.List;
13+
14+
/**
15+
* 大模型matlab脚本调用工具类
16+
*/
17+
@Component
18+
public class CallMatlab {
19+
private Logger logger = LoggerFactory.getLogger(CallPython.class);
20+
@Resource
21+
private Environment environment;
22+
/**
23+
* 生成三维场景像素流
24+
* @param codeList 代码
25+
* @return
26+
* @throws IOException
27+
* @throws InterruptedException
28+
*/
29+
public synchronized AjaxResult generatePixelStream(List<String> codeList) {
30+
AjaxResult result = null;
31+
BufferedReader bufferedReader = null;
32+
BufferedWriter bufferedWriter = null;
33+
try{
34+
//将脚本代码存储到matlab项目下的code.m文件中,等待被matlab调用
35+
String targetPath = environment.getProperty("simulation.matlab.scriptLocation")+ File.separator+"code.m";
36+
File file = new File(targetPath);
37+
FileOutputStream ous = new FileOutputStream(file);
38+
bufferedWriter = new BufferedWriter(new OutputStreamWriter(ous,"utf-8"));
39+
for(String line: codeList){
40+
bufferedWriter.write(line);
41+
bufferedWriter.newLine();
42+
}
43+
//调用matlab命令执行code.m文件
44+
String interpreterLocation = environment.getProperty("simulation.matlab.interpreterLocation");
45+
String scriptLocation = environment.getProperty("simulation.matlab.scriptLocation");
46+
Runtime runtime = Runtime.getRuntime();
47+
runtime.exec("cd "+interpreterLocation);
48+
Process process = runtime.exec("matlab -nojvm -nodesktop -nodisplay -r '"+scriptLocation+"'");
49+
//获取执行结果
50+
InputStream ins = process.getErrorStream();
51+
if(ins!=null&&ins.available()>0){
52+
bufferedReader = new BufferedReader(new InputStreamReader(ins,"utf-8"));
53+
String str = null;
54+
while((str = bufferedReader.readLine())!=null){
55+
logger.error(str);
56+
}
57+
result = AjaxResult.error("生成三维场景像素流失败!");
58+
}else{
59+
ins = process.getInputStream();
60+
byte[] byteArray = ByteStreams.toByteArray(ins);
61+
StreamSet stream = new StreamSet();
62+
stream.setGraph(byteArray);
63+
result = AjaxResult.success(stream);
64+
}
65+
process.waitFor();
66+
} catch (Exception e){
67+
logger.error(LoggerUtil.getLoggerStace(e));
68+
result = AjaxResult.error("生成三维场景像素流失败!");
69+
} finally {
70+
try {
71+
if(bufferedReader!=null) {
72+
bufferedReader.close();
73+
}
74+
} catch (IOException e) {
75+
logger.error(LoggerUtil.getLoggerStace(e));
76+
}
77+
try {
78+
if(bufferedWriter!=null) {
79+
bufferedWriter.close();
80+
}
81+
} catch (IOException e) {
82+
logger.error(LoggerUtil.getLoggerStace(e));
83+
}
84+
}
85+
return result;
86+
}
87+
}

0 commit comments

Comments
 (0)