@applemusic-like-lyrics/lyric 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +23 -22
- package/package.json +13 -7
- package/pkg/amll_lyric.d.ts +61 -40
- package/pkg/amll_lyric.js +1 -2
- package/pkg/amll_lyric_bg.js +322 -392
- package/pkg/amll_lyric_bg.wasm +0 -0
- package/pkg/amll_lyric_bg.wasm.d.ts +22 -21
- package/pkg/lyric_bg.js +48 -48
- package/pkg/lyric_bg.wasm +0 -0
- package/pkg/lyric_bg.wasm.d.ts +7 -7
package/README.md
CHANGED
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
# Lyric parser/writer for AMLL
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English / [简体中文](./README-CN.md)
|
|
4
|
+
|
|
5
|
+
> Warning: This is a personal project and is still under development. There may still be many issues, so please do not use it directly in production environments!
|
|
4
6
|
|
|
5
7
|

|
|
6
8
|
[](https://www.npmjs.com/package/@applemusic-like-lyrics/lyric)
|
|
7
9
|
[](https://www.npmjs.com/package/@applemusic-like-lyrics/lyric)
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
构建成 WASM 模块以提供给其他项目使用。
|
|
11
|
+
A lyric parsing/generation module for AMLL, written in Rust and built into a WASM module using `wasm-pack` for use in other projects.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
Since this module focuses only on lyric content, it discards all information unrelated to lyrics. If you need to get detailed information from a lyric file (such as artist), please consider using other frameworks.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
Lyric format support table:
|
|
15
16
|
|
|
16
|
-
|
|
|
17
|
-
| ------------------------------------- |
|
|
18
|
-
| LyRiC
|
|
19
|
-
| ESLyric
|
|
20
|
-
|
|
|
21
|
-
| QQ
|
|
22
|
-
| Lyricify Syllable
|
|
23
|
-
| TTML
|
|
24
|
-
| ASS
|
|
17
|
+
| Source Format\Target Format | Parse Own Format | LyRiC Format `.lrc` | ESLyric Word-by-word Format `.lrc` | NetEase Cloud Music Word-by-word Format `.yrc` | QQ Music Word-by-word Format `.qrc` | Lyricify Syllable Word-by-word Format `.lys` | TTML Lyric Format `.ttml` | ASS Subtitle Format `.ass` |
|
|
18
|
+
| ------------------------------------- | --------------- | ------------------- | ---------------------------------- | --------------------------------------------- | ---------------------------------- | -------------------------------------------- | ------------------------ | -------------------------- |
|
|
19
|
+
| LyRiC Format `.lrc` | ✅ | / | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
20
|
+
| ESLyric Word-by-word Format `.lrc` | ✅ | ✅ | / | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
21
|
+
| NetEase Cloud Music Word-by-word Format `.yrc` | ✅ | ✅ [^1] | ✅ [^1] | / | ✅ | ✅ | ✅ | ✅ |
|
|
22
|
+
| QQ Music Word-by-word Format `.qrc` | ✅ | ✅ [^1] | ✅ [^1] | ✅ | / | ✅ | ✅ | ✅ |
|
|
23
|
+
| Lyricify Syllable Word-by-word Format `.lys` | ✅ | ✅ [^1] | ✅ [^1] | ✅ [^2] | ✅ [^2] | / | ✅ | ✅ |
|
|
24
|
+
| TTML Lyric Format `.ttml` | ✅ | ✅ [^1] | ✅ [^1] | ✅ [^2] | ✅ [^2] | ✅ [^3] | / | ✅ |
|
|
25
|
+
| ASS Subtitle Format `.ass` | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | / |
|
|
25
26
|
|
|
26
|
-
[^1]:
|
|
27
|
-
[^2]:
|
|
28
|
-
[^3]:
|
|
27
|
+
[^1]: Will lose word-by-word timing data, vocal attributes (background vocals, duet vocals) and AMLL metadata
|
|
28
|
+
[^2]: Will lose vocal attributes (background vocals, duet vocals) and AMLL metadata
|
|
29
|
+
[^3]: Will lose AMLL metadata
|
|
29
30
|
|
|
30
|
-
##
|
|
31
|
+
## Using with Core Lyric Component
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
When using them together, note that **the lyric line structures of the two are not exactly the same**. You need to convert them in a way like the following example (using LyRiC as an example) for the lyric component to parse correctly:
|
|
33
34
|
|
|
34
35
|
```typescript
|
|
35
36
|
import { parseLrc } from "@applemusic-like-lyrics/lyric";
|
|
@@ -49,12 +50,12 @@ const converted = lines.map((line, i, lines) => ({
|
|
|
49
50
|
isBG: false,
|
|
50
51
|
isDuet: false,
|
|
51
52
|
}));
|
|
52
|
-
//
|
|
53
|
+
// Now you can pass converted to LyricPlayer
|
|
53
54
|
```
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
Using TypeScript is recommended as it makes it easier to detect errors.
|
|
56
57
|
|
|
57
|
-
##
|
|
58
|
+
## Building
|
|
58
59
|
|
|
59
60
|
```shell
|
|
60
61
|
wasm-pack build --target bundler --release --scope applemusic-like-lyrics
|
package/package.json
CHANGED
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
"SteveXMH <39523898+Steve-xmh@users.noreply.github.com>"
|
|
5
5
|
],
|
|
6
6
|
"description": "一个歌词解析/生成模块,着重于歌词内容解析,支持多种格式",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.3.0",
|
|
8
8
|
"license": "GPL-3.0",
|
|
9
|
+
"nx": {
|
|
10
|
+
"tags": [
|
|
11
|
+
"library"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
9
14
|
"repository": {
|
|
10
15
|
"type": "git",
|
|
11
16
|
"url": "https://github.com/Steve-xmh/applemusic-like-lyrics"
|
|
12
17
|
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "wasm-pack build --release",
|
|
15
|
-
"build:dev": "wasm-pack build --dev",
|
|
16
|
-
"fmt": "cargo fmt"
|
|
17
|
-
},
|
|
18
18
|
"files": [
|
|
19
19
|
"pkg/*.wasm",
|
|
20
20
|
"pkg/*.js",
|
|
@@ -25,5 +25,11 @@
|
|
|
25
25
|
"sideEffects": [
|
|
26
26
|
"./pkg/amll_lyric.js",
|
|
27
27
|
"./pkg/snippets/*"
|
|
28
|
-
]
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "wasm-pack build --release",
|
|
31
|
+
"build:dev": "wasm-pack build --dev",
|
|
32
|
+
"fmt": "cargo fmt",
|
|
33
|
+
"preinstall": "npx only-allow pnpm"
|
|
34
|
+
}
|
|
29
35
|
}
|
package/pkg/amll_lyric.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
|
-
* When the `console_error_panic_hook` feature is enabled, we can call the
|
|
5
|
-
* `set_panic_hook` function at least once during initialization, and then
|
|
6
|
-
* we will get better error messages if our code ever panics.
|
|
7
|
-
*
|
|
8
|
-
* For more details see
|
|
9
|
-
* https://github.com/rustwasm/console_error_panic_hook#readme
|
|
10
|
-
*/
|
|
4
|
+
* When the `console_error_panic_hook` feature is enabled, we can call the
|
|
5
|
+
* `set_panic_hook` function at least once during initialization, and then
|
|
6
|
+
* we will get better error messages if our code ever panics.
|
|
7
|
+
*
|
|
8
|
+
* For more details see
|
|
9
|
+
* https://github.com/rustwasm/console_error_panic_hook#readme
|
|
10
|
+
*/
|
|
11
11
|
export function wasm_start(): void;
|
|
12
|
-
|
|
13
12
|
/**
|
|
14
13
|
* 解析 LyRiC 格式的歌词字符串
|
|
15
14
|
* @param src 歌词字符串
|
|
@@ -82,11 +81,11 @@ export function stringifyEslrc(lines: LyricLine[]): string;
|
|
|
82
81
|
|
|
83
82
|
/**
|
|
84
83
|
* 将歌词数组转换为 ASS 字幕格式的字符串
|
|
85
|
-
*
|
|
84
|
+
*
|
|
86
85
|
* 注意导出会损失 10 毫秒以内的精度
|
|
87
|
-
*
|
|
86
|
+
*
|
|
88
87
|
* 主唱名称会变为 `v1`,对唱会变为 `v2`
|
|
89
|
-
*
|
|
88
|
+
*
|
|
90
89
|
* 如果是背景歌词则会在名称后面加上后缀 `-bg`
|
|
91
90
|
* @param lines 歌词数组
|
|
92
91
|
* @returns ASS 字幕格式的字符串
|
|
@@ -97,12 +96,14 @@ export function stringifyAss(lines: LyricLine[]): string;
|
|
|
97
96
|
* 一个歌词单词
|
|
98
97
|
*/
|
|
99
98
|
export interface LyricWord {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
/** 单词的起始时间 */
|
|
100
|
+
startTime: number;
|
|
101
|
+
/** 单词的结束时间 */
|
|
102
|
+
endTime: number;
|
|
103
|
+
/** 单词 */
|
|
104
|
+
word: string;
|
|
105
|
+
/** 单词的音译 */
|
|
106
|
+
romanWord: string;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
/**
|
|
@@ -110,21 +111,41 @@ export interface LyricWord {
|
|
|
110
111
|
* 如果是 LyRiC 等只能表达一行歌词的格式,则会将整行当做一个单词存储起来
|
|
111
112
|
*/
|
|
112
113
|
export interface LyricLine {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
114
|
+
/**
|
|
115
|
+
* 该行的所有单词
|
|
116
|
+
* 如果是 LyRiC 等只能表达一行歌词的格式,这里就只会有一个单词
|
|
117
|
+
*/
|
|
118
|
+
words: LyricWord[];
|
|
119
|
+
/**
|
|
120
|
+
* 该行的翻译
|
|
121
|
+
*/
|
|
122
|
+
translatedLyric: string;
|
|
123
|
+
/**
|
|
124
|
+
* 该行的音译
|
|
125
|
+
*/
|
|
126
|
+
romanLyric: string;
|
|
127
|
+
/**
|
|
128
|
+
* 该行是否为背景歌词行
|
|
129
|
+
* 此选项只有作为 Lyricify Syllable 文件格式导入导出时才有意义
|
|
130
|
+
*/
|
|
131
|
+
isBG: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* 该行是否为对唱歌词行(即歌词行靠右对齐)
|
|
134
|
+
* 此选项只有作为 Lyricify Syllable 文件格式导入导出时才有意义
|
|
135
|
+
*/
|
|
136
|
+
isDuet: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* 该行的开始时间
|
|
139
|
+
*
|
|
140
|
+
* **并不总是等于第一个单词的开始时间**
|
|
141
|
+
*/
|
|
142
|
+
startTime: number;
|
|
143
|
+
/**
|
|
144
|
+
* 该行的结束时间
|
|
145
|
+
*
|
|
146
|
+
* **并不总是等于最后一个单词的开始时间**
|
|
147
|
+
*/
|
|
148
|
+
endTime: number;
|
|
128
149
|
}
|
|
129
150
|
|
|
130
151
|
/**
|
|
@@ -139,14 +160,14 @@ export function decryptQrcHex(hexData: string): string;
|
|
|
139
160
|
* 一个 TTML 歌词行对象,存储了歌词行信息和 AMLL 元数据信息
|
|
140
161
|
*/
|
|
141
162
|
export interface TTMLLyric {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
163
|
+
/**
|
|
164
|
+
* TTML 中存储的歌词行信息
|
|
165
|
+
*/
|
|
166
|
+
lines: LyricLine[];
|
|
167
|
+
/**
|
|
168
|
+
* 一个元数据表,以 `[键, 值数组]` 的形式存储
|
|
169
|
+
*/
|
|
170
|
+
metadata: [string, string[]][];
|
|
150
171
|
}
|
|
151
172
|
|
|
152
173
|
/**
|