diff --git a/src/main/java/com/smart/watchboard/dto/SttRequestDto.java b/src/main/java/com/smart/watchboard/dto/SttRequestDto.java new file mode 100644 index 0000000..6bc936a --- /dev/null +++ b/src/main/java/com/smart/watchboard/dto/SttRequestDto.java @@ -0,0 +1,14 @@ +package com.smart.watchboard.dto; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class SttRequestDto { + private String audioUrl; + + public SttRequestDto(String audioUrl) { + this.audioUrl = audioUrl; + } +} diff --git a/src/main/java/com/smart/watchboard/service/STTService.java b/src/main/java/com/smart/watchboard/service/STTService.java index 0f1a7c5..dc25fd5 100644 --- a/src/main/java/com/smart/watchboard/service/STTService.java +++ b/src/main/java/com/smart/watchboard/service/STTService.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.smart.watchboard.domain.SttData; +import com.smart.watchboard.dto.SttRequestDto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -23,26 +24,18 @@ @RequiredArgsConstructor @Slf4j public class STTService { - @Value("${clova.stt.secret-key}") - private String secretKey; - - @Value("${clova.stt.invoke-url}") - private String clovaInvokeURL; + @Value("${ai-url}") + private String aiUrl; public ResponseEntity getSTT(String path) throws JsonProcessingException { + String url = aiUrl + "/stt"; + // RestTemplate restTemplate = new RestTemplate(); - String requestURL = clovaInvokeURL + "/recognizer/url"; HttpHeaders headers = new HttpHeaders(); headers.set("Content-Type", "application/json"); - headers.set("X-CLOVASPEECH-API-KEY", secretKey); - String requestBody = "{" + - "\"url\": \"" + path + "\", " + - "\"language\": \"ko-KR\", " + - "\"completion\": \"sync\"" + - "}"; - HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); - System.out.println(requestEntity.getBody()); - ResponseEntity responseEntity = restTemplate.exchange(requestURL, HttpMethod.POST, requestEntity, String.class); + SttRequestDto sttRequestDto = new SttRequestDto(path); + HttpEntity requestEntity = new HttpEntity<>(sttRequestDto, headers); + ResponseEntity responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); return responseEntity; } @@ -62,9 +55,6 @@ public List getSTTData(ResponseEntity sttResponseEntity) throws sttDatas.add(sttData); } - //result.put("data", sttDatas); - - //return result; return sttDatas; }