Skip to content

Commit

Permalink
feat: timestamp-displayの永続化 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
book000 committed Jul 1, 2024
1 parent ff1524a commit cb4490e
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ function start_recognition(recognitionId) {
console.log(event);
for (var i = 0; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
listening.end(`${recognitionId}-${i}`, Math.floor(event.timeStamp / 1000), event.results[i]);
listening.end(
`${recognitionId}-${i}`,
Math.floor(event.timeStamp / 1000),
event.results[i]
);
} else {
listening.runResults(
`${recognitionId}-${i}`,
Expand Down Expand Up @@ -64,12 +68,20 @@ class Listening {
this.messagesManager = new MessagesManager(
document.getElementById("messages")
);

this.timeStamp = [];
this.recognitionStartTimestamp = null;
}

recognitionStartHandler() {
this.recognitionStartTimestamp = new Date().getTime() / 1000;

const timestampDisplayElement =
document.getElementById("timestamp-display");
this.listeningMessagesManager.setDisplayTimestamp(
timestampDisplayElement.checked
);
this.messagesManager.setDisplayTimestamp(timestampDisplayElement.checked);
}

runResults(resultId, timeStamp, results) {
Expand Down Expand Up @@ -395,6 +407,13 @@ function onload() {
if (apiurl != null) {
document.getElementById("api_url").value = apiurl;
}
const timestampDisplay = localStorage.getItem(
"audio-transcriber-web-timestamp-display"
);
if (timestampDisplay != null) {
document.getElementById("timestamp-display").checked =
timestampDisplay.toLowerCase() === "true";
}
const autoStart = localStorage.getItem("audio-transcriber-web-auto-start");
if (autoStart != null) {
document.getElementById("auto-start").checked =
Expand Down Expand Up @@ -423,6 +442,13 @@ document.getElementById("auto-start").onchange = function () {
);
};

document.getElementById("timestamp-display").onchange = function () {
localStorage.setItem(
"audio-transcriber-web-timestamp-display",
document.getElementById("timestamp-display").checked.toString()
);
};

document.getElementById("startstop").onclick = function () {
if (!started) {
started = true;
Expand Down

0 comments on commit cb4490e

Please sign in to comment.