diff --git a/site/README.md b/site/README.md index 376983c..535a246 100644 --- a/site/README.md +++ b/site/README.md @@ -157,6 +157,7 @@ The Explain panel on a problem page (admin only) asks Claude for an intuitive ex The "Review my explanation" panel (admin only) takes a recording of the admin explaining a solution out loud, as to an interviewer, and commits feedback on it as `reviews/.md`. The id is the UTC time it started (`2026-10-20-153000`), so each attempt is its own file and the page lists them newest first. +- **Recording in the browser.** Besides a file picker, the panel records from the microphone (`AudioRecorder.vue`, `MediaRecorder` at 32 kbps): webm/Opus in Chrome and Firefox, m4a in Safari, named with that extension because the server picks the format by it. A take stops itself just short of 25 MB (over an hour), and either kind of recording gets a player to check before sending. The microphone needs a secure context, so it works on the deployed HTTPS site and on `localhost`, not over plain HTTP on a LAN address. - **Transcription.** Claude cannot take audio, so the recording goes first to an OpenAI-compatible `/v1/audio/transcriptions` endpoint: `TRANSCRIBE_URL` (default the OpenAI API) with `TRANSCRIBE_MODEL` (default `whisper-1`, about $0.006 a minute). It asks for word and segment timestamps, and for a verbatim transcript, because Whisper otherwise drops the fillers. A self-hosted faster-whisper server works by changing the URL. - **Metrics.** Pace (words per minute), pauses of 2 seconds or more, filler-word counts and when complexity was first mentioned are measured from the timestamps (`transcribe.Metrics`), since Claude never hears the recording. It is told so, and judges delivery from the words and these numbers only, not tone. - **Review.** The statement, examples, optionally the main solution file, the admin's note, the metrics and the timestamped transcript go to Claude with a JSON schema (`internal/review` `Schema`): a verdict (correct, partly correct, incorrect, incomplete), a restatement, an assessment of the approach and complexities, missed edge cases, delivery feedback quoting `[mm:ss]`, 1 to 5 scores in five areas, strengths and things to work on. The markdown ends with the metrics and the full transcript. Its first line is a `` comment the index reads. diff --git a/site/web/src/components/AudioRecorder.vue b/site/web/src/components/AudioRecorder.vue new file mode 100644 index 0000000..2a85913 --- /dev/null +++ b/site/web/src/components/AudioRecorder.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/site/web/src/views/ProblemPage.vue b/site/web/src/views/ProblemPage.vue index 6c715f7..e4e6d5b 100644 --- a/site/web/src/views/ProblemPage.vue +++ b/site/web/src/views/ProblemPage.vue @@ -10,6 +10,7 @@ */ import { computed, onUnmounted, ref, watch } from "vue"; import { RouterLink } from "vue-router"; +import AudioRecorder from "@/components/AudioRecorder.vue"; import CodeBlock from "@/components/CodeBlock.vue"; import Explanation from "@/components/Explanation.vue"; import ReviewList from "@/components/ReviewList.vue"; @@ -76,7 +77,8 @@ const tools = [ ]; function toggle(id) { - // The file input goes with the panel, so the picked file must too. + // The file input and recorder go with the panel, so the chosen recording + // must too. if (panel.value === "review") recording.value = null; if (panel.value === id) { panel.value = ""; @@ -205,15 +207,39 @@ watch(() => props.name, stopReviewPolling); // 25 MB is the transcriber's limit; checking here saves uploading it first. const MAX_RECORDING = 25 << 20; -function pickRecording(e) { - recording.value = e.target.files[0] || null; - if (recording.value && recording.value.size > MAX_RECORDING) { +function useRecording(f) { + recording.value = f; + if (f && f.size > MAX_RECORDING) { reviewJob.value = { state: "error", error: "That recording is over 25 MB; export it at a lower bitrate." }; } else if (reviewJob.value.state === "error") { reviewJob.value = { state: "idle" }; } } +function pickRecording(e) { + useRecording(e.target.files[0] || null); +} + +// A take recorded here replaces a picked file, so the file input must not +// go on naming one. +const fileInput = ref(null); +function tookRecording(f) { + if (fileInput.value) fileInput.value.value = ""; + useRecording(f); +} + +function recorderError(message) { + reviewJob.value = { state: "error", error: message }; +} + +// Whichever recording is chosen gets a player, to check it before sending. +const recordingUrl = ref(""); +watch(recording, (f) => { + URL.revokeObjectURL(recordingUrl.value); + recordingUrl.value = f ? URL.createObjectURL(f) : ""; +}); +onUnmounted(() => URL.revokeObjectURL(recordingUrl.value)); + async function checkReview() { stopReviewPolling(); const name = props.name; @@ -355,11 +381,21 @@ const moves = computed(() => {

Review my explanation

- Record yourself explaining your solution as you would to an interviewer, then upload it (mp3, m4a, wav, - webm, ogg or flac, up to 25 MB). It is transcribed, and Claude gives feedback on the approach and on your - delivery. Each review is committed under reviews/. + Record yourself explaining your solution as you would to an interviewer, here or elsewhere and upload it + (mp3, m4a, wav, webm, ogg or flac, up to 25 MB). It is transcribed, and Claude gives feedback on the approach + and on your delivery. Each review is committed under reviews/.

- +
+ + or + +
+
@@ -598,6 +634,16 @@ h2 { color: var(--color-ink); background: var(--color-paper); } +.source { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 10px; +} +.panel audio { + width: 100%; + max-width: 480px; +} .panel input[type="file"] { font-size: 0.9rem; max-width: 100%;