lyrics-transcriber 0.41.0__py3-none-any.whl → 0.42.0__py3-none-any.whl

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.
Files changed (77) hide show
  1. lyrics_transcriber/core/controller.py +30 -52
  2. lyrics_transcriber/correction/anchor_sequence.py +325 -150
  3. lyrics_transcriber/correction/corrector.py +224 -107
  4. lyrics_transcriber/correction/handlers/base.py +28 -10
  5. lyrics_transcriber/correction/handlers/extend_anchor.py +47 -24
  6. lyrics_transcriber/correction/handlers/levenshtein.py +75 -33
  7. lyrics_transcriber/correction/handlers/llm.py +290 -0
  8. lyrics_transcriber/correction/handlers/no_space_punct_match.py +81 -36
  9. lyrics_transcriber/correction/handlers/relaxed_word_count_match.py +46 -26
  10. lyrics_transcriber/correction/handlers/repeat.py +28 -11
  11. lyrics_transcriber/correction/handlers/sound_alike.py +68 -32
  12. lyrics_transcriber/correction/handlers/syllables_match.py +80 -30
  13. lyrics_transcriber/correction/handlers/word_count_match.py +36 -19
  14. lyrics_transcriber/correction/handlers/word_operations.py +68 -22
  15. lyrics_transcriber/correction/text_utils.py +3 -7
  16. lyrics_transcriber/frontend/.yarn/install-state.gz +0 -0
  17. lyrics_transcriber/frontend/.yarn/releases/yarn-4.6.0.cjs +934 -0
  18. lyrics_transcriber/frontend/.yarnrc.yml +3 -0
  19. lyrics_transcriber/frontend/dist/assets/{index-DKnNJHRK.js → index-coH8y7gV.js} +16284 -9032
  20. lyrics_transcriber/frontend/dist/assets/index-coH8y7gV.js.map +1 -0
  21. lyrics_transcriber/frontend/dist/index.html +1 -1
  22. lyrics_transcriber/frontend/package.json +6 -2
  23. lyrics_transcriber/frontend/src/App.tsx +18 -2
  24. lyrics_transcriber/frontend/src/api.ts +103 -6
  25. lyrics_transcriber/frontend/src/components/AudioPlayer.tsx +7 -6
  26. lyrics_transcriber/frontend/src/components/DetailsModal.tsx +86 -59
  27. lyrics_transcriber/frontend/src/components/EditModal.tsx +93 -43
  28. lyrics_transcriber/frontend/src/components/FileUpload.tsx +2 -2
  29. lyrics_transcriber/frontend/src/components/Header.tsx +251 -0
  30. lyrics_transcriber/frontend/src/components/LyricsAnalyzer.tsx +303 -265
  31. lyrics_transcriber/frontend/src/components/PreviewVideoSection.tsx +117 -0
  32. lyrics_transcriber/frontend/src/components/ReferenceView.tsx +125 -40
  33. lyrics_transcriber/frontend/src/components/ReviewChangesModal.tsx +129 -115
  34. lyrics_transcriber/frontend/src/components/TimelineEditor.tsx +59 -78
  35. lyrics_transcriber/frontend/src/components/TranscriptionView.tsx +40 -16
  36. lyrics_transcriber/frontend/src/components/WordEditControls.tsx +4 -10
  37. lyrics_transcriber/frontend/src/components/shared/components/HighlightedText.tsx +137 -68
  38. lyrics_transcriber/frontend/src/components/shared/components/Word.tsx +1 -1
  39. lyrics_transcriber/frontend/src/components/shared/hooks/useWordClick.ts +85 -115
  40. lyrics_transcriber/frontend/src/components/shared/types.js +2 -0
  41. lyrics_transcriber/frontend/src/components/shared/types.ts +15 -7
  42. lyrics_transcriber/frontend/src/components/shared/utils/keyboardHandlers.ts +35 -0
  43. lyrics_transcriber/frontend/src/components/shared/utils/localStorage.ts +78 -0
  44. lyrics_transcriber/frontend/src/components/shared/utils/referenceLineCalculator.ts +7 -7
  45. lyrics_transcriber/frontend/src/components/shared/utils/segmentOperations.ts +121 -0
  46. lyrics_transcriber/frontend/src/components/shared/utils/wordUtils.ts +22 -0
  47. lyrics_transcriber/frontend/src/types.js +2 -0
  48. lyrics_transcriber/frontend/src/types.ts +70 -49
  49. lyrics_transcriber/frontend/src/validation.ts +132 -0
  50. lyrics_transcriber/frontend/tsconfig.tsbuildinfo +1 -1
  51. lyrics_transcriber/frontend/yarn.lock +3752 -0
  52. lyrics_transcriber/lyrics/base_lyrics_provider.py +75 -12
  53. lyrics_transcriber/lyrics/file_provider.py +6 -5
  54. lyrics_transcriber/lyrics/genius.py +5 -2
  55. lyrics_transcriber/lyrics/spotify.py +58 -21
  56. lyrics_transcriber/output/ass/config.py +16 -5
  57. lyrics_transcriber/output/cdg.py +1 -1
  58. lyrics_transcriber/output/generator.py +22 -8
  59. lyrics_transcriber/output/plain_text.py +15 -10
  60. lyrics_transcriber/output/segment_resizer.py +16 -3
  61. lyrics_transcriber/output/subtitles.py +27 -1
  62. lyrics_transcriber/output/video.py +107 -1
  63. lyrics_transcriber/review/__init__.py +0 -1
  64. lyrics_transcriber/review/server.py +337 -164
  65. lyrics_transcriber/transcribers/audioshake.py +3 -0
  66. lyrics_transcriber/transcribers/base_transcriber.py +11 -3
  67. lyrics_transcriber/transcribers/whisper.py +11 -1
  68. lyrics_transcriber/types.py +151 -105
  69. lyrics_transcriber/utils/word_utils.py +27 -0
  70. {lyrics_transcriber-0.41.0.dist-info → lyrics_transcriber-0.42.0.dist-info}/METADATA +3 -1
  71. {lyrics_transcriber-0.41.0.dist-info → lyrics_transcriber-0.42.0.dist-info}/RECORD +74 -61
  72. {lyrics_transcriber-0.41.0.dist-info → lyrics_transcriber-0.42.0.dist-info}/WHEEL +1 -1
  73. lyrics_transcriber/frontend/dist/assets/index-DKnNJHRK.js.map +0 -1
  74. lyrics_transcriber/frontend/package-lock.json +0 -4260
  75. lyrics_transcriber/frontend/src/components/shared/utils/initializeDataWithIds.tsx +0 -202
  76. {lyrics_transcriber-0.41.0.dist-info → lyrics_transcriber-0.42.0.dist-info}/LICENSE +0 -0
  77. {lyrics_transcriber-0.41.0.dist-info → lyrics_transcriber-0.42.0.dist-info}/entry_points.txt +0 -0
