Expand description
§lyrx
A pure Rust implementation of LyRiCs which is a computer file format that synchronizes song lyrics with an audio file.
§Examples
use lyrx::{Lyrics, IDTag, TimeTag};
let mut lyrics = Lyrics::new();
let metadata = &mut lyrics.metadata;
metadata.insert(IDTag::from_string("ti", "Let's Twist Again").unwrap());
metadata.insert(IDTag::from_string("al", "Hits Of The 60's - Vol. 2 – Oldies").unwrap());
lyrics.add_timed_line(TimeTag::from_str("00:12.00").unwrap(), "Naku Penda Piya-Naku Taka Piya-Mpenziwe").unwrap();
lyrics.add_timed_line(TimeTag::from_str("00:15.30").unwrap(), "Some more lyrics").unwrap();
assert_eq!(
r"[al: Hits Of The 60's - Vol. 2 – Oldies]
[ti: Let's Twist Again]
[00:12.00]Naku Penda Piya-Naku Taka Piya-Mpenziwe
[00:15.30]Some more lyrics",
lyrics.to_string()
);use lyrx::{Lyrics, TimeTag};
let lyrics = Lyrics::from_str(r"[00:12.00][01:15.00]Naku Penda Piya-Naku Taka Piya-Mpenziwe
[00:15.30][01:18.00]Some more lyrics ...").unwrap();
if let Some(index) = lyrics.find_timed_line_index(TimeTag::from_str("00:13.00").unwrap()) {
let timed_lines = lyrics.get_timed_lines();
assert_eq!((TimeTag::from_str("00:12.00").unwrap(), "Naku Penda Piya-Naku Taka Piya-Mpenziwe".into()), timed_lines[index]);
} else {
unreachable!();
}use lyrx::Lyrics;
let lyrics = Lyrics::from_str(r"[00:53.44] This fire is out of control
[00:56.63] This fire is out of control
[00:59.96] This fire is out of control");
assert!(lyrics.is_ok());
// Here you need annotation because to_vec() support f64, Option<f64>, f32, Option<32>, u64, Option<u64>, u32, Option<u32>, i64
let vec: Vec<(f64, String)> = lyrics.unwrap().to_vec();
assert_eq!(vec.len(), 3);
assert_eq!(vec[0].0, 53.44);
assert_eq!(vec[0].1, "This fire is out of control");use lyrx::Lyrics;
let lyrics = Lyrics::from_str(
"[00:12.00] <00:12.04> This <00:12.16> fire <00:12.82> is"
);
let vec: Vec<(f64, String)> = lyrics.unwrap().to_vec();
assert_eq!(vec[0].0, 12.00);
assert_eq!(vec[0].1, "This fire is");Re-exports§
pub use tags::*;