yum-slop/TaSTT

Free self-hosted STT for VRChat.

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

yumReimplement BrowserSource as a StreamingPluginc2bc70c

v0.19.1
4.1 KiB112 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				$.ajax({
70					url: 'http://localhost:%PORT%/api/v0/transcript',
71					method: 'GET',
72					dataType: 'json',
73					success: function (data) {
74            // dirty hack: create a bunch of invisible content to push the
75            // transcript down the bottom
76            var transcriptHtml = '<span class="transcript" style="opacity: 0">'
77                    + '___ '.repeat(128) + '</span>';
78						data.commits.forEach(function (commit, index) {
79              let age = data.ts - commit.ts;
80              let min_age_s = 5.0;
81              let max_age_s = 60.0;
82              let opacity = 1.0 - (age - min_age_s) / (max_age_s - min_age_s);
83              opacity = Math.max(0, opacity);
84              opacity = Math.min(1, opacity);
85              transcriptHtml += `<span class="transcript" style="opacity: ${opacity};">${commit.delta}</span>`;
86						});
87
88						// Append the preview with full opacity if it exists
89            if (data.preview && data.preview.preview) {
90                transcriptHtml += `<span class="preview" style="opacity: 1;">${data.preview.preview}</span>`;
91            }
92
93            // Create the circle indicator
94            var circleHtml = data.preview.preview ?
95              '<span class="red_circle"></span>' :
96              '<span class="grey_circle"></span>';
97
98            $('#content').html(transcriptHtml + circleHtml);
99            $('#content').css("background-color", "#22222280");
100					},
101					error: function (jqXHR, textStatus, errorThrown) {
102						console.error('Error getting transcript: ', textStatus, errorThrown);
103					}
104				});
105				scrollToBottom();
106			}
107
108			setInterval(getTranscript, /*interval_ms=*/100);
109		</script>
110
111  </body>
112</html>