@@ -1,33 +1,36 @@
1
1
  export interface Word {
2
2
  id: string
3
3
  text: string
4
- start_time: number
5
- end_time: number
4
+ start_time: number | null
5
+ end_time: number | null
6
6
  confidence?: number
7
+ created_during_correction?: boolean
7
8
  }
8
9
 
9
10
  export interface LyricsSegment {
10
11
  id: string
11
12
  text: string
12
13
  words: Word[]
13
- start_time: number
14
- end_time: number
14
+ start_time: number | null
15
+ end_time: number | null
15
16
  }
16
17
 
17
18
  export interface WordCorrection {
18
- id: string
19
+ id?: string
20
+ handler: string
19
21
  original_word: string
20
22
  corrected_word: string
21
- segment_id: string
23
+ segment_id?: string
22
24
  word_id: string
25
+ corrected_word_id: string | null
23
26
  source: string
24
27
  confidence: number
25
28
  reason: string
26
29
  alternatives: Record<string, number>
27
30
  is_deletion: boolean
28
- split_index?: number
29
- split_total?: number
30
- reference_positions?: Record<string, string>
31
+ split_index?: number | null
32
+ split_total?: number | null
33
+ reference_positions?: Record<string, number>
31
34
  length: number
32
35
  }
33
36
 
