mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-12-02 01:48:08 +09:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90d36a63f7 | ||
|
|
84928fed33 | ||
|
|
f144797366 | ||
|
|
a86273adf1 | ||
|
|
f0b447823b |
No files matched your search
+10
-12
@@ -901,11 +901,11 @@ class KaraokePrep:
|
||||
for sig in (signal.SIGINT, signal.SIGTERM):
|
||||
loop.remove_signal_handler(sig)
|
||||
|
||||
async def shutdown(self, signal):
|
||||
async def shutdown(self, signal_received):
|
||||
"""Handle shutdown signals gracefully."""
|
||||
self.logger.info(f"Received exit signal {signal.name}...")
|
||||
self.logger.info(f"Received exit signal {signal_received.name}...")
|
||||
|
||||
# Get all running tasks
|
||||
# Get all running tasks except the current shutdown task
|
||||
tasks = [t for t in asyncio.all_tasks() if t is not asyncio.current_task()]
|
||||
|
||||
if tasks:
|
||||
@@ -914,17 +914,15 @@ class KaraokePrep:
|
||||
for task in tasks:
|
||||
task.cancel()
|
||||
|
||||
self.logger.info("Received cancellation request, cleaning up...")
|
||||
|
||||
# Wait for all tasks to complete with cancellation
|
||||
try:
|
||||
await asyncio.gather(*tasks, return_exceptions=True)
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
# Use return_exceptions=True to gather all results without raising
|
||||
await asyncio.gather(*tasks, return_exceptions=True)
|
||||
|
||||
# Force exit after cleanup
|
||||
self.logger.info("Cleanup complete, exiting...")
|
||||
sys.exit(0) # Add this line to force exit
|
||||
self.logger.info("Cleanup complete")
|
||||
|
||||
# Raise KeyboardInterrupt to propagate the cancellation up the call stack
|
||||
# This allows the main event loop to exit cleanly
|
||||
raise KeyboardInterrupt()
|
||||
|
||||
async def process_playlist(self):
|
||||
if self.artist is None or self.title is None:
|
||||
|
||||
@@ -353,8 +353,9 @@ def create_parser(prog: str = "karaoke-gen") -> argparse.ArgumentParser:
|
||||
remote_group.add_argument(
|
||||
"--review-ui-url",
|
||||
default=os.environ.get('REVIEW_UI_URL', os.environ.get('LYRICS_REVIEW_UI_URL', 'https://gen.nomadkaraoke.com/lyrics')),
|
||||
help="Lyrics review UI URL. Default: 'https://gen.nomadkaraoke.com/lyrics'. "
|
||||
"Use 'http://localhost:5173' for Vite dev server during development. "
|
||||
help="Lyrics review UI URL. For remote mode: defaults to 'https://gen.nomadkaraoke.com/lyrics'. "
|
||||
"For local mode: defaults to bundled frontend (from lyrics_transcriber/frontend/). "
|
||||
"Use 'http://localhost:5173' to develop against Vite dev server. "
|
||||
"(env: REVIEW_UI_URL or LYRICS_REVIEW_UI_URL)",
|
||||
)
|
||||
remote_group.add_argument(
|
||||
|
||||
@@ -313,9 +313,18 @@ async def async_main():
|
||||
args = parser.parse_args()
|
||||
|
||||
# Set review UI URL environment variable for the lyrics transcriber review server
|
||||
# This allows development against a local frontend dev server (e.g., http://localhost:5173)
|
||||
# Only set this if the user explicitly wants to use a dev server (e.g., http://localhost:5173)
|
||||
# By default, let the ReviewServer use its bundled local frontend (served from lyrics_transcriber/frontend/)
|
||||
# This enables local iteration on the frontend without redeploying
|
||||
if hasattr(args, 'review_ui_url') and args.review_ui_url:
|
||||
os.environ['LYRICS_REVIEW_UI_URL'] = args.review_ui_url
|
||||
# Check if user provided a custom value (not the default hosted URL)
|
||||
default_hosted_urls = [
|
||||
'https://gen.nomadkaraoke.com/lyrics',
|
||||
'https://lyrics.nomadkaraoke.com'
|
||||
]
|
||||
if args.review_ui_url.rstrip('/') not in [url.rstrip('/') for url in default_hosted_urls]:
|
||||
# User explicitly wants a specific URL (e.g., Vite dev server)
|
||||
os.environ['LYRICS_REVIEW_UI_URL'] = args.review_ui_url
|
||||
|
||||
# Process style overrides
|
||||
try:
|
||||
@@ -746,7 +755,7 @@ async def async_main():
|
||||
except UserCancelledError:
|
||||
logger.info("Operation cancelled by user")
|
||||
return
|
||||
except KeyboardInterrupt:
|
||||
except (KeyboardInterrupt, asyncio.CancelledError):
|
||||
logger.info("Operation cancelled by user (Ctrl+C)")
|
||||
return
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "lyrics-transcriber-frontend",
|
||||
"private": true,
|
||||
"homepage": "https://nomadkaraoke.github.io/lyrics-transcriber-frontend",
|
||||
"version": "0.82.0",
|
||||
"version": "0.83.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
+38
-22
@@ -34056,13 +34056,26 @@ function validateCorrectionData(data) {
|
||||
return CorrectionDataSchema.parse(data);
|
||||
}
|
||||
class LiveApiClient {
|
||||
constructor(baseUrl) {
|
||||
constructor(baseUrl, reviewToken) {
|
||||
__publicField(this, "reviewToken");
|
||||
__publicField(this, "isUpdatingHandlers", false);
|
||||
this.baseUrl = baseUrl;
|
||||
this.baseUrl = baseUrl.replace(/\/$/, "");
|
||||
this.reviewToken = reviewToken;
|
||||
}
|
||||
/**
|
||||
* Build URL with reviewToken query parameter if available
|
||||
*/
|
||||
buildUrl(path) {
|
||||
const url = `${this.baseUrl}${path}`;
|
||||
if (this.reviewToken) {
|
||||
const separator = url.includes("?") ? "&" : "?";
|
||||
return `${url}${separator}review_token=${encodeURIComponent(this.reviewToken)}`;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
async getCorrectionData() {
|
||||
const response = await fetch(`${this.baseUrl}/correction-data`);
|
||||
const response = await fetch(this.buildUrl("/correction-data"));
|
||||
if (!response.ok) {
|
||||
throw new Error(`API error: ${response.statusText}`);
|
||||
}
|
||||
@@ -34079,7 +34092,7 @@ class LiveApiClient {
|
||||
corrections: data.corrections,
|
||||
corrected_segments: data.corrected_segments
|
||||
};
|
||||
const response = await fetch(`${this.baseUrl}/complete`, {
|
||||
const response = await fetch(this.buildUrl("/complete"), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -34091,14 +34104,14 @@ class LiveApiClient {
|
||||
}
|
||||
}
|
||||
getAudioUrl(audioHash) {
|
||||
return `${this.baseUrl}/audio/${audioHash}`;
|
||||
return this.buildUrl(`/audio/${audioHash}`);
|
||||
}
|
||||
async generatePreviewVideo(data) {
|
||||
const updatePayload = {
|
||||
corrections: data.corrections,
|
||||
corrected_segments: data.corrected_segments
|
||||
};
|
||||
const response = await fetch(`${this.baseUrl}/preview-video`, {
|
||||
const response = await fetch(this.buildUrl("/preview-video"), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -34114,14 +34127,14 @@ class LiveApiClient {
|
||||
return await response.json();
|
||||
}
|
||||
getPreviewVideoUrl(previewHash) {
|
||||
return `${this.baseUrl}/preview-video/${previewHash}`;
|
||||
return this.buildUrl(`/preview-video/${previewHash}`);
|
||||
}
|
||||
async updateHandlers(enabledHandlers) {
|
||||
console.log("API: Starting handler update...");
|
||||
this.isUpdatingHandlers = true;
|
||||
console.log("API: Set isUpdatingHandlers to", this.isUpdatingHandlers);
|
||||
try {
|
||||
const response = await fetch(`${this.baseUrl}/handlers`, {
|
||||
const response = await fetch(this.buildUrl("/handlers"), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -34147,7 +34160,7 @@ class LiveApiClient {
|
||||
source,
|
||||
lyrics
|
||||
};
|
||||
const response = await fetch(`${this.baseUrl}/add-lyrics`, {
|
||||
const response = await fetch(this.buildUrl("/add-lyrics"), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -34165,7 +34178,7 @@ class LiveApiClient {
|
||||
}
|
||||
async submitAnnotations(annotations) {
|
||||
for (const annotation of annotations) {
|
||||
const response = await fetch(`${this.baseUrl}/v1/annotations`, {
|
||||
const response = await fetch(this.buildUrl("/v1/annotations"), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -34178,7 +34191,7 @@ class LiveApiClient {
|
||||
}
|
||||
}
|
||||
async getAnnotationStats() {
|
||||
const response = await fetch(`${this.baseUrl}/v1/annotations/stats`);
|
||||
const response = await fetch(this.buildUrl("/v1/annotations/stats"));
|
||||
if (!response.ok) {
|
||||
throw new Error(`API error: ${response.statusText}`);
|
||||
}
|
||||
@@ -38943,10 +38956,12 @@ const TimelineCanvas = reactExports.memo(function TimelineCanvas2({
|
||||
const deltaTime = time - dragStartRef.current.time;
|
||||
const updates = [];
|
||||
for (const [wordId, originalTimes] of dragOriginalTimesRef.current) {
|
||||
const newStartTime = Math.max(0, originalTimes.start + deltaTime);
|
||||
const newEndTime = Math.max(newStartTime + 0.05, originalTimes.end + deltaTime);
|
||||
updates.push({
|
||||
wordId,
|
||||
newStartTime: Math.max(0, originalTimes.start + deltaTime),
|
||||
newEndTime: Math.max(0.05, originalTimes.end + deltaTime)
|
||||
newStartTime,
|
||||
newEndTime
|
||||
});
|
||||
}
|
||||
if (updates.length > 0) {
|
||||
@@ -39275,7 +39290,7 @@ const LyricsSynchronizer = reactExports.memo(function LyricsSynchronizer2({
|
||||
);
|
||||
const allWords = reactExports.useMemo(() => getAllWords(workingSegments), [workingSegments]);
|
||||
const audioDuration = reactExports.useMemo(() => {
|
||||
if (window.getAudioDuration) {
|
||||
if (typeof window.getAudioDuration === "function") {
|
||||
const duration2 = window.getAudioDuration();
|
||||
return duration2 > 0 ? duration2 : 300;
|
||||
}
|
||||
@@ -39347,7 +39362,7 @@ const LyricsSynchronizer = reactExports.memo(function LyricsSynchronizer2({
|
||||
const [isPlaying, setIsPlaying] = reactExports.useState(false);
|
||||
reactExports.useEffect(() => {
|
||||
const checkPlaying = () => {
|
||||
setIsPlaying(window.isAudioPlaying || false);
|
||||
setIsPlaying(typeof window.isAudioPlaying === "boolean" ? window.isAudioPlaying : false);
|
||||
};
|
||||
checkPlaying();
|
||||
const interval = setInterval(checkPlaying, 100);
|
||||
@@ -39359,7 +39374,7 @@ const LyricsSynchronizer = reactExports.memo(function LyricsSynchronizer2({
|
||||
}
|
||||
}, [onPlaySegment]);
|
||||
const handleStopAudio = reactExports.useCallback(() => {
|
||||
if (window.toggleAudioPlayback && window.isAudioPlaying) {
|
||||
if (typeof window.toggleAudioPlayback === "function" && window.isAudioPlaying) {
|
||||
window.toggleAudioPlayback();
|
||||
}
|
||||
if (isManualSyncing) {
|
||||
@@ -39616,7 +39631,7 @@ const LyricsSynchronizer = reactExports.memo(function LyricsSynchronizer2({
|
||||
if (onPlaySegment) {
|
||||
onPlaySegment(time);
|
||||
setTimeout(() => {
|
||||
if (window.toggleAudioPlayback && window.isAudioPlaying) {
|
||||
if (typeof window.toggleAudioPlayback === "function" && window.isAudioPlaying) {
|
||||
window.toggleAudioPlayback();
|
||||
}
|
||||
}, 50);
|
||||
@@ -42923,22 +42938,23 @@ function App() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const encodedApiUrl = params.get("baseApiUrl");
|
||||
const audioHashParam = params.get("audioHash");
|
||||
const reviewTokenParam = params.get("reviewToken");
|
||||
if (encodedApiUrl) {
|
||||
const baseApiUrl = decodeURIComponent(encodedApiUrl);
|
||||
setApiClient(new LiveApiClient(baseApiUrl));
|
||||
setApiClient(new LiveApiClient(baseApiUrl, reviewTokenParam || void 0));
|
||||
setIsReadOnly(false);
|
||||
if (audioHashParam) {
|
||||
setAudioHash(audioHashParam);
|
||||
}
|
||||
fetchData(baseApiUrl);
|
||||
fetchData(baseApiUrl, reviewTokenParam || void 0);
|
||||
} else {
|
||||
setApiClient(new FileOnlyClient());
|
||||
setIsReadOnly(true);
|
||||
}
|
||||
}, []);
|
||||
const fetchData = async (baseUrl) => {
|
||||
const fetchData = async (baseUrl, reviewToken) => {
|
||||
try {
|
||||
const client2 = new LiveApiClient(baseUrl);
|
||||
const client2 = new LiveApiClient(baseUrl, reviewToken);
|
||||
const data2 = await client2.getCorrectionData();
|
||||
setData(data2);
|
||||
} catch (err) {
|
||||
@@ -43258,7 +43274,7 @@ const theme = createTheme({
|
||||
spacing: (factor) => `${0.6 * factor}rem`
|
||||
// Further reduced from 0.8 * factor
|
||||
});
|
||||
const version = "0.82.0";
|
||||
const version = "0.83.0";
|
||||
const packageJson = {
|
||||
version
|
||||
};
|
||||
@@ -43269,4 +43285,4 @@ ReactDOM$1.createRoot(document.getElementById("root")).render(
|
||||
/* @__PURE__ */ jsxRuntimeExports.jsx(App, {})
|
||||
] })
|
||||
);
|
||||
//# sourceMappingURL=index-COYImAcx.js.map
|
||||
//# sourceMappingURL=index-BECn1o8Q.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"index-COYImAcx.js","sources":["../../node_modules/react/cjs/react.production.min.js","../../node_modules/react/index.js","../../node_modules/react/cjs/react-jsx-runtime.production.min.js","../../node_modules/react/jsx-runtime.js","../../node_modules/scheduler/cjs/scheduler.production.min.js","../../node_modules/scheduler/index.js","../../node_modules/react-dom/cjs/react-dom.production.min.js","../../node_modules/react-dom/index.js","../../node_modules/react-dom/client.js","../../node_modules/@mui/utils/esm/formatMuiErrorMessage/formatMuiErrorMessage.js","../../node_modules/@mui/material/styles/identifier.js","../../node_modules/@babel/runtime/helpers/esm/extends.js","../../node_modules/@emotion/sheet/dist/emotion-sheet.esm.js","../../node_modules/stylis/src/Enum.js","../../node_modules/stylis/src/Utility.js","../../node_modules/stylis/src/Tokenizer.js","../../node_modules/stylis/src/Parser.js","../../node_modules/stylis/src/Serializer.js","../../node_modules/stylis/src/Middleware.js","../../node_modules/@emotion/memoize/dist/emotion-memoize.esm.js","../../node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js","../../node_modules/react-is/cjs/react-is.production.min.js","../../node_modules/react-is/index.js","../../node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js","../../node_modules/@emotion/utils/dist/emotion-utils.browser.esm.js","../../node_modules/@emotion/hash/dist/emotion-hash.esm.js","../../node_modules/@emotion/unitless/dist/emotion-unitless.esm.js","../../node_modules/@emotion/serialize/dist/emotion-serialize.esm.js","../../node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js","../../node_modules/@emotion/react/dist/emotion-element-f0de968e.browser.esm.js","../../node_modules/@emotion/react/dist/emotion-react.browser.esm.js","../../node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js","../../node_modules/@emotion/styled/base/dist/emotion-styled-base.browser.esm.js","../../node_modules/@emotion/styled/dist/emotion-styled.browser.esm.js","../../node_modules/@mui/styled-engine/GlobalStyles/GlobalStyles.js","../../node_modules/@mui/styled-engine/index.js","../../node_modules/@mui/utils/node_modules/react-is/cjs/react-is.production.js","../../node_modules/@mui/utils/node_modules/react-is/index.js","../../node_modules/@mui/utils/esm/deepmerge/deepmerge.js","../../node_modules/@mui/system/esm/createBreakpoints/createBreakpoints.js","../../node_modules/@mui/system/esm/cssContainerQueries/cssContainerQueries.js","../../node_modules/@mui/system/esm/createTheme/shape.js","../../node_modules/@mui/system/esm/merge/merge.js","../../node_modules/@mui/system/esm/breakpoints/breakpoints.js","../../node_modules/@mui/utils/esm/capitalize/capitalize.js","../../node_modules/@mui/system/esm/style/style.js","../../node_modules/@mui/system/esm/memoize/memoize.js","../../node_modules/@mui/system/esm/spacing/spacing.js","../../node_modules/@mui/system/esm/createTheme/createSpacing.js","../../node_modules/@mui/system/esm/compose/compose.js","../../node_modules/@mui/system/esm/borders/borders.js","../../node_modules/@mui/system/esm/cssGrid/cssGrid.js","../../node_modules/@mui/system/esm/palette/palette.js","../../node_modules/@mui/system/esm/sizing/sizing.js","../../node_modules/@mui/system/esm/styleFunctionSx/defaultSxConfig.js","../../node_modules/@mui/system/esm/styleFunctionSx/styleFunctionSx.js","../../node_modules/@mui/system/esm/createTheme/applyStyles.js","../../node_modules/@mui/system/esm/createTheme/createTheme.js","../../node_modules/@mui/system/esm/useThemeWithoutDefault/useThemeWithoutDefault.js","../../node_modules/@mui/system/esm/useTheme/useTheme.js","../../node_modules/@mui/system/esm/GlobalStyles/GlobalStyles.js","../../node_modules/@mui/system/esm/styleFunctionSx/extendSxProp.js","../../node_modules/@mui/utils/esm/ClassNameGenerator/ClassNameGenerator.js","../../node_modules/clsx/dist/clsx.mjs","../../node_modules/@mui/system/esm/createBox/createBox.js","../../node_modules/@mui/utils/esm/generateUtilityClass/generateUtilityClass.js","../../node_modules/@mui/utils/esm/generateUtilityClasses/generateUtilityClasses.js","../../node_modules/@mui/system/esm/preprocessStyles.js","../../node_modules/@mui/system/esm/createStyled/createStyled.js","../../node_modules/@mui/system/esm/styled/styled.js","../../node_modules/@mui/utils/esm/resolveProps/resolveProps.js","../../node_modules/@mui/system/esm/useThemeProps/getThemeProps.js","../../node_modules/@mui/system/esm/useThemeProps/useThemeProps.js","../../node_modules/@mui/utils/esm/useEnhancedEffect/useEnhancedEffect.js","../../node_modules/@mui/system/esm/useMediaQuery/useMediaQuery.js","../../node_modules/@mui/utils/esm/clamp/clamp.js","../../node_modules/@mui/system/esm/colorManipulator/colorManipulator.js","../../node_modules/@mui/utils/esm/createChainedFunction/createChainedFunction.js","../../node_modules/@mui/utils/esm/debLine truncated
|
||||
{"version":3,"file":"index-BECn1o8Q.js","sources":["../../node_modules/react/cjs/react.production.min.js","../../node_modules/react/index.js","../../node_modules/react/cjs/react-jsx-runtime.production.min.js","../../node_modules/react/jsx-runtime.js","../../node_modules/scheduler/cjs/scheduler.production.min.js","../../node_modules/scheduler/index.js","../../node_modules/react-dom/cjs/react-dom.production.min.js","../../node_modules/react-dom/index.js","../../node_modules/react-dom/client.js","../../node_modules/@mui/utils/esm/formatMuiErrorMessage/formatMuiErrorMessage.js","../../node_modules/@mui/material/styles/identifier.js","../../node_modules/@babel/runtime/helpers/esm/extends.js","../../node_modules/@emotion/sheet/dist/emotion-sheet.esm.js","../../node_modules/stylis/src/Enum.js","../../node_modules/stylis/src/Utility.js","../../node_modules/stylis/src/Tokenizer.js","../../node_modules/stylis/src/Parser.js","../../node_modules/stylis/src/Serializer.js","../../node_modules/stylis/src/Middleware.js","../../node_modules/@emotion/memoize/dist/emotion-memoize.esm.js","../../node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js","../../node_modules/react-is/cjs/react-is.production.min.js","../../node_modules/react-is/index.js","../../node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js","../../node_modules/@emotion/utils/dist/emotion-utils.browser.esm.js","../../node_modules/@emotion/hash/dist/emotion-hash.esm.js","../../node_modules/@emotion/unitless/dist/emotion-unitless.esm.js","../../node_modules/@emotion/serialize/dist/emotion-serialize.esm.js","../../node_modules/@emotion/use-insertion-effect-with-fallbacks/dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js","../../node_modules/@emotion/react/dist/emotion-element-f0de968e.browser.esm.js","../../node_modules/@emotion/react/dist/emotion-react.browser.esm.js","../../node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js","../../node_modules/@emotion/styled/base/dist/emotion-styled-base.browser.esm.js","../../node_modules/@emotion/styled/dist/emotion-styled.browser.esm.js","../../node_modules/@mui/styled-engine/GlobalStyles/GlobalStyles.js","../../node_modules/@mui/styled-engine/index.js","../../node_modules/@mui/utils/node_modules/react-is/cjs/react-is.production.js","../../node_modules/@mui/utils/node_modules/react-is/index.js","../../node_modules/@mui/utils/esm/deepmerge/deepmerge.js","../../node_modules/@mui/system/esm/createBreakpoints/createBreakpoints.js","../../node_modules/@mui/system/esm/cssContainerQueries/cssContainerQueries.js","../../node_modules/@mui/system/esm/createTheme/shape.js","../../node_modules/@mui/system/esm/merge/merge.js","../../node_modules/@mui/system/esm/breakpoints/breakpoints.js","../../node_modules/@mui/utils/esm/capitalize/capitalize.js","../../node_modules/@mui/system/esm/style/style.js","../../node_modules/@mui/system/esm/memoize/memoize.js","../../node_modules/@mui/system/esm/spacing/spacing.js","../../node_modules/@mui/system/esm/createTheme/createSpacing.js","../../node_modules/@mui/system/esm/compose/compose.js","../../node_modules/@mui/system/esm/borders/borders.js","../../node_modules/@mui/system/esm/cssGrid/cssGrid.js","../../node_modules/@mui/system/esm/palette/palette.js","../../node_modules/@mui/system/esm/sizing/sizing.js","../../node_modules/@mui/system/esm/styleFunctionSx/defaultSxConfig.js","../../node_modules/@mui/system/esm/styleFunctionSx/styleFunctionSx.js","../../node_modules/@mui/system/esm/createTheme/applyStyles.js","../../node_modules/@mui/system/esm/createTheme/createTheme.js","../../node_modules/@mui/system/esm/useThemeWithoutDefault/useThemeWithoutDefault.js","../../node_modules/@mui/system/esm/useTheme/useTheme.js","../../node_modules/@mui/system/esm/GlobalStyles/GlobalStyles.js","../../node_modules/@mui/system/esm/styleFunctionSx/extendSxProp.js","../../node_modules/@mui/utils/esm/ClassNameGenerator/ClassNameGenerator.js","../../node_modules/clsx/dist/clsx.mjs","../../node_modules/@mui/system/esm/createBox/createBox.js","../../node_modules/@mui/utils/esm/generateUtilityClass/generateUtilityClass.js","../../node_modules/@mui/utils/esm/generateUtilityClasses/generateUtilityClasses.js","../../node_modules/@mui/system/esm/preprocessStyles.js","../../node_modules/@mui/system/esm/createStyled/createStyled.js","../../node_modules/@mui/system/esm/styled/styled.js","../../node_modules/@mui/utils/esm/resolveProps/resolveProps.js","../../node_modules/@mui/system/esm/useThemeProps/getThemeProps.js","../../node_modules/@mui/system/esm/useThemeProps/useThemeProps.js","../../node_modules/@mui/utils/esm/useEnhancedEffect/useEnhancedEffect.js","../../node_modules/@mui/system/esm/useMediaQuery/useMediaQuery.js","../../node_modules/@mui/utils/esm/clamp/clamp.js","../../node_modules/@mui/system/esm/colorManipulator/colorManipulator.js","../../node_modules/@mui/utils/esm/createChainedFunction/createChainedFunction.js","../../node_modules/@mui/utils/esm/debLine truncated
|
||||
@@ -10,7 +10,7 @@
|
||||
<link rel="icon" type="image/png" sizes="512x512" href="/android-chrome-512x512.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Nomad Karaoke: Lyrics Review</title>
|
||||
<script type="module" crossorigin src="/assets/index-COYImAcx.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-BECn1o8Q.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -363,8 +363,19 @@ class AnchorSequence:
|
||||
def from_dict(cls, data: Dict[str, Any]) -> "AnchorSequence":
|
||||
"""Create AnchorSequence from dictionary."""
|
||||
# Handle both old and new dictionary formats
|
||||
if "words" in data:
|
||||
# Old format - convert to new format without setting _words
|
||||
# Check for new format keys FIRST (they take priority even if old keys also present)
|
||||
if "transcribed_word_ids" in data:
|
||||
# New format - use existing IDs
|
||||
return cls(
|
||||
id=data.get("id", WordUtils.generate_id()),
|
||||
transcribed_word_ids=data["transcribed_word_ids"],
|
||||
transcription_position=data["transcription_position"],
|
||||
reference_positions=data["reference_positions"],
|
||||
reference_word_ids=data["reference_word_ids"],
|
||||
confidence=data["confidence"],
|
||||
)
|
||||
elif "words" in data:
|
||||
# Old format only - convert to new format by generating IDs
|
||||
# This ensures to_dict() always returns the new format
|
||||
words = data["words"]
|
||||
return cls(
|
||||
@@ -375,18 +386,9 @@ class AnchorSequence:
|
||||
reference_word_ids={source: [WordUtils.generate_id() for _ in words]
|
||||
for source in data["reference_positions"].keys()},
|
||||
confidence=data["confidence"],
|
||||
# Don't set _words - this ensures we always use the new format
|
||||
)
|
||||
else:
|
||||
# New format
|
||||
return cls(
|
||||
id=data.get("id", WordUtils.generate_id()),
|
||||
transcribed_word_ids=data["transcribed_word_ids"],
|
||||
transcription_position=data["transcription_position"],
|
||||
reference_positions=data["reference_positions"],
|
||||
reference_word_ids=data["reference_word_ids"],
|
||||
confidence=data["confidence"],
|
||||
)
|
||||
raise ValueError("AnchorSequence.from_dict requires either 'transcribed_word_ids' or 'words' key")
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "lyrics-transcriber"
|
||||
version = "0.82.0"
|
||||
version = "0.83.0"
|
||||
description = "Automatically create synchronised lyrics files in ASS and MidiCo LRC formats with word-level timestamps, using Whisper and lyrics from Genius and Spotify"
|
||||
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
|
||||
license = "MIT"
|
||||
|
||||
@@ -67,6 +67,56 @@ def test_anchor_sequence_properties():
|
||||
assert len(result["reference_word_ids"]["source1"]) == 2
|
||||
|
||||
|
||||
def test_anchor_sequence_from_dict_preserves_ids_with_both_formats():
|
||||
"""Test that from_dict prioritizes new format keys when both old and new are present.
|
||||
|
||||
This is a regression test for a bug where cached anchors with both 'words' (old format)
|
||||
and 'transcribed_word_ids' (new format) would incorrectly regenerate word IDs.
|
||||
The fix ensures that 'transcribed_word_ids' takes priority when present.
|
||||
"""
|
||||
# Dict with BOTH old format (words) and new format (transcribed_word_ids)
|
||||
# This is what the cache file looks like after to_dict() is called
|
||||
data = {
|
||||
"id": "test123",
|
||||
"transcribed_word_ids": ["original_id1", "original_id2", "original_id3"],
|
||||
"transcription_position": 0,
|
||||
"reference_positions": {"file": 0},
|
||||
"reference_word_ids": {"file": ["ref_id1", "ref_id2", "ref_id3"]},
|
||||
"confidence": 1.0,
|
||||
"words": ["word1", "word2", "word3"], # Old format key also present
|
||||
"text": "word1 word2 word3",
|
||||
"length": 3,
|
||||
}
|
||||
|
||||
anchor = AnchorSequence.from_dict(data)
|
||||
|
||||
# The fix should preserve the explicit IDs from transcribed_word_ids
|
||||
assert anchor.transcribed_word_ids == ["original_id1", "original_id2", "original_id3"], \
|
||||
"transcribed_word_ids should be preserved when both old and new format keys present"
|
||||
assert anchor.reference_word_ids == {"file": ["ref_id1", "ref_id2", "ref_id3"]}, \
|
||||
"reference_word_ids should be preserved when both old and new format keys present"
|
||||
assert anchor.id == "test123", "id should be preserved"
|
||||
|
||||
|
||||
def test_anchor_sequence_from_dict_old_format_only():
|
||||
"""Test that from_dict generates IDs when only old format is present."""
|
||||
# Dict with ONLY old format (words), no transcribed_word_ids
|
||||
data = {
|
||||
"transcription_position": 0,
|
||||
"reference_positions": {"file": 0},
|
||||
"confidence": 1.0,
|
||||
"words": ["word1", "word2", "word3"],
|
||||
}
|
||||
|
||||
anchor = AnchorSequence.from_dict(data)
|
||||
|
||||
# Should generate new IDs
|
||||
assert len(anchor.transcribed_word_ids) == 3
|
||||
assert len(anchor.reference_word_ids["file"]) == 3
|
||||
# IDs should be newly generated (not the literal word text)
|
||||
assert anchor.transcribed_word_ids != ["word1", "word2", "word3"]
|
||||
|
||||
|
||||
def test_find_ngrams(finder):
|
||||
words = ["a", "b", "c", "d"]
|
||||
assert finder._find_ngrams(words, 2) == [(["a", "b"], 0), (["b", "c"], 1), (["c", "d"], 2)]
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "karaoke-gen"
|
||||
version = "0.75.25"
|
||||
version = "0.75.26"
|
||||
description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens."
|
||||
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
|
||||
license = "MIT"
|
||||
|
||||
@@ -703,6 +703,88 @@ async def test_style_override_parsing(mock_run_review, mock_kprep_class, mock_ba
|
||||
assert prep_kwargs["style_overrides"] == expected_overrides
|
||||
|
||||
|
||||
# --- Test review_ui_url environment variable handling ---
|
||||
|
||||
@patch("karaoke_gen.utils.gen_cli.run_instrumental_review", return_value="clean")
|
||||
@patch("karaoke_gen.utils.gen_cli.is_url", return_value=False)
|
||||
@patch("karaoke_gen.utils.gen_cli.is_file", return_value=False)
|
||||
@patch("karaoke_gen.utils.gen_cli.KaraokePrep")
|
||||
async def test_review_ui_url_default_hosted_not_set_env_var(mock_kprep_class, mock_isfile, mock_isurl, mock_run_review, mock_base_args):
|
||||
"""Test that default hosted review UI URL does NOT set LYRICS_REVIEW_UI_URL env var.
|
||||
|
||||
This allows the ReviewServer to use its bundled local frontend by default.
|
||||
"""
|
||||
mock_base_args.args = ["Artist", "Title"]
|
||||
# Simulate the default hosted URL from cli_args
|
||||
mock_base_args.review_ui_url = "https://gen.nomadkaraoke.com/lyrics"
|
||||
|
||||
mock_kprep_instance = MagicMock()
|
||||
mock_kprep_class.return_value = mock_kprep_instance
|
||||
mock_kprep_instance.process = AsyncMock(return_value=[MOCK_PREP_TRACK])
|
||||
|
||||
# Clear the env var first
|
||||
env_backup = os.environ.get('LYRICS_REVIEW_UI_URL')
|
||||
if 'LYRICS_REVIEW_UI_URL' in os.environ:
|
||||
del os.environ['LYRICS_REVIEW_UI_URL']
|
||||
|
||||
try:
|
||||
with patch("karaoke_gen.utils.gen_cli.argparse.ArgumentParser") as mock_parser, \
|
||||
patch("karaoke_gen.utils.gen_cli.os.chdir"), \
|
||||
patch("karaoke_gen.utils.gen_cli.os.path.exists", return_value=True), \
|
||||
patch("karaoke_gen.utils.gen_cli.KaraokeFinalise"):
|
||||
mock_parser.return_value.parse_args.return_value = mock_base_args
|
||||
await gen_cli.async_main()
|
||||
|
||||
# Verify the env var was NOT set (so ReviewServer uses local frontend)
|
||||
assert 'LYRICS_REVIEW_UI_URL' not in os.environ or os.environ.get('LYRICS_REVIEW_UI_URL') != mock_base_args.review_ui_url
|
||||
finally:
|
||||
# Restore env var
|
||||
if env_backup:
|
||||
os.environ['LYRICS_REVIEW_UI_URL'] = env_backup
|
||||
elif 'LYRICS_REVIEW_UI_URL' in os.environ:
|
||||
del os.environ['LYRICS_REVIEW_UI_URL']
|
||||
|
||||
|
||||
@patch("karaoke_gen.utils.gen_cli.run_instrumental_review", return_value="clean")
|
||||
@patch("karaoke_gen.utils.gen_cli.is_url", return_value=False)
|
||||
@patch("karaoke_gen.utils.gen_cli.is_file", return_value=False)
|
||||
@patch("karaoke_gen.utils.gen_cli.KaraokePrep")
|
||||
async def test_review_ui_url_custom_dev_server_sets_env_var(mock_kprep_class, mock_isfile, mock_isurl, mock_run_review, mock_base_args):
|
||||
"""Test that custom dev server URL (e.g., localhost:5173) DOES set LYRICS_REVIEW_UI_URL env var.
|
||||
|
||||
This allows using a Vite dev server for local frontend development.
|
||||
"""
|
||||
mock_base_args.args = ["Artist", "Title"]
|
||||
# Simulate a custom dev server URL
|
||||
mock_base_args.review_ui_url = "http://localhost:5173"
|
||||
|
||||
mock_kprep_instance = MagicMock()
|
||||
mock_kprep_class.return_value = mock_kprep_instance
|
||||
mock_kprep_instance.process = AsyncMock(return_value=[MOCK_PREP_TRACK])
|
||||
|
||||
# Clear the env var first
|
||||
env_backup = os.environ.get('LYRICS_REVIEW_UI_URL')
|
||||
if 'LYRICS_REVIEW_UI_URL' in os.environ:
|
||||
del os.environ['LYRICS_REVIEW_UI_URL']
|
||||
|
||||
try:
|
||||
with patch("karaoke_gen.utils.gen_cli.argparse.ArgumentParser") as mock_parser, \
|
||||
patch("karaoke_gen.utils.gen_cli.os.chdir"), \
|
||||
patch("karaoke_gen.utils.gen_cli.os.path.exists", return_value=True), \
|
||||
patch("karaoke_gen.utils.gen_cli.KaraokeFinalise"):
|
||||
mock_parser.return_value.parse_args.return_value = mock_base_args
|
||||
await gen_cli.async_main()
|
||||
|
||||
# Verify the env var WAS set to the custom URL
|
||||
assert os.environ.get('LYRICS_REVIEW_UI_URL') == "http://localhost:5173"
|
||||
finally:
|
||||
# Restore env var
|
||||
if env_backup:
|
||||
os.environ['LYRICS_REVIEW_UI_URL'] = env_backup
|
||||
elif 'LYRICS_REVIEW_UI_URL' in os.environ:
|
||||
del os.environ['LYRICS_REVIEW_UI_URL']
|
||||
|
||||
|
||||
# --- Test _resolve_path_for_cwd helper function ---
|
||||
|
||||
class TestResolvePathForCwd:
|
||||
|
||||
Reference in new issue
Block a user