yum-slop/TaSTT

Free self-hosted STT for VRChat.

git clone https://git.yummers.dev/yum-slop/TaSTT

yumReplace hardcoded localhost with js magic6dc21f8

v0.20.0
4.3 KiB114 linesraw
1<!DOCTYPE html>
2<html>
3  <head>
4    <title>TaSTT</title>
5    <script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
6    <link rel="stylesheet"
7          href="https://fonts.googleapis.com/css?family=Noto+Sans+Mono&display=swap">
8  </head>
9  <style>
10    body {
11      font-family: 'Noto Sans Mono', monospace;
12      font-size: 96px;
13      font-weight: 3200;
14      /* xdd */
15      /* https://stackoverflow.com/a/55097644 */
16      text-shadow: 0.0px 10.0px 0.02px #000, 9.8px 2.1px 0.02px #000, 4.2px
17        -9.1px 0.02px #000, -8.0px -6.0px 0.02px #000, -7.6px 6.5px 0.02px
18      #000, 4.8px 8.8px 0.02px #000, 9.6px -2.8px 0.02px #000, -0.7px -10.0px
19      0.02px #000, -9.9px -1.5px 0.02px #000, -3.5px 9.4px 0.02px #000, 8.4px
20      5.4px 0.02px #000, 7.1px -7.0px 0.02px #000, -5.4px -8.4px 0.02px #000,
21      -9.4px 3.5px 0.02px #000, 1.4px 9.9px 0.02px #000, 10.0px 0.8px 0.02px
22        #000, 2.9px -9.6px 0.02px #000, -8.7px -4.8px 0.02px #000, -6.6px 7.5px
23      0.02px #000, 5.9px 8.0px 0.02px #000, 9.1px -4.1px 0.02px #000, -2.1px
24      -9.8px 0.02px #000, -10.0px -0.1px 0.02px #000, -2.2px 9.8px 0.02px #000,
25      9.1px 4.2px 0.02px #000, 6.1px -8.0px 0.02px #000, -6.5px -7.6px 0.02px
26        #000, -8.8px 4.7px 0.02px #000, 2.7px 9.6px 0.02px #000, 10.0px -0.6px
27      0.02px #000, 1.5px -9.9px 0.02px #000, -9.3px -3.6px 0.02px #000, -5.5px
28      8.4px 0.02px #000, 7.0px 7.2px 0.02px #000, 8.5px -5.3px 0.02px #000,
29      -3.4px -9.4px 0.02px #000, -9.9px 1.3px 0.02px #000, -0.8px 10.0px 0.02px
30        #000, 9.6px 2.9px 0.02px #000, 4.9px -8.7px 0.02px #000, -7.5px -6.7px
31      0.02px #000, -8.1px 5.9px 0.02px #000, 4.0px 9.2px 0.02px #000, 9.8px
32      -2.0px 0.02px #000, 0.2px -10.0px 0.02px #000, -9.7px -2.3px 0.02px #000,
33      -4.3px 9.0px 0.02px #000, 7.9px 6.1px 0.02px #000;
34    }
35    .transcript {
36      color: white;
37    }
38    .preview {
39      color: white;
40      opacity: 0.65;
41    }
42    .red_circle {
43      height: 50px;
44      width: 50px;
45      background-color: red;
46      border-radius: 50%;
47      display: inline-block;
48      vertical-align: middle;
49      margin: 20px;
50    }
51    .grey_circle {
52      height: 50px;
53      width: 50px;
54      background-color: grey;
55      border-radius: 50%;
56      display: inline-block;
57      vertical-align: middle;
58      margin: 20px;
59    }
60  </style>
61  <body>
62    <div id="content"></div>
63    <script>
64      function scrollToBottom() {
65        window.scrollTo(0, document.body.scrollHeight);
66      }
67
68      function getTranscript() {
69        const host = window.location.hostname;
70        const port = window.location.port;
71        $.ajax({
72          url: `http://${host}:${port}/api/v0/transcript`,
73          method: 'GET',
74          dataType: 'json',
75          success: function (data) {
76            // dirty hack: create a bunch of invisible content to push the
77            // transcript down the bottom
78            var transcriptHtml = '<span class="transcript" style="opacity: 0">'
79                    + '___ '.repeat(128) + '</span>';
80            data.commits.forEach(function (commit, index) {
81              let age = data.ts - commit.ts;
82              let min_age_s = 5.0;
83              let max_age_s = 60.0;
84              let opacity = 1.0 - (age - min_age_s) / (max_age_s - min_age_s);
85              opacity = Math.max(0, opacity);
86              opacity = Math.min(1, opacity);
87              transcriptHtml += `<span class="transcript" style="opacity: ${opacity};">${commit.delta.trim() + ' '}</span>`;
88            });
89
90            // Append the preview with full opacity if it exists
91            if (data.preview && data.preview.preview) {
92                transcriptHtml += `<span class="preview" style="opacity: 1;">${data.preview.preview}</span>`;
93            }
94
95            // Create the circle indicator
96            var circleHtml = data.preview.preview ?
97              '<span class="red_circle"></span>' :
98              '<span class="grey_circle"></span>';
99
100            $('#content').html(transcriptHtml + circleHtml);
101            $('#content').css("background-color", "#22222280");
102          },
103          error: function (jqXHR, textStatus, errorThrown) {
104            console.error('Error getting transcript: ', textStatus, errorThrown);
105          }
106        });
107        scrollToBottom();
108      }
109
110      setInterval(getTranscript, /*interval_ms=*/100);
111    </script>
112
113  </body>
114</html>