Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast api 코드 수정 #38

Merged
merged 8 commits into from
Aug 10, 2024
Merged

Conversation

yuuddin
Copy link
Collaborator

@yuuddin yuuddin commented Aug 10, 2024

DONE

  • multipartfile 입력 받을 수 있도록 수정 과정
  • 겹치는 코드 제거( cast service > create 부분)
  • 양방향 매핑은 그냥 두되 List 저장하지 않고 sentence에 cast 저장 하는 로직으로 변경

yuuddin added 7 commits August 7, 2024 23:23
…cast/OwnCast_backend into enhance/cast-api/29

# Conflicts:
#	src/main/java/com/umc/owncast/domain/cast/controller/CastController.java
#	src/main/java/com/umc/owncast/domain/cast/service/CastService.java
#	src/main/java/com/umc/owncast/domain/cast/service/TTSService.java
#	src/main/java/com/umc/owncast/domain/sentence/service/SentenceService.java
#	src/main/java/com/umc/owncast/domain/sentence/service/SentenceServiceImpl.java
@yuuddin yuuddin requested a review from ja7811 August 10, 2024 07:07
@yuuddin yuuddin self-assigned this Aug 10, 2024
@yuuddin yuuddin added the 💡 ENHANCEMENT Feature enhancement label Aug 10, 2024
@yuuddin yuuddin changed the base branch from feat/cast-api/11 to feat/cast-api-completion August 10, 2024 07:08
Copy link
Contributor

@ja7811 ja7811 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

캐스트 생성 할 때 응답에 script가 빕니다
아래 리뷰 참고해주세욥

Comment on lines 64 to 85
private @NotNull ApiResponse<Object> getObjectApiResponse(KeywordCastCreationDTO castRequest, String script) {
TTSResultDTO ttsResult = ttsService.createSpeech(script, castRequest);
Double audioLength = ttsResult.getTimePointList().get(ttsResult.getTimePointList().size() - 1);
int minutes = (int) (audioLength / 60);
int seconds = (int) Math.round(audioLength % 60);

Cast cast = Cast.builder()
.voice(castRequest.getVoice())
.audioLength(0) // TODO mp3 파일 길이 가져오기
.audioLength(String.format("%02d:%02d", minutes, seconds))
.filePath(ttsResult.getMp3Path())
.formality(castRequest.getFormality())
.member(null) // TODO 회원 기능 만들어지면 자기자신 넣기
.language(null) // TODO 회원 기능 만들어지면 언어 설정 넣기
.isPublic(false)
.hits(0L)
.build();
List<Sentence> sentences = sentenceService.mapToSentence(
script,
translateService.translate(script),
ttsResult,
cast
);
cast.addSentences(sentences);
castRepository.save(cast);
sentenceRepository.saveAll(sentences);
cast = castRepository.save(cast);
sentenceService.save(script, ttsResult, cast);

CastScriptDTO response = new CastScriptDTO(cast);
return ApiResponse.of(SuccessCode._OK, response);
}
Copy link
Contributor

@ja7811 ja7811 Aug 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리팩토링 해주셨군요 👍

근데 함수명은 바꾸는 게 좋을 거 같아요 (인텔리제이가 추천해준 이름 같은데 의미가 불명확함)
차라리 saveCastCreation 같은 느낌으로 바꾼 다음에
ApiResponse 말고 CastScriptDTO만 반환하게 하는 게 어떨까요

audioLength 구하는 부분은 좋네요
외부 라이브러리 가져와서 mp3 길이 구하고 이런 거 생각하고 있었는데 ssml 태그 사용하면 됐었네..
근데 timePoint 태그가 스크립트 맨 끝에도 붙는 거죠??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넹 맨끝에 붙어요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빼놓고 수정 까먹었네요 함수명 수정하겠습니다~~!

- sentenceService.save()가 List<Sentence>를 반환하도록 변경
@ja7811 ja7811 merged commit 1e8557e into feat/cast-api-completion Aug 10, 2024
@ja7811 ja7811 deleted the enhance/cast-api/29 branch August 11, 2024 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 ENHANCEMENT Feature enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants