- tools/analyze + tools/song_analysis: Trennung in Stems, Takte, Akkorde, Tonhöhe und Text mit Wortzeiten (eigene Python-3.11-Umgebung, README, Tests) - schemas/song-analysis-v1: JSON-Schemas der Ausgabe - src/lib.rs, src/song_analysis.rs: liest die Ausgabe (Version 1); Integrationstest in tests/ - .gitignore: Umgebung, Modelle und Zwischenspeicher des Werkzeugs Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
28 lines
1.2 KiB
Rust
28 lines
1.2 KiB
Rust
use singtrainer::song_analysis::{Analysis, load_analysis};
|
|
|
|
#[test]
|
|
fn reads_optional_outputs_from_one_folder() {
|
|
let dir = std::env::temp_dir().join(format!("song-analysis-{}", std::process::id()));
|
|
std::fs::create_dir_all(&dir).unwrap();
|
|
std::fs::write(dir.join("meta.json"), r#"{"title":"Example","bpm":120.0,"key":null,"duration":3.0,"schema_version":1,"errors":{}}"#).unwrap();
|
|
std::fs::write(
|
|
dir.join("beats.json"),
|
|
r#"{"beats":[0.0,0.5],"downbeats":[0.0]}"#,
|
|
)
|
|
.unwrap();
|
|
let value: Analysis = load_analysis(&dir).unwrap();
|
|
assert_eq!(value.meta.title, "Example");
|
|
assert_eq!(value.beats.unwrap().downbeats, vec![0.0]);
|
|
assert!(value.pitch.is_none());
|
|
std::fs::remove_dir_all(dir).unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn rejects_unknown_schema_version() {
|
|
let dir = std::env::temp_dir().join(format!("song-analysis-version-{}", std::process::id()));
|
|
std::fs::create_dir_all(&dir).unwrap();
|
|
std::fs::write(dir.join("meta.json"), r#"{"title":"Example","bpm":null,"key":null,"duration":3.0,"schema_version":2,"errors":{}}"#).unwrap();
|
|
assert!(load_analysis(&dir).is_err());
|
|
std::fs::remove_dir_all(dir).unwrap();
|
|
}
|