Skip to content

Commit

Permalink
cleanup and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
maboa committed May 7, 2024
1 parent bad441e commit 49a0b44
Showing 1 changed file with 20 additions and 43 deletions.
63 changes: 20 additions & 43 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,6 @@ <h3 class="font-bold text-lg" style="margin-bottom:16px">Transcribe</h3>
}
}
});



let showSpeakers = document.querySelector('#show-speakers');

Expand Down Expand Up @@ -838,7 +836,6 @@ <h3 class="font-bold text-lg" style="margin-bottom:16px">Transcribe</h3>

hyperaudio();


function hyperaudioGenerateCaptionsFromTranscript() {
let rootnode = document.querySelector("#hypertranscript");
let sourceMedia = document.querySelector("#hyperplayer").src;
Expand Down Expand Up @@ -1343,8 +1340,6 @@ <h3 class="font-bold text-lg">Load from Local Storage</h3>

window.document.addEventListener('hyperaudioTranscriptLoaded', registerStrikeThrus, false);



function registerStrikeThrus() {
audioDataArray = [];

Expand All @@ -1365,11 +1360,9 @@ <h3 class="font-bold text-lg">Load from Local Storage</h3>
newSection.start = 0;

words.forEach((word, index) => {
//console.log(word);
let isStrikethrough = word.style.textDecoration === "line-through";

if (isStrikethrough) {
console.log("struck");
if (isPreviousWordStruckThru === false){
newSection.end = word.getAttribute("data-m")/1000;
newSections.push(newSection);
Expand Down Expand Up @@ -1408,14 +1401,13 @@ <h3 class="font-bold text-lg">Load from Local Storage</h3>
let animationFrameId;

function update() {
// Call the `checkStrikeThrus` function with `audioDataArray` and `myPlayer`
checkStrikeThrus(audioDataArray, myPlayer);

// Continue the loop
animationFrameId = requestAnimationFrame(update);
}

// Optional: Stop the animation frame loop when the player is not playing
// Stop the animation frame loop when the player is not playing
myPlayer.addEventListener("pause", () => {
if (animationFrameId) {
cancelAnimationFrame(animationFrameId);
Expand All @@ -1432,20 +1424,9 @@ <h3 class="font-bold text-lg">Load from Local Storage</h3>
}

function checkStrikeThrus(audioDataArray, myPlayer){
//let myPlayer = window.hyperaudioInstance.player;
console.log(myPlayer.currentTime);
audioDataArray.forEach((element, index) => {
console.log("index = "+index);
console.log("audioDataArray.length = "+audioDataArray.length);
console.log("start = "+element.stop);
//console.log("stop = "+audioDataArray[index+1].start);
if ((index+1) < audioDataArray.length && parseFloat(element.stop) < parseFloat(myPlayer.currentTime) && parseFloat(myPlayer.currentTime) < parseFloat(audioDataArray[index+1].start)) {
console.log("-------------------------------------------");
console.log("START = "+element.stop);
console.log("NOW = "+myPlayer.currentTime);
console.log("STOP = "+audioDataArray[index+1].start);
console.log("-------------------------------------------");
myPlayer.currentTime = audioDataArray[index+1].start;
myPlayer.currentTime = audioDataArray[index+1].start + 0.05;
}
});
}
Expand All @@ -1456,30 +1437,26 @@ <h3 class="font-bold text-lg">Load from Local Storage</h3>
// grab the filename if saved
const element = document.querySelector(".file-item.active");

/*if (element === null){
alert("File must be referenced locally or CORS enabled on the server.");
} else {*/
let fileName;
if (typeof element === "undefined"){
fileName = "default";
} else {
fileName = element.textContent;
}
let fileName;
if (typeof element === "undefined"){
fileName = "default";
} else {
fileName = element.textContent;
}

if (typeof audioDataArray === "undefined") {
audioDataArray = [];
audioDataArray.push(
new AudioData(
document.querySelector("#hyperplayer").src,
0,
document.getElementById("hyperplayer").duration
)
);
}
if (typeof audioDataArray === "undefined") {
audioDataArray = [];
audioDataArray.push(
new AudioData(
document.querySelector("#hyperplayer").src,
0,
document.getElementById("hyperplayer").duration
)
);
}

let wavBlob = await cutAudioApp.cutAudio(audioDataArray);
cutAudioApp.to_wav(wavBlob, fileName);
//}
let wavBlob = await cutAudioApp.cutAudio(audioDataArray);
cutAudioApp.to_wav(wavBlob, fileName);

});
</script>
Expand Down

0 comments on commit 49a0b44

Please sign in to comment.