Skip to content

Commit

Permalink
fix: voices weren't loading correctly and this wasn't caught in previ…
Browse files Browse the repository at this point in the history
…ew :|
  • Loading branch information
VehpuS committed Mar 7, 2024
1 parent 54fc47b commit 54e14e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions musicxml-singer-with-oddvoices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"build-oddvoices": "git submodule update --init --recursive; cd ./src/oddvoices; make -C cpp; cd ../../",
"dev": "npm run build-oddvoices; vite",
"build": "tsc && npm run build-oddvoices && vite build && mkdir -p ./dist/singing-synthesis && cp -r ./dist/*.* ./dist/singing-synthesis/ && cp -r ./dist/assets ./dist/singing-synthesis/",
"build-dev": "tsc && npm run build-oddvoices && NODE_ENV=development vite build --mode development && mkdir -p ./dist/singing-synthesis && cp -r ./dist/*.* ./dist/singing-synthesis/ && cp -r ./dist/assets ./dist/singing-synthesis/",
"build": "tsc && npm run build-oddvoices && vite build && mkdir -p ./dist/singing-synthesis && cp -r ./dist/*.* ./dist/singing-synthesis/ && cp -r ./dist/assets ./dist/singing-synthesis/ && cp -r ./dist/voices ./dist/singing-synthesis/",
"build-dev": "tsc && npm run build-oddvoices && NODE_ENV=development vite build --mode development && mkdir -p ./dist/singing-synthesis && cp -r ./dist/*.* ./dist/singing-synthesis/ && cp -r ./dist/assets ./dist/singing-synthesis/ && cp -r ./dist/voices ./dist/singing-synthesis/",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
Expand Down
10 changes: 8 additions & 2 deletions musicxml-singer-with-oddvoices/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Typography,
} from "@mui/material";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import ErrorIcon from "@mui/icons-material/Error";

import { SplitParams } from "./oddVoiceJSON";
import { OddVoiceJSON } from "./oddVoiceJSON/oddVoiceHelpers";
Expand All @@ -34,7 +35,7 @@ function App() {
console.log({ oddVoiceOutputs });
}

const { isLoadingApp, isLoadingVoice, generateVoiceFromOddVoiceJson } = useOddVoicesApp();
const { isLoadingApp, isLoadingVoice, voiceLoadingFailed, generateVoiceFromOddVoiceJson } = useOddVoicesApp();

const [isGeneratingAudio, setIsGeneratingAudio] = React.useState(false);

Expand All @@ -51,7 +52,12 @@ function App() {
>
<AccordionSummary disabled={!rawFile} expandIcon={rawFile ? <ExpandMoreIcon /> : null}>
<Typography variant="body1" textAlign="center" width="100%">
{isGeneratingAudio ? (
{voiceLoadingFailed ? (
<>
<ErrorIcon />
Error loading voice!
</>
) : isGeneratingAudio ? (
<>
<CircularProgress size={16} /> Generating audio...
</>
Expand Down
8 changes: 7 additions & 1 deletion musicxml-singer-with-oddvoices/src/oddvoices/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const useOddVoicesApp = () => {
const {
data: voiceData,
isLoading: isLoadingVoice,
error: voiceError,
} = useQuery({
queryKey: ["oddVoices", activeVoice],
queryFn: async () => {
Expand All @@ -52,7 +53,7 @@ export const useOddVoicesApp = () => {
}
const response = await fetch(`${voiceUrlPrefix}${activeVoice}.voice`);
const buffer = await response.arrayBuffer();

const fileName = `/voices/${activeVoice}.voice`;
oddVoiceApp.FS.writeFile(fileName, new Uint8Array(buffer));

Expand Down Expand Up @@ -88,11 +89,16 @@ export const useOddVoicesApp = () => {
return buffer;
};

if (voiceError) {
console.error(voiceError);
}

return {
isLoadingApp: !oddVoiceApp,
isLoadingVoice,
generateVoiceFromOddVoiceJson,
activeVoice,
setActiveVoice,
voiceLoadingFailed: !isLoadingVoice && !voiceData,
};
};

0 comments on commit 54e14e1

Please sign in to comment.