Add section performance directives

This commit is contained in:
diyaa
2026-09-14 22:04:35 +02:00
parent 7bf4df79f9
commit 4fa477bdb0
3 changed files with 43 additions and 7 deletions
@@ -30,13 +30,18 @@ public struct SongProjectPromptCompiler: PromptCompiling {
} }
return project.orderedSections return project.orderedSections
.compactMap { section in .compactMap { sectionLyricsBlock(for: $0, project: project) }
.joined(separator: "\n\n")
}
private func sectionLyricsBlock(for section: SongSection, project: SongProject) -> String? {
let lyrics = project.lyrics.sectionTexts[section.id] ?? section.lyrics let lyrics = project.lyrics.sectionTexts[section.id] ?? section.lyrics
let trimmedLyrics = lyrics.trimmingCharacters(in: .whitespacesAndNewlines) let trimmedLyrics = lyrics.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmedLyrics.isEmpty else { return nil } guard !trimmedLyrics.isEmpty else { return nil }
return "[\(section.title)]\n\(trimmedLyrics)"
} let performanceDirective = normalized(section.vocalDirection)
.joined(separator: "\n\n") let header = performanceDirective.map { "[\(section.title) - \($0)]" } ?? "[\(section.title)]"
return "\(header)\n\(trimmedLyrics)"
} }
private func stylePrompt(for project: SongProject) -> String { private func stylePrompt(for project: SongProject) -> String {
@@ -62,4 +62,35 @@ final class SongProjectPromptCompilerTests: XCTestCase {
XCTAssertEqual(output.lyricsText, "[Verse]\nVerse line\n\n[Chorus]\nHook line") XCTAssertEqual(output.lyricsText, "[Verse]\nVerse line\n\n[Chorus]\nHook line")
} }
func testCompilerIncludesSectionPerformanceDirectivesInFallbackLyrics() throws {
let project = SongProject(
title: "Directed Sections",
idea: "Compile performance directions",
sections: [
SongSection(
id: "intro",
type: .intro,
title: "Intro",
lyrics: "First line",
vocalDirection: "whispered lead"
),
SongSection(
id: "chorus",
type: .chorus,
title: "Chorus",
order: 1,
lyrics: "Original hook"
)
],
lyrics: Lyrics(sectionTexts: ["chorus": "Approved hook"])
)
let output = try SongProjectPromptCompiler().compile(project: project)
XCTAssertEqual(
output.lyricsText,
"[Intro - whispered lead]\nFirst line\n\n[Chorus]\nApproved hook"
)
}
} }
+1 -1
View File
@@ -98,7 +98,7 @@ requirement is missing and blocks implementation, record it in
- [x] Create deterministic compiler from approved SongProject → Suno - [x] Create deterministic compiler from approved SongProject → Suno
output. output.
- [ ] Generate lyrics text with section/performance directives where - [x] Generate lyrics text with section/performance directives where
appropriate. appropriate.
- [ ] Generate style prompt from genre blend, instrumentation, vocals, - [ ] Generate style prompt from genre blend, instrumentation, vocals,
tempo, harmony, emotion and production instructions. tempo, harmony, emotion and production instructions.