Merge pull request #155 from davidgumberg/keepawakescrolldown
frontend: Keep screen awake and scroll down when transcribing.
This commit is contained in:
commit
b0a5fc0693
1 changed files with 16 additions and 0 deletions
|
|
@ -385,6 +385,7 @@
|
||||||
let chunkDuration = 1000;
|
let chunkDuration = 1000;
|
||||||
let websocketUrl = "ws://localhost:8000/asr";
|
let websocketUrl = "ws://localhost:8000/asr";
|
||||||
let userClosing = false;
|
let userClosing = false;
|
||||||
|
let wakeLock = null;
|
||||||
let startTime = null;
|
let startTime = null;
|
||||||
let timerInterval = null;
|
let timerInterval = null;
|
||||||
let audioContext = null;
|
let audioContext = null;
|
||||||
|
|
@ -665,6 +666,7 @@
|
||||||
}).join("");
|
}).join("");
|
||||||
|
|
||||||
linesTranscriptDiv.innerHTML = linesHtml;
|
linesTranscriptDiv.innerHTML = linesHtml;
|
||||||
|
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTimer() {
|
function updateTimer() {
|
||||||
|
|
@ -712,6 +714,16 @@
|
||||||
|
|
||||||
async function startRecording() {
|
async function startRecording() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API
|
||||||
|
// create an async function to request a wake lock
|
||||||
|
try {
|
||||||
|
wakeLock = await navigator.wakeLock.request("screen");
|
||||||
|
} catch (err) {
|
||||||
|
// The Wake Lock request has failed - usually system related, such as battery.
|
||||||
|
console.log("Error acquiring wake lock.")
|
||||||
|
}
|
||||||
|
|
||||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||||
|
|
||||||
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
|
|
@ -741,6 +753,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function stopRecording() {
|
async function stopRecording() {
|
||||||
|
wakeLock.release().then(() => {
|
||||||
|
wakeLock = null;
|
||||||
|
});
|
||||||
|
|
||||||
userClosing = true;
|
userClosing = true;
|
||||||
waitingForStop = true;
|
waitingForStop = true;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue