장르 선택 로직 개선
This commit is contained in:
1 parent
888ac4fa5e
commit
6c499ae061
15 files changed
+167
-112
No files matched your search
@@ -31,6 +31,27 @@ const MAX_RETRY_COUNT = 3;
|
||||
// GenerationFlow의 clearAllProjectStorage가 이 키를 포함해 정리함
|
||||
const SONG_GENERATION_KEY = 'castad_song_generation';
|
||||
|
||||
const GENRE_VALUES = ['kpop', 'pop', 'ballad', 'hip-hop', 'rnb', 'edm', 'jazz', 'rock'];
|
||||
|
||||
const genreMap: Record<string, string> = {
|
||||
'자동 선택': '', // 런타임에 랜덤 결정
|
||||
'K-POP': 'kpop',
|
||||
'POP': 'pop',
|
||||
'발라드': 'ballad',
|
||||
'Hip-Hop': 'hip-hop',
|
||||
'R&B': 'rnb',
|
||||
'EDM': 'edm',
|
||||
'JAZZ': 'jazz',
|
||||
'ROCK': 'rock',
|
||||
};
|
||||
|
||||
const getEffectiveGenre = (selectedGenre: string): string => {
|
||||
if (selectedGenre === '자동 선택') {
|
||||
return GENRE_VALUES[Math.floor(Math.random() * GENRE_VALUES.length)];
|
||||
}
|
||||
return genreMap[selectedGenre] || 'pop';
|
||||
};
|
||||
|
||||
const sanitizeError = (message: string, fallback: string): string => {
|
||||
if (
|
||||
message.includes('Traceback') ||
|
||||
@@ -69,6 +90,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
const [selectedType, setSelectedType] = useState('보컬');
|
||||
const [selectedLang, setSelectedLang] = useState('한국어');
|
||||
const [selectedGenre, setSelectedGenre] = useState('자동 선택');
|
||||
const [usedGenre, setUsedGenre] = useState('');
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
const [status, setStatus] = useState<GenerationStatus>('idle');
|
||||
@@ -88,7 +110,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
const saveSongCompletionData = () => {
|
||||
const completionData = {
|
||||
businessName: businessInfo?.customer_name || '알 수 없음',
|
||||
genre: selectedGenre === '자동 선택' ? 'K-POP' : selectedGenre,
|
||||
genre: selectedGenre,
|
||||
lyrics: lyrics,
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
@@ -211,20 +233,13 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
|
||||
try {
|
||||
const language = LANGUAGE_MAP[selectedLang] || 'Korean';
|
||||
const genreMap: Record<string, string> = {
|
||||
'자동 선택': 'pop',
|
||||
'K-POP': 'kpop',
|
||||
'발라드': 'ballad',
|
||||
'Hip-Hop': 'hip-hop',
|
||||
'R&B': 'rnb',
|
||||
'EDM': 'edm',
|
||||
'JAZZ': 'jazz',
|
||||
'ROCK': 'rock',
|
||||
};
|
||||
|
||||
const isInstrumental = selectedType === '배경음악';
|
||||
const effectiveGenre = getEffectiveGenre(selectedGenre);
|
||||
setUsedGenre(effectiveGenre);
|
||||
|
||||
const songResponse = await generateSong(imageTaskId, {
|
||||
genre: genreMap[selectedGenre] || 'pop',
|
||||
genre: effectiveGenre,
|
||||
...(isInstrumental ? { instrumental: true, lyrics: '' } : { language, lyrics: currentLyrics }),
|
||||
});
|
||||
|
||||
@@ -371,17 +386,6 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
throw new Error(lyricResponse.error_message || t('soundStudio.lyricGenerationFailed'));
|
||||
}
|
||||
|
||||
const genreMap: Record<string, string> = {
|
||||
'자동 선택': 'pop',
|
||||
'K-POP': 'kpop',
|
||||
'발라드': 'ballad',
|
||||
'Hip-Hop': 'hip-hop',
|
||||
'R&B': 'rnb',
|
||||
'EDM': 'edm',
|
||||
'JAZZ': 'jazz',
|
||||
'ROCK': 'rock',
|
||||
};
|
||||
|
||||
let songLyrics: string | undefined;
|
||||
|
||||
if (!isInstrumental) {
|
||||
@@ -412,8 +416,11 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
setStatus('generating_song');
|
||||
setStatusMessage(t('soundStudio.generatingSong'));
|
||||
|
||||
const effectiveGenre = getEffectiveGenre(selectedGenre);
|
||||
setUsedGenre(effectiveGenre);
|
||||
|
||||
const songResponse = await generateSong(imageTaskId, {
|
||||
genre: genreMap[selectedGenre] || 'pop',
|
||||
genre: effectiveGenre,
|
||||
...(isInstrumental ? { instrumental: true, lyrics: '' } : { language, lyrics: songLyrics }),
|
||||
});
|
||||
|
||||
@@ -552,7 +559,7 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
))}
|
||||
</div>
|
||||
<div className="genre-row">
|
||||
{['JAZZ', 'ROCK'].map(genre => (
|
||||
{['JAZZ', 'ROCK', 'POP'].map(genre => (
|
||||
<button
|
||||
key={genre}
|
||||
onClick={() => setSelectedGenre(genre)}
|
||||
@@ -562,7 +569,6 @@ const SoundStudioContent: React.FC<SoundStudioContentProps> = ({
|
||||
{genre}
|
||||
</button>
|
||||
))}
|
||||
<div className="genre-btn-placeholder"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user