Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ def info(msg):
"humming_id": humming_id,
"title": "E2E Test Song",
"genre": "pop",
"mood": "happy",
"reference_track_id": None
"mood": "happy"
},
headers=headers,
timeout=15
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.humix.api.domain.humming.entity.Humming;
import com.humix.api.domain.humming.entity.ReferenceTrack;
import com.humix.api.domain.member.entity.Member;
import java.time.LocalDateTime;

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public interface GenerationControllerDocs {
"- `humming_id`: 벡터화가 완료된 허밍의 ID (필수)\n" +
"- `title`: 생성할 곡 제목 (생략 시 기본값 '나의 허밍곡' 사용)\n" +
"- `genre`: 원하는 장르 (예: pop, jazz, classical, hiphop)\n" +
"- `mood`: 원하는 분위기 (예: upbeat, calm, romantic, sad)\n" +
"- `reference_track_id`: 참조할 트랙 ID (선택사항, 없으면 null)")
"- `mood`: 원하는 분위기 (예: upbeat, calm, romantic, sad)")
@RequestBody(
required = true,
content = @Content(
Expand All @@ -35,8 +34,7 @@ public interface GenerationControllerDocs {
" \"humming_id\": 1,\n" +
" \"title\": \"나의 첫 번째 곡\",\n" +
" \"genre\": \"pop\",\n" +
" \"mood\": \"upbeat\",\n" +
" \"reference_track_id\": 3\n" +
" \"mood\": \"upbeat\"\n" +
"}"
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ public record SongCreateRequest(
String genre,

@Schema(description = "분위기 (예: upbeat, calm, romantic, sad 등)", example = "upbeat")
String mood,

@Schema(description = "참조 트랙 ID (선택, 없으면 null)", example = "3", nullable = true)
@JsonProperty("reference_track_id") Long referenceTrackId
String mood
) {
//DTO를 MusicGeneration 엔티티로 변환하는 매핑 메서드
public MusicGeneration from(Member member, MelodyScore melodyScore) {
Expand Down Expand Up @@ -116,8 +113,7 @@ public record GenerationDetailResponse(
@JsonProperty("humming_duration_seconds") double hummingDurationSeconds,
@JsonProperty("melody_note_count") int melodyNoteCount,
String genre,
String mood,
@JsonProperty("reference_track") Object referenceTrack
String mood
) {
//엔티티 및 연관 데이터(Humming 등)를 조합하여 조회 응답 DTO로 변환하는 메서드
public static GenerationDetailResponse from(MusicGeneration musicGeneration,
Expand All @@ -126,8 +122,7 @@ public static GenerationDetailResponse from(MusicGeneration musicGeneration,
hummingDuration, //Humming 엔티티의 durationSeconds 등에서 조회
noteCount, //MelodyScore 내부 notes_data JSON의 배열 길이 등에서 파싱
musicGeneration.getGenre(),
musicGeneration.getAtmosphere(), //엔티티의 atmosphere를 mood 필드로 매핑
null //기본값 null
musicGeneration.getAtmosphere() //엔티티의 atmosphere를 mood 필드로 매핑
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.humix.api.domain.humming.entity.ReferenceTrack;
import com.humix.api.domain.humming.repository.ReferenceTrackRepository;
import com.humix.api.domain.melodyScore.dto.MelodyScoreDTO;
import com.humix.api.domain.melodyScore.entity.MelodyScore;
import com.humix.api.domain.melodyScore.repository.MelodyScoreRepository;
Expand Down Expand Up @@ -43,7 +41,6 @@ public class MusicGenerationService {

private final MusicGenerationRepository musicGenerationRepository;
private final MelodyScoreRepository melodyScoreRepository;
private final ReferenceTrackRepository referenceTrackRepository;
private final S3Presigner s3Presigner;
private final WebClient.Builder webClientBuilder;
private final ObjectMapper objectMapper;
Expand Down Expand Up @@ -78,7 +75,6 @@ private record AiGenerationRequest(
@JsonProperty("melody_vectors") List<AiMelodyVector> melodyVectors,
String genre,
String mood,
@JsonProperty("reference_track") String referenceTrack,
@JsonProperty("callback_url") String callbackUrl,
@JsonProperty("presigned_url") String presignedUrl
) {}
Expand Down Expand Up @@ -106,32 +102,24 @@ public MusicGenerationDTO.TaskAcceptedResponse generateSong(CustomUserDetails us
MelodyScore melodyScore = melodyScoreRepository.findByHummingId(request.hummingId())
.orElseThrow(() -> new IllegalArgumentException("해당 허밍의 멜로디 악보가 존재하지 않습니다. ID: " + request.hummingId()));

// 2. ReferenceTrack 로드 (옵션)
ReferenceTrack referenceTrack = null;
if (request.referenceTrackId() != null) {
referenceTrack = referenceTrackRepository.findById(request.referenceTrackId())
.orElseThrow(() -> new IllegalArgumentException("해당 참조 곡이 존재하지 않습니다. ID: " + request.referenceTrackId()));
}

// 3. Task ID 생성
// 2. Task ID 생성
String taskId = "task_" + UUID.randomUUID().toString();

// 4. S3 Presigned URL 생성
// 3. S3 Presigned URL 생성
String uniqueFileName = UUID.randomUUID().toString() + "_variation.wav";
String fileKey = "audio/" + uniqueFileName;
String presignedUrl = generatePresignedUrl(fileKey);

// 5. MusicGeneration 엔티티 생성 및 영속화
// 4. MusicGeneration 엔티티 생성 및 영속화
MusicGeneration musicGeneration = request.from(userDetails.getMember(), melodyScore);
musicGeneration.updateTaskId(taskId);
musicGeneration.updateDuration(30); // Default 30s
musicGenerationRepository.save(musicGeneration);

// 6. Melody Vectors 파싱
// 5. Melody Vectors 파싱
List<AiMelodyVector> melodyVectors = parseMelodyVectors(melodyScore.getNotesData());

// 7. AI 서버로 비동기 작곡 요청
String refTrackName = referenceTrack != null ? referenceTrack.getAudioName() : null;
// 6. AI 서버로 비동기 작곡 요청
String callbackUrl = backendUrl + "/api/v1/internal/tasks/" + taskId + "/completion";

log.info("[MusicGeneration] Requesting song generation for taskId: {}, genre: {}, mood: {}, callback: {}", taskId, request.genre(), request.mood(), callbackUrl);
Expand All @@ -142,7 +130,6 @@ public MusicGenerationDTO.TaskAcceptedResponse generateSong(CustomUserDetails us
melodyVectors,
request.genre(),
request.mood(),
refTrackName,
callbackUrl,
presignedUrl
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,4 @@ public ApiResponse<HummingDTO.HummingSaveResponse> saveHummingInfo(@Authenticati

return ApiResponse.onSuccess(GeneralSuccessCode.OK, result);
}

@PostMapping("/reference-tracks")
@Override
public ApiResponse<Object> saveReferenceTrackInfo(@RequestBody Object request) {
return ApiResponse.onSuccess(GeneralSuccessCode.OK, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,4 @@ public interface UploadControllerDocs {
@PostMapping("/humming")
ApiResponse<HummingDTO.HummingSaveResponse> saveHummingInfo(@AuthenticationPrincipal CustomUserDetails userDetails,
@RequestBody HummingDTO.HummingSaveRequest request);

@Operation(summary = "참조곡 오디오 메타데이터 저장 API", description = "S3 업로드 완료 후 사용자가 올린 참조곡의 메타데이터를 저장합니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "성공")
})
@PostMapping("/reference-tracks")
ApiResponse<Object> saveReferenceTrackInfo(@RequestBody Object request);
}
Loading