@@ -40,63 +43,70 @@ export interface PhraseScore {
40
43
 
41
44
  export interface AnchorSequence {
42
45
  id: string
43
- words: string[]
44
- text: string
45
- length: number
46
- word_ids: string[]
47
- reference_word_ids: Record<string, string[]>
46
+ transcribed_word_ids: string[]
47
+ transcription_position: number
48
+ reference_positions: Record<string, number>
49
+ reference_word_ids: {
50
+ [source: string]: string[]
51
+ }
48
52
  confidence: number
49
53
  phrase_score: PhraseScore
50
54
  total_score: number
51
55
  }
52
56
 
53
- export interface AnchorReference {
54
- text: string
55
- word_ids: string[]
56
- confidence: number
57
- }
58
-
59
57
  export interface GapSequence {
60
58
  id: string
61
- text: string
62
- words: string[]
63
- word_ids: string[]
64
- length: number
65
- corrections: WordCorrection[]
66
- preceding_anchor: AnchorReference | null
67
- following_anchor: AnchorReference | null
68
- reference_words: {
59
+ transcribed_word_ids: string[]
60
+ transcription_position: number
61
+ preceding_anchor_id: string | null
62
+ following_anchor_id: string | null
63
+ reference_word_ids: {
69
64
  [source: string]: string[]
70
65
  }
71
66
  }
72
67
 
73
- export interface LyricsData {
74
- transcribed_text: string
75
- corrected_text: string
76
- original_segments: LyricsSegment[]
68
+ export interface ReferenceSource {
69
+ segments: LyricsSegment[]
77
70
  metadata: {
78
- anchor_sequences_count: number
79
- gap_sequences_count: number
80
- total_words: number
81
- correction_ratio: number
71
+ source: string
72
+ track_name: string | null
73
+ artist_names: string | null
74
+ album_name: string | null
75
+ duration_ms: number | null
76
+ explicit: boolean | null
77
+ language: string | null
78
+ is_synced: boolean
79
+ lyrics_provider: string
80
+ lyrics_provider_id: string
81
+ provider_metadata: Record<string, unknown>
82
82
  }
83
- anchor_sequences: AnchorSequence[]
84
- gap_sequences: GapSequence[]
85
- corrected_segments: LyricsSegment[]
86
- corrections_made: number
87
- confidence: number
83
+ source: string
84
+ }
85
+
86
+ export interface CorrectionStep {
87
+ handler_name: string
88
+ affected_word_ids: string[]
89
+ affected_segment_ids: string[]
88
90
  corrections: WordCorrection[]
89
- reference_texts: Record<string, string>
91
+ segments_before: LyricsSegment[]
92
+ segments_after: LyricsSegment[]
93
+ created_word_ids: string[]
94
+ deleted_word_ids: string[]
95
+ }
96
+
97
+ export interface CorrectionHandler {
98
+ id: string
99
+ name: string
100
+ description: string
101
+ enabled: boolean
90
102
  }
91
103
 
92
104
  export interface CorrectionData {
93
- transcribed_text: string
94
105
  original_segments: LyricsSegment[]
95
- reference_texts: Record<string, string>
106
+ reference_lyrics: Record<string, ReferenceSource>
96
107
  anchor_sequences: AnchorSequence[]
97
108
  gap_sequences: GapSequence[]
98
- resized_segments?: LyricsSegment[]
99
- corrected_text: string
109
+ resized_segments: LyricsSegment[]
100
110
  corrections_made: number
101
111
  confidence: number
102
112
  corrections: WordCorrection[]
@@ -106,13 +116,24 @@ export interface CorrectionData {
106
116
  gap_sequences_count: number
107
117
  total_words: number
108
118
  correction_ratio: number
119
+ audio_filepath?: string
120
+ audio_hash?: string
121
+ available_handlers?: CorrectionHandler[]
122
+ enabled_handlers?: string[]
109
123
  }
124
+ correction_steps: CorrectionStep[]
125
+ word_id_map: Record<string, string>
126
+ segment_id_map: Record<string, string>
110
127
  }
111
128
 
112
129
  export interface HighlightInfo {
113
- word_ids?: string[]
114
- reference_word_ids?: Record<string, string[]>
115
- type: 'single' | 'gap' | 'anchor'
130
+ type: 'single' | 'gap' | 'anchor' | 'correction'
131
+ sequence?: AnchorSequence | GapSequence
132
+ transcribed_words: Word[]
133
+ reference_words?: {
134
+ [source: string]: Word[]
135
+ }
136
+ correction?: WordCorrection
116
137
  }
117
138
 
118
139
  export type InteractionMode = 'highlight' | 'details' | 'edit'
@@ -0,0 +1,132 @@
1
+ import { z } from 'zod'
2
+
3
+ // Define schemas that match our TypeScript interfaces
4
+ const WordSchema = z.object({
5
+ id: z.string(),
6
+ text: z.string(),
7
+ start_time: z.number().nullable(),
8
+ end_time: z.number().nullable(),
9
+ confidence: z.number().optional(),
10
+ created_during_correction: z.boolean().optional()
11
+ })
12
+
13
+ const LyricsSegmentSchema = z.object({
14
+ id: z.string(),
15
+ text: z.string(),
16
+ words: z.array(WordSchema),
17
+ start_time: z.number().nullable(),
18
+ end_time: z.number().nullable()
19
+ })
20
+
21
+ const WordCorrectionSchema = z.object({
22
+ id: z.string().optional(),
23
+ handler: z.string(),
24
+ original_word: z.string(),
25
+ corrected_word: z.string(),
26
+ segment_id: z.string().optional(),
27
+ word_id: z.string(),
28
+ corrected_word_id: z.string().nullable(),
29
+ source: z.string(),
30
+ confidence: z.number(),
31
+ reason: z.string(),
32
+ alternatives: z.record(z.number()),
33
+ is_deletion: z.boolean(),
34
+ split_index: z.number().nullable().optional(),
35
+ split_total: z.number().nullable().optional(),
36
+ reference_positions: z.record(z.number()).optional(),
37
+ length: z.number()
38
+ })
39
+
40
+ const ReferenceSourceSchema = z.object({
41
+ segments: z.array(LyricsSegmentSchema),
42
+ metadata: z.object({
43
+ source: z.string(),
44
+ track_name: z.string().nullable(),
45
+ artist_names: z.string().nullable(),
46
+ album_name: z.string().nullable(),
47
+ duration_ms: z.number().nullable(),
48
+ explicit: z.boolean().nullable(),
49
+ language: z.string().nullable(),
50
+ is_synced: z.boolean(),
51
+ lyrics_provider: z.string(),
52
+ lyrics_provider_id: z.string(),
53
+ provider_metadata: z.record(z.unknown())
54
+ }),
55
+ source: z.string()
56
+ })
57
+
58
+ const PhraseScoreSchema = z.object({
59
+ phrase_type: z.string(),
60
+ natural_break_score: z.number(),
61
+ length_score: z.number(),
62
+ total_score: z.number()
63
+ })
64
+
65
+ const AnchorSequenceSchema = z.object({
66
+ id: z.string(),
67
+ transcribed_word_ids: z.array(z.string()),
68
+ transcription_position: z.number(),
69
+ reference_positions: z.record(z.number()),
70
+ reference_word_ids: z.record(z.array(z.string())),
71
+ confidence: z.number(),
72
+ phrase_score: PhraseScoreSchema,
73
+ total_score: z.number()
74
+ })
75
+
76
+ const GapSequenceSchema = z.object({
77
+ id: z.string(),
78
+ transcribed_word_ids: z.array(z.string()),
79
+ transcription_position: z.number(),
80
+ preceding_anchor_id: z.string().nullable(),
81
+ following_anchor_id: z.string().nullable(),
82
+ reference_word_ids: z.record(z.array(z.string()))
83
+ })
84
+
85
+ const CorrectionStepSchema = z.object({
86
+ handler_name: z.string(),
87
+ affected_word_ids: z.array(z.string()),
88
+ affected_segment_ids: z.array(z.string()),
89
+ corrections: z.array(WordCorrectionSchema),
90
+ segments_before: z.array(LyricsSegmentSchema),
91
+ segments_after: z.array(LyricsSegmentSchema),
92
+ created_word_ids: z.array(z.string()),
93
+ deleted_word_ids: z.array(z.string())
94
+ })
95
+
96
+ // Add new schema for correction handlers
97
+ const CorrectionHandlerSchema = z.object({
98
+ id: z.string(),
99
+ name: z.string(),
100
+ description: z.string(),
101
+ enabled: z.boolean()
102
+ })
103
+
104
+ // Update CorrectionDataSchema to include handler information
105
+ const CorrectionDataSchema = z.object({
106
+ original_segments: z.array(LyricsSegmentSchema),
107
+ reference_lyrics: z.record(ReferenceSourceSchema),
108
+ anchor_sequences: z.array(AnchorSequenceSchema),
109
+ gap_sequences: z.array(GapSequenceSchema),
110
+ resized_segments: z.array(LyricsSegmentSchema),
111
+ corrections_made: z.number(),
112
+ confidence: z.number(),
113
+ corrections: z.array(WordCorrectionSchema),
114
+ corrected_segments: z.array(LyricsSegmentSchema),
115
+ metadata: z.object({
116
+ anchor_sequences_count: z.number(),
117
+ gap_sequences_count: z.number(),
118
+ total_words: z.number(),
119
+ correction_ratio: z.number(),
120
+ audio_filepath: z.string().optional(),
121
+ audio_hash: z.string().optional(),
122
+ available_handlers: z.array(CorrectionHandlerSchema).optional(),
123
+ enabled_handlers: z.array(z.string()).optional()
124
+ }),
125
+ correction_steps: z.array(CorrectionStepSchema),
126
+ word_id_map: z.record(z.string()),
127
+ segment_id_map: z.record(z.string())
128
+ })
129
+
130
+ export function validateCorrectionData(data: unknown) {
131
+ return CorrectionDataSchema.parse(data)
132
+ }
@@ -1 +1 @@
1
- {"root":["./src/app.tsx","./src/api.ts","./src/main.tsx","./src/types.ts","./src/vite-env.d.ts","./src/components/audioplayer.tsx","./src/components/correctionmetrics.tsx","./src/components/detailsmodal.tsx","./src/components/editmodal.tsx","./src/components/fileupload.tsx","./src/components/lyricsanalyzer.tsx","./src/components/modeselector.tsx","./src/components/referenceview.tsx","./src/components/reviewchangesmodal.tsx","./src/components/segmentdetailsmodal.tsx","./src/components/timelineeditor.tsx","./src/components/transcriptionview.tsx","./src/components/wordeditcontrols.tsx","./src/components/shared/constants.ts","./src/components/shared/styles.ts","./src/components/shared/types.ts","./src/components/shared/components/highlightedtext.tsx","./src/components/shared/components/sourceselector.tsx","./src/components/shared/components/word.tsx","./src/components/shared/hooks/usewordclick.ts","./src/components/shared/utils/initializedatawithids.tsx","./src/components/shared/utils/referencelinecalculator.ts"],"version":"5.6.3"}
1
+ {"root":["./src/app.tsx","./src/api.ts","./src/main.tsx","./src/types.ts","./src/validation.ts","./src/vite-env.d.ts","./src/components/audioplayer.tsx","./src/components/correctionmetrics.tsx","./src/components/detailsmodal.tsx","./src/components/editmodal.tsx","./src/components/fileupload.tsx","./src/components/header.tsx","./src/components/lyricsanalyzer.tsx","./src/components/modeselector.tsx","./src/components/previewvideosection.tsx","./src/components/referenceview.tsx","./src/components/reviewchangesmodal.tsx","./src/components/segmentdetailsmodal.tsx","./src/components/timelineeditor.tsx","./src/components/transcriptionview.tsx","./src/components/wordeditcontrols.tsx","./src/components/shared/constants.ts","./src/components/shared/styles.ts","./src/components/shared/types.ts","./src/components/shared/components/highlightedtext.tsx","./src/components/shared/components/sourceselector.tsx","./src/components/shared/components/word.tsx","./src/components/shared/hooks/usewordclick.ts","./src/components/shared/utils/keyboardhandlers.ts","./src/components/shared/utils/localstorage.ts","./src/components/shared/utils/referencelinecalculator.ts","./src/components/shared/utils/segmentoperations.ts","./src/components/shared/utils/wordutils.ts"],"version":"5.6.3"}