Browse Source

fish proxy

wangyunpeng 3 tháng trước cách đây
mục cha
commit
b84e0e4c73

+ 6 - 1
core/src/main/java/com/tzld/supply/api/fish/FishApiServiceImpl.java

@@ -22,6 +22,7 @@ import lombok.experimental.Accessors;
 import lombok.extern.slf4j.Slf4j;
 import org.msgpack.jackson.dataformat.MessagePackFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -41,6 +42,9 @@ public class FishApiServiceImpl implements FishApiService {
 
     private static final String apiKey = "0891f3f93a2640428f9988e267aa57e1";
 
+    @Value("${api.proxy.url:http://47.242.29.135:8080/proxy/byte}")
+    private String proxyUrl;
+
     @Override
     public void importTTSModels(String speakerId) {
         if (StringUtils.hasText(speakerId)) {
@@ -186,6 +190,7 @@ public class FishApiServiceImpl implements FishApiService {
         }
         String apiUrl = "https://api.fish.audio/v1/tts";
         Map<String, String> headerMap = buildCommonHeaderMap();
+        headerMap.put("Target-URL", apiUrl);
         Map<String, String> paramMap = new HashMap<>();
         paramMap.put("reference_id", speakerId);
         paramMap.put("text", text);
@@ -195,7 +200,7 @@ public class FishApiServiceImpl implements FishApiService {
         int retryTimes = 0;
         do {
             retryTimes++;
-            HttpResponseContent hrc = HttpClientUtils.postDataAddHeader(apiUrl, JSON.toJSONString(paramMap), headerMap,
+            HttpResponseContent hrc = HttpClientUtils.postDataAddHeader(proxyUrl, JSON.toJSONString(paramMap), headerMap,
                     10000, 1800000);
             if (Objects.isNull(hrc)) {
                 log.error("fishTTS hrc is null,bizId:{}", bizId);