Skip to content

Commit

Permalink
feat: Improve lazy loading of transcript file
Browse files Browse the repository at this point in the history
  • Loading branch information
KiwiGaze committed Sep 25, 2024
1 parent a6ac4f1 commit 11c2dc3
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,15 @@
const nodeJSON = document.getElementById('json');
nodeJSON.value = "Please wait...";

const reader = new FileReader();
reader.onload = async (event) => {
// Debugging
const jsonString = event.target.result;
console.log("Type of event result:", typeof jsonString);
const response = await fetch('./transcript/transcript.json')
if (response.ok) {
const json = await response.json();
nodeJSON.value = JSON.stringify(json, null, 4);


// Parse JSON
const json = JSON.parse(jsonString);
console.log("Type of JSON:", typeof json);

nodeJSON.value = JSON.stringify(json, null, 4);

// Debugging
console.log("Words from JSON:", json.words);

Expand Down Expand Up @@ -264,20 +260,6 @@
mtimes: audio.mtimes.slice(startIndex).map(time => time - audio.wtimes[startIndex])
};
}
// Fetch transcript from the local path
async function loadTranscriptFile() {
try {
const response = await fetch('./transcript/transcript.json');
if (!response.ok) {
throw new Error(`Failed to load transcript: ${response.statusText}`);
}
return response;
} catch (error) {
console.error('Error loading transcript:', error);
return null;
}
}

});
</script>
</head>
Expand Down

0 comments on commit 11c2dc3

Please sign in to comment.