lyrics-transcriber 0.47.0__py3-none-any.whl → 0.48.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.
- lyrics_transcriber/frontend/dist/assets/{index-2vK-qVJS.js → index-BvRLUQmZ.js} +271 -239
- lyrics_transcriber/frontend/dist/assets/index-BvRLUQmZ.js.map +1 -0
- lyrics_transcriber/frontend/dist/index.html +1 -1
- lyrics_transcriber/frontend/src/components/LyricsAnalyzer.tsx +7 -1
- lyrics_transcriber/frontend/src/components/TranscriptionView.tsx +26 -1
- lyrics_transcriber/frontend/src/components/shared/types.ts +1 -0
- {lyrics_transcriber-0.47.0.dist-info → lyrics_transcriber-0.48.0.dist-info}/METADATA +1 -1
- {lyrics_transcriber-0.47.0.dist-info → lyrics_transcriber-0.48.0.dist-info}/RECORD +11 -11
- lyrics_transcriber/frontend/dist/assets/index-2vK-qVJS.js.map +0 -1
- {lyrics_transcriber-0.47.0.dist-info → lyrics_transcriber-0.48.0.dist-info}/LICENSE +0 -0
- {lyrics_transcriber-0.47.0.dist-info → lyrics_transcriber-0.48.0.dist-info}/WHEEL +0 -0
- {lyrics_transcriber-0.47.0.dist-info → lyrics_transcriber-0.48.0.dist-info}/entry_points.txt +0 -0
@@ -33650,6 +33650,243 @@ function SegmentDetailsModal({
|
|
33650
33650
|
const PlayCircleOutlineIcon = createSvgIcon(/* @__PURE__ */ jsxRuntimeExports.jsx("path", {
|
33651
33651
|
d: "m10 16.5 6-4.5-6-4.5zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8"
|
33652
33652
|
}), "PlayCircleOutline");
|
33653
|
+
const DeleteOutlineIcon = createSvgIcon(/* @__PURE__ */ jsxRuntimeExports.jsx("path", {
|
33654
|
+
d: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM8 9h8v10H8zm7.5-5-1-1h-5l-1 1H5v2h14V4z"
|
33655
|
+
}), "DeleteOutline");
|
33656
|
+
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
33657
|
+
let nanoid = (size = 21) => {
|
33658
|
+
let id = "";
|
33659
|
+
let bytes = crypto.getRandomValues(new Uint8Array(size |= 0));
|
33660
|
+
while (size--) {
|
33661
|
+
id += urlAlphabet[bytes[size] & 63];
|
33662
|
+
}
|
33663
|
+
return id;
|
33664
|
+
};
|
33665
|
+
const addSegmentBefore = (data, beforeIndex) => {
|
33666
|
+
const newData = { ...data };
|
33667
|
+
const beforeSegment = newData.corrected_segments[beforeIndex];
|
33668
|
+
const newStartTime = Math.max(0, (beforeSegment.start_time ?? 1) - 1);
|
33669
|
+
const newEndTime = newStartTime + 1;
|
33670
|
+
const newSegment = {
|
33671
|
+
id: nanoid(),
|
33672
|
+
text: "REPLACE",
|
33673
|
+
start_time: newStartTime,
|
33674
|
+
end_time: newEndTime,
|
33675
|
+
words: [{
|
33676
|
+
id: nanoid(),
|
33677
|
+
text: "REPLACE",
|
33678
|
+
start_time: newStartTime,
|
33679
|
+
end_time: newEndTime,
|
33680
|
+
confidence: 1
|
33681
|
+
}]
|
33682
|
+
};
|
33683
|
+
newData.corrected_segments.splice(beforeIndex, 0, newSegment);
|
33684
|
+
return newData;
|
33685
|
+
};
|
33686
|
+
const splitSegment = (data, segmentIndex, afterWordIndex) => {
|
33687
|
+
const newData = { ...data };
|
33688
|
+
const segment = newData.corrected_segments[segmentIndex];
|
33689
|
+
const firstHalfWords = segment.words.slice(0, afterWordIndex + 1);
|
33690
|
+
const secondHalfWords = segment.words.slice(afterWordIndex + 1);
|
33691
|
+
if (secondHalfWords.length === 0) return null;
|
33692
|
+
const lastFirstWord = firstHalfWords[firstHalfWords.length - 1];
|
33693
|
+
const firstSecondWord = secondHalfWords[0];
|
33694
|
+
const lastSecondWord = secondHalfWords[secondHalfWords.length - 1];
|
33695
|
+
const firstSegment = {
|
33696
|
+
...segment,
|
33697
|
+
words: firstHalfWords,
|
33698
|
+
text: firstHalfWords.map((w) => w.text).join(" "),
|
33699
|
+
end_time: lastFirstWord.end_time ?? null
|
33700
|
+
};
|
33701
|
+
const secondSegment = {
|
33702
|
+
id: nanoid(),
|
33703
|
+
words: secondHalfWords,
|
33704
|
+
text: secondHalfWords.map((w) => w.text).join(" "),
|
33705
|
+
start_time: firstSecondWord.start_time ?? null,
|
33706
|
+
end_time: lastSecondWord.end_time ?? null
|
33707
|
+
};
|
33708
|
+
newData.corrected_segments.splice(segmentIndex, 1, firstSegment, secondSegment);
|
33709
|
+
return newData;
|
33710
|
+
};
|
33711
|
+
const deleteSegment = (data, segmentIndex) => {
|
33712
|
+
const newData = { ...data };
|
33713
|
+
const deletedSegment = newData.corrected_segments[segmentIndex];
|
33714
|
+
newData.corrected_segments = newData.corrected_segments.filter((_, index) => index !== segmentIndex);
|
33715
|
+
newData.anchor_sequences = newData.anchor_sequences.map((anchor) => ({
|
33716
|
+
...anchor,
|
33717
|
+
transcribed_word_ids: anchor.transcribed_word_ids.filter(
|
33718
|
+
(wordId) => !deletedSegment.words.some((deletedWord) => deletedWord.id === wordId)
|
33719
|
+
)
|
33720
|
+
}));
|
33721
|
+
newData.gap_sequences = newData.gap_sequences.map((gap2) => ({
|
33722
|
+
...gap2,
|
33723
|
+
transcribed_word_ids: gap2.transcribed_word_ids.filter(
|
33724
|
+
(wordId) => !deletedSegment.words.some((deletedWord) => deletedWord.id === wordId)
|
33725
|
+
)
|
33726
|
+
}));
|
33727
|
+
return newData;
|
33728
|
+
};
|
33729
|
+
const updateSegment = (data, segmentIndex, updatedSegment) => {
|
33730
|
+
const newData = { ...data };
|
33731
|
+
updatedSegment.words = updatedSegment.words.map((word) => ({
|
33732
|
+
...word,
|
33733
|
+
id: word.id || nanoid()
|
33734
|
+
}));
|
33735
|
+
newData.corrected_segments[segmentIndex] = updatedSegment;
|
33736
|
+
return newData;
|
33737
|
+
};
|
33738
|
+
function mergeSegment(data, segmentIndex, mergeWithNext) {
|
33739
|
+
const segments = [...data.corrected_segments];
|
33740
|
+
const targetIndex = mergeWithNext ? segmentIndex + 1 : segmentIndex - 1;
|
33741
|
+
if (targetIndex < 0 || targetIndex >= segments.length) {
|
33742
|
+
return data;
|
33743
|
+
}
|
33744
|
+
const baseSegment = segments[segmentIndex];
|
33745
|
+
const targetSegment = segments[targetIndex];
|
33746
|
+
const mergedSegment = {
|
33747
|
+
id: nanoid(),
|
33748
|
+
words: mergeWithNext ? [...baseSegment.words, ...targetSegment.words] : [...targetSegment.words, ...baseSegment.words],
|
33749
|
+
text: mergeWithNext ? `${baseSegment.text} ${targetSegment.text}` : `${targetSegment.text} ${baseSegment.text}`,
|
33750
|
+
start_time: Math.min(
|
33751
|
+
baseSegment.start_time ?? Infinity,
|
33752
|
+
targetSegment.start_time ?? Infinity
|
33753
|
+
),
|
33754
|
+
end_time: Math.max(
|
33755
|
+
baseSegment.end_time ?? -Infinity,
|
33756
|
+
targetSegment.end_time ?? -Infinity
|
33757
|
+
)
|
33758
|
+
};
|
33759
|
+
const minIndex = Math.min(segmentIndex, targetIndex);
|
33760
|
+
segments.splice(minIndex, 2, mergedSegment);
|
33761
|
+
return {
|
33762
|
+
...data,
|
33763
|
+
corrected_segments: segments
|
33764
|
+
};
|
33765
|
+
}
|
33766
|
+
function findAndReplace(data, findText, replaceText, options = {
|
33767
|
+
caseSensitive: false,
|
33768
|
+
useRegex: false,
|
33769
|
+
fullTextMode: false
|
33770
|
+
}) {
|
33771
|
+
const newData = { ...data };
|
33772
|
+
if (options.fullTextMode) {
|
33773
|
+
newData.corrected_segments = data.corrected_segments.map((segment) => {
|
33774
|
+
let pattern;
|
33775
|
+
if (options.useRegex) {
|
33776
|
+
pattern = new RegExp(findText, options.caseSensitive ? "g" : "gi");
|
33777
|
+
} else {
|
33778
|
+
const escapedFindText = findText.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
33779
|
+
pattern = new RegExp(escapedFindText, options.caseSensitive ? "g" : "gi");
|
33780
|
+
}
|
33781
|
+
const segmentText = segment.text;
|
33782
|
+
if (!pattern.test(segmentText)) {
|
33783
|
+
return segment;
|
33784
|
+
}
|
33785
|
+
pattern.lastIndex = 0;
|
33786
|
+
const newSegmentText = segmentText.replace(pattern, replaceText);
|
33787
|
+
const newWordTexts = newSegmentText.trim().split(/\s+/).filter((text) => text.length > 0);
|
33788
|
+
const newWords = [];
|
33789
|
+
if (newWordTexts.length === segment.words.length) {
|
33790
|
+
for (let i = 0; i < newWordTexts.length; i++) {
|
33791
|
+
newWords.push({
|
33792
|
+
...segment.words[i],
|
33793
|
+
text: newWordTexts[i]
|
33794
|
+
});
|
33795
|
+
}
|
33796
|
+
} else if (newWordTexts.length < segment.words.length) {
|
33797
|
+
let oldWordIndex = 0;
|
33798
|
+
for (let i = 0; i < newWordTexts.length; i++) {
|
33799
|
+
while (oldWordIndex < segment.words.length && segment.words[oldWordIndex].text.trim() === "") {
|
33800
|
+
oldWordIndex++;
|
33801
|
+
}
|
33802
|
+
if (oldWordIndex < segment.words.length) {
|
33803
|
+
newWords.push({
|
33804
|
+
...segment.words[oldWordIndex],
|
33805
|
+
text: newWordTexts[i]
|
33806
|
+
});
|
33807
|
+
oldWordIndex++;
|
33808
|
+
} else {
|
33809
|
+
newWords.push({
|
33810
|
+
id: nanoid(),
|
33811
|
+
text: newWordTexts[i],
|
33812
|
+
start_time: null,
|
33813
|
+
end_time: null
|
33814
|
+
});
|
33815
|
+
}
|
33816
|
+
}
|
33817
|
+
} else {
|
33818
|
+
for (let i = 0; i < newWordTexts.length; i++) {
|
33819
|
+
if (i < segment.words.length) {
|
33820
|
+
newWords.push({
|
33821
|
+
...segment.words[i],
|
33822
|
+
text: newWordTexts[i]
|
33823
|
+
});
|
33824
|
+
} else {
|
33825
|
+
newWords.push({
|
33826
|
+
id: nanoid(),
|
33827
|
+
text: newWordTexts[i],
|
33828
|
+
start_time: null,
|
33829
|
+
end_time: null
|
33830
|
+
});
|
33831
|
+
}
|
33832
|
+
}
|
33833
|
+
}
|
33834
|
+
return {
|
33835
|
+
...segment,
|
33836
|
+
words: newWords,
|
33837
|
+
text: newSegmentText
|
33838
|
+
};
|
33839
|
+
});
|
33840
|
+
} else {
|
33841
|
+
newData.corrected_segments = data.corrected_segments.map((segment) => {
|
33842
|
+
let newWords = segment.words.map((word) => {
|
33843
|
+
let pattern;
|
33844
|
+
if (options.useRegex) {
|
33845
|
+
pattern = new RegExp(findText, options.caseSensitive ? "g" : "gi");
|
33846
|
+
} else {
|
33847
|
+
const escapedFindText = findText.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
33848
|
+
pattern = new RegExp(escapedFindText, options.caseSensitive ? "g" : "gi");
|
33849
|
+
}
|
33850
|
+
return {
|
33851
|
+
...word,
|
33852
|
+
text: word.text.replace(pattern, replaceText)
|
33853
|
+
};
|
33854
|
+
});
|
33855
|
+
newWords = newWords.filter((word) => word.text.trim() !== "");
|
33856
|
+
return {
|
33857
|
+
...segment,
|
33858
|
+
words: newWords,
|
33859
|
+
text: newWords.map((w) => w.text).join(" ")
|
33860
|
+
};
|
33861
|
+
});
|
33862
|
+
}
|
33863
|
+
newData.corrected_segments = newData.corrected_segments.filter((segment) => segment.words.length > 0);
|
33864
|
+
return newData;
|
33865
|
+
}
|
33866
|
+
function deleteWord(data, wordId) {
|
33867
|
+
const segmentIndex = data.corrected_segments.findIndex(
|
33868
|
+
(segment2) => segment2.words.some((word) => word.id === wordId)
|
33869
|
+
);
|
33870
|
+
if (segmentIndex === -1) {
|
33871
|
+
return data;
|
33872
|
+
}
|
33873
|
+
const segment = data.corrected_segments[segmentIndex];
|
33874
|
+
const wordIndex = segment.words.findIndex((word) => word.id === wordId);
|
33875
|
+
if (wordIndex === -1) {
|
33876
|
+
return data;
|
33877
|
+
}
|
33878
|
+
const updatedWords = segment.words.filter((_, index) => index !== wordIndex);
|
33879
|
+
if (updatedWords.length > 0) {
|
33880
|
+
const updatedSegment = {
|
33881
|
+
...segment,
|
33882
|
+
words: updatedWords,
|
33883
|
+
text: updatedWords.map((w) => w.text).join(" ")
|
33884
|
+
};
|
33885
|
+
return updateSegment(data, segmentIndex, updatedSegment);
|
33886
|
+
} else {
|
33887
|
+
return deleteSegment(data, segmentIndex);
|
33888
|
+
}
|
33889
|
+
}
|
33653
33890
|
const SegmentIndex = styled(Typography)(({ theme: theme2 }) => ({
|
33654
33891
|
color: theme2.palette.text.secondary,
|
33655
33892
|
width: "1.8em",
|
@@ -33688,9 +33925,16 @@ function TranscriptionView({
|
|
33688
33925
|
mode,
|
33689
33926
|
onPlaySegment,
|
33690
33927
|
currentTime = 0,
|
33691
|
-
anchors = []
|
33928
|
+
anchors = [],
|
33929
|
+
onDataChange
|
33692
33930
|
}) {
|
33693
33931
|
const [selectedSegmentIndex, setSelectedSegmentIndex] = reactExports.useState(null);
|
33932
|
+
const handleDeleteSegment = (segmentIndex) => {
|
33933
|
+
if (onDataChange) {
|
33934
|
+
const updatedData = deleteSegment(data, segmentIndex);
|
33935
|
+
onDataChange(updatedData);
|
33936
|
+
}
|
33937
|
+
};
|
33694
33938
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Paper, { sx: { p: 0.8 }, children: [
|
33695
33939
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Box, { sx: { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 0.5 }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { variant: "h6", sx: { fontSize: "0.9rem", mb: 0 }, children: "Corrected Transcription" }) }),
|
33696
33940
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Box, { sx: { display: "flex", flexDirection: "column", gap: 0.2 }, children: data.corrected_segments.map((segment, segmentIndex) => {
|
@@ -33745,6 +33989,22 @@ function TranscriptionView({
|
|
33745
33989
|
children: segmentIndex
|
33746
33990
|
}
|
33747
33991
|
),
|
33992
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
33993
|
+
IconButton,
|
33994
|
+
{
|
33995
|
+
size: "small",
|
33996
|
+
onClick: () => handleDeleteSegment(segmentIndex),
|
33997
|
+
sx: {
|
33998
|
+
padding: "1px",
|
33999
|
+
height: "18px",
|
34000
|
+
width: "18px",
|
34001
|
+
minHeight: "18px",
|
34002
|
+
minWidth: "18px"
|
34003
|
+
},
|
34004
|
+
title: "Delete segment",
|
34005
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteOutlineIcon, { sx: { fontSize: "0.9rem", color: "error.main" } })
|
34006
|
+
}
|
34007
|
+
),
|
33748
34008
|
segment.start_time !== null && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
33749
34009
|
IconButton,
|
33750
34010
|
{
|
@@ -33757,6 +34017,7 @@ function TranscriptionView({
|
|
33757
34017
|
minHeight: "18px",
|
33758
34018
|
minWidth: "18px"
|
33759
34019
|
},
|
34020
|
+
title: "Play segment",
|
33760
34021
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlayCircleOutlineIcon, { sx: { fontSize: "0.9rem" } })
|
33761
34022
|
}
|
33762
34023
|
)
|
@@ -33794,15 +34055,6 @@ function TranscriptionView({
|
|
33794
34055
|
const StopIcon = createSvgIcon(/* @__PURE__ */ jsxRuntimeExports.jsx("path", {
|
33795
34056
|
d: "M6 6h12v12H6z"
|
33796
34057
|
}), "Stop");
|
33797
|
-
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
33798
|
-
let nanoid = (size = 21) => {
|
33799
|
-
let id = "";
|
33800
|
-
let bytes = crypto.getRandomValues(new Uint8Array(size |= 0));
|
33801
|
-
while (size--) {
|
33802
|
-
id += urlAlphabet[bytes[size] & 63];
|
33803
|
-
}
|
33804
|
-
return id;
|
33805
|
-
};
|
33806
34058
|
const TAP_THRESHOLD_MS = 200;
|
33807
34059
|
const DEFAULT_WORD_DURATION = 1;
|
33808
34060
|
const OVERLAP_BUFFER = 0.01;
|
@@ -35967,231 +36219,6 @@ function ReviewChangesModal({
|
|
35967
36219
|
}
|
35968
36220
|
);
|
35969
36221
|
}
|
35970
|
-
const addSegmentBefore = (data, beforeIndex) => {
|
35971
|
-
const newData = { ...data };
|
35972
|
-
const beforeSegment = newData.corrected_segments[beforeIndex];
|
35973
|
-
const newStartTime = Math.max(0, (beforeSegment.start_time ?? 1) - 1);
|
35974
|
-
const newEndTime = newStartTime + 1;
|
35975
|
-
const newSegment = {
|
35976
|
-
id: nanoid(),
|
35977
|
-
text: "REPLACE",
|
35978
|
-
start_time: newStartTime,
|
35979
|
-
end_time: newEndTime,
|
35980
|
-
words: [{
|
35981
|
-
id: nanoid(),
|
35982
|
-
text: "REPLACE",
|
35983
|
-
start_time: newStartTime,
|
35984
|
-
end_time: newEndTime,
|
35985
|
-
confidence: 1
|
35986
|
-
}]
|
35987
|
-
};
|
35988
|
-
newData.corrected_segments.splice(beforeIndex, 0, newSegment);
|
35989
|
-
return newData;
|
35990
|
-
};
|
35991
|
-
const splitSegment = (data, segmentIndex, afterWordIndex) => {
|
35992
|
-
const newData = { ...data };
|
35993
|
-
const segment = newData.corrected_segments[segmentIndex];
|
35994
|
-
const firstHalfWords = segment.words.slice(0, afterWordIndex + 1);
|
35995
|
-
const secondHalfWords = segment.words.slice(afterWordIndex + 1);
|
35996
|
-
if (secondHalfWords.length === 0) return null;
|
35997
|
-
const lastFirstWord = firstHalfWords[firstHalfWords.length - 1];
|
35998
|
-
const firstSecondWord = secondHalfWords[0];
|
35999
|
-
const lastSecondWord = secondHalfWords[secondHalfWords.length - 1];
|
36000
|
-
const firstSegment = {
|
36001
|
-
...segment,
|
36002
|
-
words: firstHalfWords,
|
36003
|
-
text: firstHalfWords.map((w) => w.text).join(" "),
|
36004
|
-
end_time: lastFirstWord.end_time ?? null
|
36005
|
-
};
|
36006
|
-
const secondSegment = {
|
36007
|
-
id: nanoid(),
|
36008
|
-
words: secondHalfWords,
|
36009
|
-
text: secondHalfWords.map((w) => w.text).join(" "),
|
36010
|
-
start_time: firstSecondWord.start_time ?? null,
|
36011
|
-
end_time: lastSecondWord.end_time ?? null
|
36012
|
-
};
|
36013
|
-
newData.corrected_segments.splice(segmentIndex, 1, firstSegment, secondSegment);
|
36014
|
-
return newData;
|
36015
|
-
};
|
36016
|
-
const deleteSegment = (data, segmentIndex) => {
|
36017
|
-
const newData = { ...data };
|
36018
|
-
const deletedSegment = newData.corrected_segments[segmentIndex];
|
36019
|
-
newData.corrected_segments = newData.corrected_segments.filter((_, index) => index !== segmentIndex);
|
36020
|
-
newData.anchor_sequences = newData.anchor_sequences.map((anchor) => ({
|
36021
|
-
...anchor,
|
36022
|
-
transcribed_word_ids: anchor.transcribed_word_ids.filter(
|
36023
|
-
(wordId) => !deletedSegment.words.some((deletedWord) => deletedWord.id === wordId)
|
36024
|
-
)
|
36025
|
-
}));
|
36026
|
-
newData.gap_sequences = newData.gap_sequences.map((gap2) => ({
|
36027
|
-
...gap2,
|
36028
|
-
transcribed_word_ids: gap2.transcribed_word_ids.filter(
|
36029
|
-
(wordId) => !deletedSegment.words.some((deletedWord) => deletedWord.id === wordId)
|
36030
|
-
)
|
36031
|
-
}));
|
36032
|
-
return newData;
|
36033
|
-
};
|
36034
|
-
const updateSegment = (data, segmentIndex, updatedSegment) => {
|
36035
|
-
const newData = { ...data };
|
36036
|
-
updatedSegment.words = updatedSegment.words.map((word) => ({
|
36037
|
-
...word,
|
36038
|
-
id: word.id || nanoid()
|
36039
|
-
}));
|
36040
|
-
newData.corrected_segments[segmentIndex] = updatedSegment;
|
36041
|
-
return newData;
|
36042
|
-
};
|
36043
|
-
function mergeSegment(data, segmentIndex, mergeWithNext) {
|
36044
|
-
const segments = [...data.corrected_segments];
|
36045
|
-
const targetIndex = mergeWithNext ? segmentIndex + 1 : segmentIndex - 1;
|
36046
|
-
if (targetIndex < 0 || targetIndex >= segments.length) {
|
36047
|
-
return data;
|
36048
|
-
}
|
36049
|
-
const baseSegment = segments[segmentIndex];
|
36050
|
-
const targetSegment = segments[targetIndex];
|
36051
|
-
const mergedSegment = {
|
36052
|
-
id: nanoid(),
|
36053
|
-
words: mergeWithNext ? [...baseSegment.words, ...targetSegment.words] : [...targetSegment.words, ...baseSegment.words],
|
36054
|
-
text: mergeWithNext ? `${baseSegment.text} ${targetSegment.text}` : `${targetSegment.text} ${baseSegment.text}`,
|
36055
|
-
start_time: Math.min(
|
36056
|
-
baseSegment.start_time ?? Infinity,
|
36057
|
-
targetSegment.start_time ?? Infinity
|
36058
|
-
),
|
36059
|
-
end_time: Math.max(
|
36060
|
-
baseSegment.end_time ?? -Infinity,
|
36061
|
-
targetSegment.end_time ?? -Infinity
|
36062
|
-
)
|
36063
|
-
};
|
36064
|
-
const minIndex = Math.min(segmentIndex, targetIndex);
|
36065
|
-
segments.splice(minIndex, 2, mergedSegment);
|
36066
|
-
return {
|
36067
|
-
...data,
|
36068
|
-
corrected_segments: segments
|
36069
|
-
};
|
36070
|
-
}
|
36071
|
-
function findAndReplace(data, findText, replaceText, options = {
|
36072
|
-
caseSensitive: false,
|
36073
|
-
useRegex: false,
|
36074
|
-
fullTextMode: false
|
36075
|
-
}) {
|
36076
|
-
const newData = { ...data };
|
36077
|
-
if (options.fullTextMode) {
|
36078
|
-
newData.corrected_segments = data.corrected_segments.map((segment) => {
|
36079
|
-
let pattern;
|
36080
|
-
if (options.useRegex) {
|
36081
|
-
pattern = new RegExp(findText, options.caseSensitive ? "g" : "gi");
|
36082
|
-
} else {
|
36083
|
-
const escapedFindText = findText.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
36084
|
-
pattern = new RegExp(escapedFindText, options.caseSensitive ? "g" : "gi");
|
36085
|
-
}
|
36086
|
-
const segmentText = segment.text;
|
36087
|
-
if (!pattern.test(segmentText)) {
|
36088
|
-
return segment;
|
36089
|
-
}
|
36090
|
-
pattern.lastIndex = 0;
|
36091
|
-
const newSegmentText = segmentText.replace(pattern, replaceText);
|
36092
|
-
const newWordTexts = newSegmentText.trim().split(/\s+/).filter((text) => text.length > 0);
|
36093
|
-
const newWords = [];
|
36094
|
-
if (newWordTexts.length === segment.words.length) {
|
36095
|
-
for (let i = 0; i < newWordTexts.length; i++) {
|
36096
|
-
newWords.push({
|
36097
|
-
...segment.words[i],
|
36098
|
-
text: newWordTexts[i]
|
36099
|
-
});
|
36100
|
-
}
|
36101
|
-
} else if (newWordTexts.length < segment.words.length) {
|
36102
|
-
let oldWordIndex = 0;
|
36103
|
-
for (let i = 0; i < newWordTexts.length; i++) {
|
36104
|
-
while (oldWordIndex < segment.words.length && segment.words[oldWordIndex].text.trim() === "") {
|
36105
|
-
oldWordIndex++;
|
36106
|
-
}
|
36107
|
-
if (oldWordIndex < segment.words.length) {
|
36108
|
-
newWords.push({
|
36109
|
-
...segment.words[oldWordIndex],
|
36110
|
-
text: newWordTexts[i]
|
36111
|
-
});
|
36112
|
-
oldWordIndex++;
|
36113
|
-
} else {
|
36114
|
-
newWords.push({
|
36115
|
-
id: nanoid(),
|
36116
|
-
text: newWordTexts[i],
|
36117
|
-
start_time: null,
|
36118
|
-
end_time: null
|
36119
|
-
});
|
36120
|
-
}
|
36121
|
-
}
|
36122
|
-
} else {
|
36123
|
-
for (let i = 0; i < newWordTexts.length; i++) {
|
36124
|
-
if (i < segment.words.length) {
|
36125
|
-
newWords.push({
|
36126
|
-
...segment.words[i],
|
36127
|
-
text: newWordTexts[i]
|
36128
|
-
});
|
36129
|
-
} else {
|
36130
|
-
newWords.push({
|
36131
|
-
id: nanoid(),
|
36132
|
-
text: newWordTexts[i],
|
36133
|
-
start_time: null,
|
36134
|
-
end_time: null
|
36135
|
-
});
|
36136
|
-
}
|
36137
|
-
}
|
36138
|
-
}
|
36139
|
-
return {
|
36140
|
-
...segment,
|
36141
|
-
words: newWords,
|
36142
|
-
text: newSegmentText
|
36143
|
-
};
|
36144
|
-
});
|
36145
|
-
} else {
|
36146
|
-
newData.corrected_segments = data.corrected_segments.map((segment) => {
|
36147
|
-
let newWords = segment.words.map((word) => {
|
36148
|
-
let pattern;
|
36149
|
-
if (options.useRegex) {
|
36150
|
-
pattern = new RegExp(findText, options.caseSensitive ? "g" : "gi");
|
36151
|
-
} else {
|
36152
|
-
const escapedFindText = findText.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
36153
|
-
pattern = new RegExp(escapedFindText, options.caseSensitive ? "g" : "gi");
|
36154
|
-
}
|
36155
|
-
return {
|
36156
|
-
...word,
|
36157
|
-
text: word.text.replace(pattern, replaceText)
|
36158
|
-
};
|
36159
|
-
});
|
36160
|
-
newWords = newWords.filter((word) => word.text.trim() !== "");
|
36161
|
-
return {
|
36162
|
-
...segment,
|
36163
|
-
words: newWords,
|
36164
|
-
text: newWords.map((w) => w.text).join(" ")
|
36165
|
-
};
|
36166
|
-
});
|
36167
|
-
}
|
36168
|
-
newData.corrected_segments = newData.corrected_segments.filter((segment) => segment.words.length > 0);
|
36169
|
-
return newData;
|
36170
|
-
}
|
36171
|
-
function deleteWord(data, wordId) {
|
36172
|
-
const segmentIndex = data.corrected_segments.findIndex(
|
36173
|
-
(segment2) => segment2.words.some((word) => word.id === wordId)
|
36174
|
-
);
|
36175
|
-
if (segmentIndex === -1) {
|
36176
|
-
return data;
|
36177
|
-
}
|
36178
|
-
const segment = data.corrected_segments[segmentIndex];
|
36179
|
-
const wordIndex = segment.words.findIndex((word) => word.id === wordId);
|
36180
|
-
if (wordIndex === -1) {
|
36181
|
-
return data;
|
36182
|
-
}
|
36183
|
-
const updatedWords = segment.words.filter((_, index) => index !== wordIndex);
|
36184
|
-
if (updatedWords.length > 0) {
|
36185
|
-
const updatedSegment = {
|
36186
|
-
...segment,
|
36187
|
-
words: updatedWords,
|
36188
|
-
text: updatedWords.map((w) => w.text).join(" ")
|
36189
|
-
};
|
36190
|
-
return updateSegment(data, segmentIndex, updatedSegment);
|
36191
|
-
} else {
|
36192
|
-
return deleteSegment(data, segmentIndex);
|
36193
|
-
}
|
36194
|
-
}
|
36195
36222
|
const generateStorageKey = (data) => {
|
36196
36223
|
var _a;
|
36197
36224
|
const text = ((_a = data.original_segments[0]) == null ? void 0 : _a.text) || "";
|
@@ -37158,7 +37185,8 @@ const MemoizedTranscriptionView = reactExports.memo(function MemoizedTranscripti
|
|
37158
37185
|
onPlaySegment,
|
37159
37186
|
currentTime,
|
37160
37187
|
anchors,
|
37161
|
-
disableHighlighting
|
37188
|
+
disableHighlighting,
|
37189
|
+
onDataChange
|
37162
37190
|
}) {
|
37163
37191
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
37164
37192
|
TranscriptionView,
|
@@ -37172,7 +37200,8 @@ const MemoizedTranscriptionView = reactExports.memo(function MemoizedTranscripti
|
|
37172
37200
|
highlightInfo,
|
37173
37201
|
onPlaySegment,
|
37174
37202
|
currentTime: disableHighlighting ? void 0 : currentTime,
|
37175
|
-
anchors
|
37203
|
+
anchors,
|
37204
|
+
onDataChange
|
37176
37205
|
}
|
37177
37206
|
);
|
37178
37207
|
});
|
@@ -37739,7 +37768,10 @@ function LyricsAnalyzer({ data: initialData, onFileLoad, apiClient, isReadOnly,
|
|
37739
37768
|
onPlaySegment: handlePlaySegment,
|
37740
37769
|
currentTime: currentAudioTime,
|
37741
37770
|
anchors: data.anchor_sequences,
|
37742
|
-
disableHighlighting: isAnyModalOpenMemo
|
37771
|
+
disableHighlighting: isAnyModalOpenMemo,
|
37772
|
+
onDataChange: (updatedData) => {
|
37773
|
+
setData(updatedData);
|
37774
|
+
}
|
37743
37775
|
}
|
37744
37776
|
),
|
37745
37777
|
!isReadOnly && apiClient && /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { sx: {
|
@@ -38221,4 +38253,4 @@ ReactDOM$1.createRoot(document.getElementById("root")).render(
|
|
38221
38253
|
/* @__PURE__ */ jsxRuntimeExports.jsx(App, {})
|
38222
38254
|
] })
|
38223
38255
|
);
|
38224
|
-
//# sourceMappingURL=index-
|
38256
|
+
//# sourceMappingURL=index-BvRLUQmZ.js.map
|