调整 音频合成

This commit is contained in:
spllzh
2025-10-06 12:17:34 +08:00
parent 725a5294d0
commit 20378e8115
43 changed files with 508 additions and 60 deletions

View File

@@ -88,6 +88,11 @@ public class AliyunConfig {

View File

@@ -1,48 +1,26 @@
package com.rj.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* RestTemplate 配置类
* RestTemplate配置类
*
* @author rj
* @date 2025-01-02
*/
@Configuration
public class RestTemplateConfig {
/**
* 创建RestTemplate Bean
* 支持音频流响应处理
*
* @return RestTemplate实例
*/
@Bean
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(30000); // 连接超时30秒
factory.setReadTimeout(60000); // 读取超时60秒
RestTemplate restTemplate = new RestTemplate(factory);
// 添加支持音频流的HttpMessageConverter
ByteArrayHttpMessageConverter audioConverter = new ByteArrayHttpMessageConverter();
audioConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.valueOf("audio/mpeg")));
List<org.springframework.http.converter.HttpMessageConverter<?>> messageConverters =
new ArrayList<>(restTemplate.getMessageConverters());
messageConverters.add(audioConverter);
restTemplate.setMessageConverters(messageConverters);
return restTemplate;
return new RestTemplate();
}
}
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper();
}
}