From 1f6ba4c179b6a3286df71401168b149e6a92f3b6 Mon Sep 17 00:00:00 2001 From: ch8930 Date: Wed, 17 Jul 2024 13:49:17 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20TT-268=20stt=20process=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=EA=B3=BC=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 문단 나누기 api가 slicing한 문장을 기반으로 타임체크를 하는 로직 추가 - 기존에 stt 문장을 '.' 단위로 나누던 로직 삭제 --- .../peech/script/service/SentenceService.java | 14 ++-- ...eVO.java => AddSentenceInformationVO.java} | 2 +- .../response/ParagraphDivideResponseDto.java | 4 +- .../dto/response/STTResultResponseDto.java | 20 ------ .../stt/dto/response/STTResultResponseVO.java | 21 ------ .../service/AddRealTimeToSentenceService.java | 49 +++++++++++++ .../stt/service/CreateSTTResultService.java | 69 +++++++------------ .../EditClovaSpeechResponseService.java | 55 --------------- .../script/stt/service/ProcessSTTService.java | 41 ++++++----- .../script/stt/utils/MergeWordListUtils.java | 20 ++++++ 10 files changed, 123 insertions(+), 172 deletions(-) rename src/main/java/com/twentythree/peech/script/stt/dto/{EditClovaSpeechSentenceVO.java => AddSentenceInformationVO.java} (85%) delete mode 100644 src/main/java/com/twentythree/peech/script/stt/dto/response/STTResultResponseDto.java delete mode 100644 src/main/java/com/twentythree/peech/script/stt/dto/response/STTResultResponseVO.java create mode 100644 src/main/java/com/twentythree/peech/script/stt/service/AddRealTimeToSentenceService.java delete mode 100644 src/main/java/com/twentythree/peech/script/stt/service/EditClovaSpeechResponseService.java create mode 100644 src/main/java/com/twentythree/peech/script/stt/utils/MergeWordListUtils.java diff --git a/src/main/java/com/twentythree/peech/script/service/SentenceService.java b/src/main/java/com/twentythree/peech/script/service/SentenceService.java index 46af51e8..7936b207 100644 --- a/src/main/java/com/twentythree/peech/script/service/SentenceService.java +++ b/src/main/java/com/twentythree/peech/script/service/SentenceService.java @@ -6,8 +6,7 @@ import com.twentythree.peech.script.domain.SentenceEntity; import com.twentythree.peech.script.dto.paragraphIdToExpectedTime; import com.twentythree.peech.script.repository.SentenceRepository; -import com.twentythree.peech.script.stt.dto.EditClovaSpeechSentenceVO; -import com.twentythree.peech.script.stt.dto.SentenceVO; +import com.twentythree.peech.script.stt.dto.AddSentenceInformationVO; import com.twentythree.peech.script.stt.utils.RealTimeUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -48,23 +47,22 @@ public List saveInputSentencesByParagraphs(ScriptEntity scriptEntity, Stri } @Transactional - public List saveSTTSentences(ScriptEntity scriptEntity, List sentenceAndRealTimeList, List> sentenceSpan) { + public List saveSTTSentences(ScriptEntity scriptEntity, List sentenceAndRealTimeList, List> sentenceSpan) { Long paragraphId = 0L; - List sentenceVOList = new ArrayList<>(); + List sentenceEntityList = new ArrayList<>(); for(List paragraph : sentenceSpan) { for (Integer index : paragraph) { - EditClovaSpeechSentenceVO sentence = sentenceAndRealTimeList.get(index); + AddSentenceInformationVO sentence = sentenceAndRealTimeList.get(index); SentenceEntity sentenceEntity = SentenceEntity.ofCreateSTTSentence(scriptEntity, paragraphId, sentence.sentenceContent(), sentence.sentenceOrder(), RealTimeUtils.convertMsToTimeFormat(sentence.sentenceDuration())); sentenceRepository.save(sentenceEntity); - SentenceVO sentenceVO = new SentenceVO(sentenceEntity); - sentenceVOList.add(sentenceVO); + sentenceEntityList.add(sentenceEntity); } paragraphId++; } - return sentenceVOList; + return sentenceEntityList; } public List getParagraphExpectedTime(Long scriptId) { diff --git a/src/main/java/com/twentythree/peech/script/stt/dto/EditClovaSpeechSentenceVO.java b/src/main/java/com/twentythree/peech/script/stt/dto/AddSentenceInformationVO.java similarity index 85% rename from src/main/java/com/twentythree/peech/script/stt/dto/EditClovaSpeechSentenceVO.java rename to src/main/java/com/twentythree/peech/script/stt/dto/AddSentenceInformationVO.java index 4e89d8ed..c23e0c4e 100644 --- a/src/main/java/com/twentythree/peech/script/stt/dto/EditClovaSpeechSentenceVO.java +++ b/src/main/java/com/twentythree/peech/script/stt/dto/AddSentenceInformationVO.java @@ -4,7 +4,7 @@ import java.time.LocalTime; -public record EditClovaSpeechSentenceVO( +public record AddSentenceInformationVO( Long sentenceOrder, String sentenceContent, int sentenceDuration diff --git a/src/main/java/com/twentythree/peech/script/stt/dto/response/ParagraphDivideResponseDto.java b/src/main/java/com/twentythree/peech/script/stt/dto/response/ParagraphDivideResponseDto.java index 5a528ae8..a5eb7eba 100644 --- a/src/main/java/com/twentythree/peech/script/stt/dto/response/ParagraphDivideResponseDto.java +++ b/src/main/java/com/twentythree/peech/script/stt/dto/response/ParagraphDivideResponseDto.java @@ -21,9 +21,9 @@ public class ParagraphDivideResponseDto { @JsonIgnoreProperties(ignoreUnknown = true) public static class Result { - @JsonProperty("paragraphs") + @JsonProperty("paragraphList") @JsonAlias("topicSeg") - private List> paragraphs; + private List> paragraphList; @JsonProperty("span") private List> span; diff --git a/src/main/java/com/twentythree/peech/script/stt/dto/response/STTResultResponseDto.java b/src/main/java/com/twentythree/peech/script/stt/dto/response/STTResultResponseDto.java deleted file mode 100644 index 9dda2cff..00000000 --- a/src/main/java/com/twentythree/peech/script/stt/dto/response/STTResultResponseDto.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.twentythree.peech.script.stt.dto.response; - -import java.time.LocalTime; -import java.util.List; - -public record STTResultResponseDto( - LocalTime realTimePerScript, - List paragraphs -) { - public record Paragraph( - Long paragraphId, - List sentences, - LocalTime realTimePerParagraph - ){ - public record Sentence( - Long sentenceId, - String sentenceContent - ){} - } -} diff --git a/src/main/java/com/twentythree/peech/script/stt/dto/response/STTResultResponseVO.java b/src/main/java/com/twentythree/peech/script/stt/dto/response/STTResultResponseVO.java deleted file mode 100644 index 22a41ffd..00000000 --- a/src/main/java/com/twentythree/peech/script/stt/dto/response/STTResultResponseVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.twentythree.peech.script.stt.dto.response; - -import java.time.LocalTime; -import java.util.List; - -// 클라이언트에게 전달할 STT 결과 응답 VO -public record STTResultResponseVO( - LocalTime realTimePerScript, - List paragraphs -) { - public record Paragraph( - int paragraphId, - List sentences, - LocalTime realTimePerParagraph - ){ - public record Sentence( - int sentenceId, - String sentenceContent - ){} - } -} \ No newline at end of file diff --git a/src/main/java/com/twentythree/peech/script/stt/service/AddRealTimeToSentenceService.java b/src/main/java/com/twentythree/peech/script/stt/service/AddRealTimeToSentenceService.java new file mode 100644 index 00000000..6848181a --- /dev/null +++ b/src/main/java/com/twentythree/peech/script/stt/service/AddRealTimeToSentenceService.java @@ -0,0 +1,49 @@ +package com.twentythree.peech.script.stt.service; + +import com.twentythree.peech.script.stt.dto.AddSentenceInformationVO; +import com.twentythree.peech.script.stt.dto.response.ClovaResponseDto; +import com.twentythree.peech.script.stt.dto.response.ParagraphDivideResponseDto; +import com.twentythree.peech.script.stt.utils.MergeWordListUtils; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +@RequiredArgsConstructor +public class AddRealTimeToSentenceService { + public List addRealTimeToSentence(ClovaResponseDto clovaResponseDto, ParagraphDivideResponseDto paragraphDivideResponseDto) { + + // AddSentenceInformationVO 객체 리스트를 만들어야 함 + List AddSentenceInformationVOList = new ArrayList<>(); + + // 문단 나누기 결과 가져오기 + List sentenceList = paragraphDivideResponseDto.getResult().getParagraphList().stream().flatMap(List::stream).toList(); + + // clovaResponseDto에서 wordList 가져오기 + List> wordList = MergeWordListUtils.mergeWordList(clovaResponseDto); + + int startIndex = 0; + int endIndex = 0; + int startStamp = 0; + int endStamp = 0; + long sentenceOrder = 0L; + + // 문장의 단어 개수를 기반으로 문장의 시작 시간과 종료 시간을 계산 + for(String sentence : sentenceList){ + startStamp = (int) wordList.get(startIndex).get(0); + // 해당 문장의 단어 개수를 알아야함 + int wordCount = sentence.split(" ").length; + endIndex = startIndex + wordCount - 1; + endStamp = (int) wordList.get(endIndex).get(1); + int duration = endStamp - startStamp; + + AddSentenceInformationVO AddSentenceInformationVO = new AddSentenceInformationVO(++sentenceOrder, sentence, duration); + AddSentenceInformationVOList.add(AddSentenceInformationVO); + startIndex = endIndex + 1; + } + + return AddSentenceInformationVOList; + } +} diff --git a/src/main/java/com/twentythree/peech/script/stt/service/CreateSTTResultService.java b/src/main/java/com/twentythree/peech/script/stt/service/CreateSTTResultService.java index f69a88d1..009264f6 100644 --- a/src/main/java/com/twentythree/peech/script/stt/service/CreateSTTResultService.java +++ b/src/main/java/com/twentythree/peech/script/stt/service/CreateSTTResultService.java @@ -2,19 +2,17 @@ package com.twentythree.peech.script.stt.service; import com.twentythree.peech.script.cache.RedisTemplateImpl; +import com.twentythree.peech.script.domain.SentenceEntity; import com.twentythree.peech.script.dto.NowStatus; -import com.twentythree.peech.script.dto.RedisSentenceDTO; -import com.twentythree.peech.script.stt.dto.EditClovaSpeechSentenceVO; -import com.twentythree.peech.script.stt.dto.STTResultSentenceDto; -import com.twentythree.peech.script.stt.dto.SentenceVO; import com.twentythree.peech.script.stt.dto.response.*; -import com.twentythree.peech.script.stt.utils.RealTimeUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.time.LocalTime; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; // STT 결과를 클라이언트에게 전달할 VO 생성 @Service @@ -23,58 +21,37 @@ public class CreateSTTResultService { private final RedisTemplateImpl redisTemplateImpl; - public STTScriptResponseDTO createSTTResultResponseDto(ClovaResponseDto clovaResponseDto, List sentenceAndRealTimeList, List sentenceVOList, ParagraphDivideResponseDto paragraphDivideResponseDto) { + public STTScriptResponseDTO createSTTResultResponseDto(ClovaResponseDto clovaResponseDto, List sentenceEntityList) { - int timestamp; - Long paragraphId = 0L; - Long paragraphOrder = 0L; - List sttResultSentenceDtoList = new ArrayList<>(); + // 문단별로 그룹핑 + Map> sentenceListGroupByParagraph = sentenceEntityList.stream().collect(Collectors.groupingBy(SentenceEntity::getParagraphId)); - // 전체 대본 소요 시간 - LocalTime totalRealTime = clovaResponseDto.getTotalRealTime(); - - // sttSentenceDto 리스트에 있는 타임 스탬프들을 가져옴 - List sentencesRealTimeList = sentenceAndRealTimeList - .stream().map(EditClovaSpeechSentenceVO::sentenceDuration) - .toList(); - - for(int i = 0; i < sentencesRealTimeList.size(); i++){ - SentenceVO sentenceVO = sentenceVOList.get(i); - - Long id = sentenceVO.sentenceEntity().getSentenceId(); - Long order = sentenceVO.sentenceEntity().getSentenceOrder(); - String content = sentenceVO.sentenceEntity().getSentenceContent(); - - STTResultSentenceDto sttResultSentenceDto = new STTResultSentenceDto(id, order, content, sentencesRealTimeList.get(i)); - sttResultSentenceDtoList.add(sttResultSentenceDto); - } + List paragraphList = new ArrayList<>(); - // paragraphDevideResponseDto에서 문단별로 나눈 index를 가져옴 - List> paragraphNumber = paragraphDivideResponseDto.getResult().getSpan(); + for(Map.Entry> sentenceEntry : sentenceListGroupByParagraph.entrySet()) { - // 문단별 측정된 시간 저장 - List paragraphRealTime = new ArrayList<>(); + List sentenceDTOList = new ArrayList<>(); - List paragraphList = new ArrayList<>(); + for(SentenceEntity sentenceEntity : sentenceEntry.getValue()) { + SentenceDTO sentenceDTO = new SentenceDTO(sentenceEntity.getSentenceId(), sentenceEntity.getSentenceOrder(), sentenceEntity.getSentenceContent()); + sentenceDTOList.add(sentenceDTO); + } - for (List paragraph : paragraphNumber) { - List sentenceList = new ArrayList<>(); - timestamp = 0; - for (Integer index : paragraph) { + List sentenceList = sentenceEntry.getValue(); + List sentenceContentList = sentenceEntry.getValue().stream().map(SentenceEntity::getSentenceContent).toList(); - Long sentenceId = sttResultSentenceDtoList.get(index).getSentenceId(); - Long sentenceOrder = sttResultSentenceDtoList.get(index).getSentenceOrder(); - String sentenceContent = sttResultSentenceDtoList.get(index).getContent(); + // 문단에 해당하는 시간 합산 + LocalTime realTimePerParagraph = sentenceList.stream() + .map(SentenceEntity::getSentenceRealTime) + .reduce(LocalTime.of(0,0,0), + ((localTime, localTime2) -> localTime.plusHours(localTime2.getHour()).plusMinutes(localTime2.getMinute()).plusSeconds(localTime2.getSecond()))); - timestamp += sttResultSentenceDtoList.get(index).getRealTime(); - sentenceList.add(new SentenceDTO(sentenceId, sentenceOrder, sentenceContent)); - redisTemplateImpl.saveSentenceInformation(sentenceId, new RedisSentenceDTO(paragraphId, paragraphOrder, Long.valueOf(index), sentenceContent, RealTimeUtils.convertMsToTimeFormat(timestamp), NowStatus.RealTime)); - } - paragraphList.add(new STTParagraphDTO(paragraphId++, paragraphOrder++, RealTimeUtils.convertMsToTimeFormat(timestamp), NowStatus.RealTime, sentenceList)); + STTParagraphDTO sttParagraphDTO = new STTParagraphDTO(sentenceEntry.getKey(), sentenceEntry.getKey(), realTimePerParagraph, NowStatus.RealTime, sentenceDTOList); + paragraphList.add(sttParagraphDTO); } - return new STTScriptResponseDTO(paragraphList); + return new STTScriptResponseDTO(paragraphList);// return new STTScriptResponseDTO(paragraphList); } } diff --git a/src/main/java/com/twentythree/peech/script/stt/service/EditClovaSpeechResponseService.java b/src/main/java/com/twentythree/peech/script/stt/service/EditClovaSpeechResponseService.java deleted file mode 100644 index 2f90d299..00000000 --- a/src/main/java/com/twentythree/peech/script/stt/service/EditClovaSpeechResponseService.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.twentythree.peech.script.stt.service; - - -import com.twentythree.peech.script.stt.dto.EditClovaSpeechSentenceVO; -import com.twentythree.peech.script.stt.dto.response.ClovaResponseDto; -import com.twentythree.peech.script.stt.utils.RealTimeUtils; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; - -@Service -@RequiredArgsConstructor -public class EditClovaSpeechResponseService { - - public List editClovaSpeechResponseSentences(ClovaResponseDto clovaResponseDto) { - - List clovaSpeechSentenceDtoList = new ArrayList<>(); - - StringBuilder currentSentence = new StringBuilder(); - int calculatedTime = 0; - int startTimestamp = 0; - int endTimestamp = 0; - Long sentenceOrder = 1L; - - // Get the sentences that STT arbitrarily divided - for(ClovaResponseDto.Segment segment : clovaResponseDto.getSentences()) { - List> words = segment.getWords(); - - // Start checking word by word - for (List word : words){ - String text = (String) word.get(2); - - if(currentSentence.isEmpty()) { - startTimestamp = (int) word.get(0); - } - - if (!currentSentence.isEmpty()) { - // No space needed if it's the first word - currentSentence.append(" "); - } - currentSentence.append(text); - - if(text.contains(".")) { - endTimestamp = (int) word.get(1); - calculatedTime = endTimestamp - startTimestamp; - clovaSpeechSentenceDtoList.add(new EditClovaSpeechSentenceVO(sentenceOrder++, currentSentence.toString(), calculatedTime)); - currentSentence.setLength(0); - } - } - } - return clovaSpeechSentenceDtoList; - } -} diff --git a/src/main/java/com/twentythree/peech/script/stt/service/ProcessSTTService.java b/src/main/java/com/twentythree/peech/script/stt/service/ProcessSTTService.java index 9870eca7..c6c77663 100644 --- a/src/main/java/com/twentythree/peech/script/stt/service/ProcessSTTService.java +++ b/src/main/java/com/twentythree/peech/script/stt/service/ProcessSTTService.java @@ -1,10 +1,11 @@ package com.twentythree.peech.script.stt.service; import com.twentythree.peech.script.cache.RedisTemplateImpl; +import com.twentythree.peech.script.domain.SentenceEntity; import com.twentythree.peech.script.repository.ThemeRepository; import com.twentythree.peech.script.service.ScriptService; import com.twentythree.peech.script.service.SentenceService; -import com.twentythree.peech.script.stt.dto.EditClovaSpeechSentenceVO; +import com.twentythree.peech.script.stt.dto.AddSentenceInformationVO; import com.twentythree.peech.script.stt.dto.SaveSTTScriptVO; import com.twentythree.peech.script.stt.dto.SentenceVO; import com.twentythree.peech.script.stt.dto.request.STTRequestDto; @@ -25,7 +26,9 @@ public class ProcessSTTService { private final RequestClovaSpeechApiService requestClovaSpeechApiService; - private final EditClovaSpeechResponseService editClovaSpeechResponseService; + //private final EditClovaSpeechResponseService editClovaSpeechResponseService; + + private final AddRealTimeToSentenceService addRealTimeToSentenceService; private final CreateParagraghService createParagraghService; @@ -46,23 +49,24 @@ public Mono createSTTResult(STTRequestDto request, Long th return clovaResponseDtoMono .flatMap(clovaResponseDto -> { - List sentenceAndRealTimeList = editClovaSpeechResponseService.editClovaSpeechResponseSentences(clovaResponseDto); - String totalText = sentenceAndRealTimeList - .stream().map(EditClovaSpeechSentenceVO::sentenceContent) - .collect(Collectors.joining("\\n")); + + String totalText = clovaResponseDto.getFullText(); Mono paragraphDivideResponseDtoMono = Mono.fromFuture(createParagraghService.requestClovaParagraphApi(totalText)); return paragraphDivideResponseDtoMono.flatMap(paragraphDivideResponseDto -> { + + List sentenceAndRealTimeList = addRealTimeToSentenceService.addRealTimeToSentence(clovaResponseDto, paragraphDivideResponseDto); + // Script Entity 저장 Mono saveSTTScriptVOMono = scriptService.saveSTTScriptVO(themeId, clovaResponseDto); - // Sentence Entity 저장 return saveSTTScriptVOMono.flatMap(saveSTTScriptVO -> { - List sentenceList = sentenceService.saveSTTSentences(saveSTTScriptVO.scriptEntity(), sentenceAndRealTimeList, paragraphDivideResponseDto.getResult().getSpan()); - STTScriptResponseDTO sttScriptResponseDTO = createSTTResultService.createSTTResultResponseDto(clovaResponseDto, sentenceAndRealTimeList, sentenceList, paragraphDivideResponseDto); + + List sentenceEntityList = sentenceService.saveSTTSentences(saveSTTScriptVO.scriptEntity(), sentenceAndRealTimeList, paragraphDivideResponseDto.getResult().getSpan()); + STTScriptResponseDTO sttScriptResponseDTO = createSTTResultService.createSTTResultResponseDto(clovaResponseDto, sentenceEntityList); // Redis 저장 로직 - List sentenceIds = sentenceList.stream().map(sentenceVO -> sentenceVO.sentenceEntity().getSentenceId()).toList(); - redisTemplateImpl.saveSentencesIdList(userKey, sentenceIds); + List sentenceIdList = sentenceEntityList.stream().map(SentenceEntity::getSentenceId).toList(); + redisTemplateImpl.saveSentencesIdList(userKey, sentenceIdList); // 최종 클라이언트 반환 DTO return Mono.just(sttScriptResponseDTO); }); @@ -93,23 +97,22 @@ public Mono createSTTResult(STTRequestDto request, Long th return clovaResponseDtoMono .flatMap(clovaResponseDto -> { - List sentenceAndRealTimeList = editClovaSpeechResponseService.editClovaSpeechResponseSentences(clovaResponseDto); - String totalText = sentenceAndRealTimeList - .stream().map(EditClovaSpeechSentenceVO::sentenceContent) - .collect(Collectors.joining("\\n")); + String totalText = clovaResponseDto.getFullText(); Mono paragraphDivideResponseDtoMono = Mono.fromFuture(createParagraghService.requestClovaParagraphApi(totalText)); return paragraphDivideResponseDtoMono.flatMap(paragraphDivideResponseDto -> { + + List sentenceAndRealTimeList = addRealTimeToSentenceService.addRealTimeToSentence(clovaResponseDto, paragraphDivideResponseDto); // Script Entity 저장 Mono saveSTTScriptVOMono = scriptService.saveSTTScriptVO(themeId, scriptId, clovaResponseDto); // Sentence Entity 저장 return saveSTTScriptVOMono.flatMap(saveSTTScriptVO -> { - List sentenceList = sentenceService.saveSTTSentences(saveSTTScriptVO.scriptEntity(), sentenceAndRealTimeList, paragraphDivideResponseDto.getResult().getSpan()); - STTScriptResponseDTO sttScriptResponseDTO = createSTTResultService.createSTTResultResponseDto(clovaResponseDto, sentenceAndRealTimeList, sentenceList, paragraphDivideResponseDto); + List sentenceEntityList = sentenceService.saveSTTSentences(saveSTTScriptVO.scriptEntity(), sentenceAndRealTimeList, paragraphDivideResponseDto.getResult().getSpan()); + STTScriptResponseDTO sttScriptResponseDTO = createSTTResultService.createSTTResultResponseDto(clovaResponseDto, sentenceEntityList); // Redis 저장 로직 - List sentenceIds = sentenceList.stream().map(sentenceVO -> sentenceVO.sentenceEntity().getSentenceId()).toList(); - redisTemplateImpl.saveSentencesIdList(userKey, sentenceIds); + List sentenceIdList = sentenceEntityList.stream().map(SentenceEntity::getSentenceId).toList(); + redisTemplateImpl.saveSentencesIdList(userKey, sentenceIdList); // 최종 클라이언트 반환 DTO return Mono.just(sttScriptResponseDTO); }); diff --git a/src/main/java/com/twentythree/peech/script/stt/utils/MergeWordListUtils.java b/src/main/java/com/twentythree/peech/script/stt/utils/MergeWordListUtils.java new file mode 100644 index 00000000..280059ea --- /dev/null +++ b/src/main/java/com/twentythree/peech/script/stt/utils/MergeWordListUtils.java @@ -0,0 +1,20 @@ +package com.twentythree.peech.script.stt.utils; + +import com.twentythree.peech.script.stt.dto.response.ClovaResponseDto; + +import java.util.ArrayList; +import java.util.List; + +public class MergeWordListUtils { + + public static List> mergeWordList(ClovaResponseDto clovaResponseDto) { + List> mergedWordList = new ArrayList<>(); + + for(ClovaResponseDto.Segment segment : clovaResponseDto.getSentences()) { + List> words = segment.getWords(); + mergedWordList.addAll(words); + } + return mergedWordList; + } + +} From ffd365fc650ea4abbfdc500ff1711a0d86096358 Mon Sep 17 00:00:00 2001 From: ch8930 Date: Wed, 17 Jul 2024 13:50:58 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20TT-268=20stt=20process=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=EA=B3=BC=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 문단 나누기 api가 slicing한 문장을 기반으로 타임체크를 하는 로직 추가 - 기존에 stt 문장을 '.' 단위로 나누던 로직 삭제 --- .../twentythree/peech/script/stt/service/ProcessSTTService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/twentythree/peech/script/stt/service/ProcessSTTService.java b/src/main/java/com/twentythree/peech/script/stt/service/ProcessSTTService.java index c6c77663..d2fb830b 100644 --- a/src/main/java/com/twentythree/peech/script/stt/service/ProcessSTTService.java +++ b/src/main/java/com/twentythree/peech/script/stt/service/ProcessSTTService.java @@ -26,8 +26,6 @@ public class ProcessSTTService { private final RequestClovaSpeechApiService requestClovaSpeechApiService; - //private final EditClovaSpeechResponseService editClovaSpeechResponseService; - private final AddRealTimeToSentenceService addRealTimeToSentenceService; private final CreateParagraghService createParagraghService;