A modern C++ library for parsing common lyric file formats
- π Multi-format support: Parse LRC, SRT, ESLyric, ASS and more
- β‘ High performance: Optimized C++20 implementation
- π§© Extensible architecture: Easy to add new parsers
- π·οΈ Role assignment: Flexible lyric content role management
- π Word-level timing: Support for karaoke-style word-by-word lyrics
| Format | Status | Parser | Modes Supported | Role Assignment |
|---|---|---|---|---|
| LRC | β | lexy | Line & Word-by-word | β |
| SRT | β | lexy | Line-only | β |
| ESLyric | β | lexy | Line & Word-by-word | β |
| ASS | β | C++ | Line & Word-by-word | β |
| KRC | β | - | - | - |
| YRC | β | - | - | - |
| QRC | β | - | - | - |
| LYS | β | - | - | - |
| TTML | β | - | - | - |
| VTT | β | - | - | - |
π‘ Note: Missing sample files prevent development of certain formats. Contributions welcome!
- FProcess: Main entry point for parsing operations
- FLyricFile: Container for parsed lyrics and metadata
- FLyricGroup: Groups lyrics by time periods
- FLyricLine: Individual lyric lines with timing
- FLyricWord: Word-level timing data
- FLyricGroupRoleOption: Role assignment configuration
- IParser: Abstract parser interface
mermaid
graph TD
A[User Input: Format + Lyrics + Roles] --> B[FProcess::Process]
B --> C[Select Parser via GetParser]
C --> D[Parse Input String]
D --> E[Create FLyricGroups & Metadata]
E --> F[Process Individual Lines]
F --> G[Assign Roles via ApplyRole]
G --> H[Return FLyricFile]
FLyricFile
βββ FLyricMetadata (key-value pairs)
βββ std::vector<FLyricGroup>
βββ FLyricGroup
βββ Timestamps (start/end)
βββ FLyricGroupRoleOption
βββ std::vector<FLyricLine>
βββ FLyricLine
βββ Content & Timing
βββ ELyricContentRole
βββ word_by_word flag
βββ std::vector<FLyricWord>
βββ FLyricWord
βββ Text content
βββ Timestamps (start/end)
bash
# Clone the repository
git clone https://github.com/TypeDreamMoon/libdlp.git
cd libdlp
# Build using CMake
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
cpp
#include <dlp/Process.hpp>
#include <dlp/File.hpp>
// Define content roles
std::vector<dlp::ELyricContentRole> roles{
dlp::ELyricContentRole::Romanization, // First priority
dlp::ELyricContentRole::Lyric, // Second priority
dlp::ELyricContentRole::Translation // Third priority
};
// Create processor and parse
dlp::FProcess processor;
dlp::File::FLyricFile lyric_file = processor.Process(
dlp::EFileFormat::LRC, // File format
"Lyric content string...", // Input lyrics
{roles, dlp::ELyricContentRole::Lyric} // Role options
);
// Access parsed data
for (const auto& group : lyric_file.groups) {
for (const auto& line : group.parsed_lines) {
std::cout << "Role: " << static_cast<int>(line.role)
<< ", Content: " << line.lyric
<< ", Time: " << line.time_start.count()
<< std::endl;
}
}
cpp
// For karaoke-style lyrics with word-level timing
if (lyric_line.IsWordByWord()) {
for (const auto& word : lyric_line.parsed_words) {
std::cout << "Word: '" << word.word
<< "' starts at: " << word.time_start.count()
<< "ms, ends at: " << word.time_end.count()
<< "ms" << std::endl;
}
}
- C++20 compatible compiler (GCC 10+, Clang 10+, MSVC 19.28+)
- CMake 3.16+
- Git
bash
# Clone the repository
git clone https://github.com/TypeDreamMoon/libdlp.git
cd libdlp
# Configure and build
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
# Run tests (if available)
cd build && ./test_executable
We welcome contributions! Here are some ways you can help:
- Implement the
IParserinterface - Register your parser in
FProcess::GetParser - Update the format table in this README
Many formats are unimplemented due to lack of sample files. If you have sample lyric files for unsupported formats, please contribute them!
- Performance optimizations
- Better error handling
- Additional features
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter issues or have questions:
- Check the Issues section
- Open a new issue for bug reports or feature requests
- Contribute samples for unsupported formats
β Star this repo if it helped you!
