jek 4 mesi fa
parent
commit
c76e4ac8ce

+ 0 - 34
src/main/java/com/zhili/stationcontrol/tts/configuration/RedisConfiguration.java

@@ -1,34 +0,0 @@
-package com.zhili.stationcontrol.tts.configuration;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-/**
- * @author :HuangBin
- * @description:TODO
- * @date :2022/9/28 10:44
- */
-
-@Configuration
-public class RedisConfiguration {
-    @Bean
-    public RedisTemplate redisTemplate(RedisConnectionFactory factory){
-        RedisTemplate redisTemplate = new RedisTemplate();
-        redisTemplate.setConnectionFactory(factory);
-        //解决key的序列化问题,字符串序列化,可读
-        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
-        redisTemplate.setKeySerializer(stringRedisSerializer);
-        //解决hashkey的序列化问题,字符串序列化,可读
-        redisTemplate.setHashKeySerializer(stringRedisSerializer);
-        //解决value的序列化问题,json序列化,可读
-        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
-        redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
-        //解决hashvalue的序列化问题,json序列化,可读
-        redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
-        return redisTemplate;
-    }
-}

+ 35 - 35
src/main/java/com/zhili/stationcontrol/tts/controller/TtsController.java

@@ -35,43 +35,43 @@ public class TtsController {
     @Autowired
     MusicService musicService;
 
-    @Value("${play_path:/static/wav/hdzqdd.wav}")
+    @Value("${play_path:/static/wav/music.wav}")
     String playPath;
 
-    @GetMapping("/speak/{txt}")
-    public String speak(@PathVariable String txt) {
-//        redisTemplate.opsForList().rightPush("ttsList", txt);
-        speak(txt,100);
-        return txt;
-    }
-
-    @GetMapping("/speak1/{txt}/{vol}")
-    public String speak(@PathVariable String txt,@PathVariable Integer vol) {
-        vol = vol > 1000 ? 1000 : vol;
-        vol = vol < 0 ? 0 : vol;
-        Map<String,Object> m = new HashMap();
-        m.put("txt",txt);
-        m.put("vol",vol);
-        redisTemplate.opsForList().rightPush("ttsList", JSON.toJSONString(m));
-        return txt;
-    }
-
-    @GetMapping("/speakFile/{fileName}")
-    public String speakFile(@PathVariable String fileName) {
-        String path = "/home/" + fileName + ".wav";
-        log.info("path:{}", path);
-        WavPlayUtil.play(path);
-        return fileName;
-    }
-
-    @GetMapping("/speakFile1/{fileName}")
-    public String speakFile1(@PathVariable String fileName) throws IOException, InterruptedException {
-        String path = "/home/" + fileName + ".wav";
-        log.info("path:{}", path);
-        Process exec = Runtime.getRuntime().exec("play " + path);
-        exec.waitFor();
-        return path;
-    }
+//    @GetMapping("/speak/{txt}")
+//    public String speak(@PathVariable String txt) {
+////        redisTemplate.opsForList().rightPush("ttsList", txt);
+//        speak(txt,100);
+//        return txt;
+//    }
+//
+//    @GetMapping("/speak1/{txt}/{vol}")
+//    public String speak(@PathVariable String txt,@PathVariable Integer vol) {
+//        vol = vol > 1000 ? 1000 : vol;
+//        vol = vol < 0 ? 0 : vol;
+//        Map<String,Object> m = new HashMap();
+//        m.put("txt",txt);
+//        m.put("vol",vol);
+//        redisTemplate.opsForList().rightPush("ttsList", JSON.toJSONString(m));
+//        return txt;
+//    }
+//
+//    @GetMapping("/speakFile/{fileName}")
+//    public String speakFile(@PathVariable String fileName) {
+//        String path = "/home/" + fileName + ".wav";
+//        log.info("path:{}", path);
+//        WavPlayUtil.play(path);
+//        return fileName;
+//    }
+//
+//    @GetMapping("/speakFile1/{fileName}")
+//    public String speakFile1(@PathVariable String fileName) throws IOException, InterruptedException {
+//        String path = "/home/" + fileName + ".wav";
+//        log.info("path:{}", path);
+//        Process exec = Runtime.getRuntime().exec("play " + path);
+//        exec.waitFor();
+//        return path;
+//    }
 
     @GetMapping("/startMusic/{vol}")
     public String startMusic(@PathVariable Integer vol) {

+ 2 - 4
src/main/resources/application-prod.yml

@@ -2,7 +2,5 @@ server:
   port: 8050
 
 spring:
-  redis:
-    host: redis
-    port: 6379
-    #password: 123456
+  resources:
+    static-locations: classpath:/static/

+ 2 - 3
src/main/resources/application-test.yml

@@ -2,6 +2,5 @@ server:
   port: 8050
 
 spring:
-  redis:
-    host: 192.168.3.120
-    port: 6379
+  resources:
+    static-locations: classpath:/static/

+ 0 - 4
src/main/resources/application.yml

@@ -2,9 +2,5 @@ server:
   port: 8050
 
 spring:
-  redis:
-    host: 127.0.0.1
-    port: 6379
-#    password: 123456
   resources:
     static-locations: classpath:/static/

BIN
src/main/resources/static/wav/music.mp3