Record review audio in the browser
The review panel can now record from the microphone as well as take a file. The take is made with MediaRecorder at 32 kbps, which is plenty for speech and puts the 25 MB limit at over an hour; it stops itself just short of that. It is named .webm (Chrome, Firefox) or .m4a (Safari) to match its container, since the server picks the format by extension, so the backend is unchanged. Whichever recording is chosen, recorded or picked, gets a player to check it before sending. Closing the panel mid-take discards it and releases the microphone. Recording needs HTTPS or localhost; elsewhere the button is disabled with a note saying why. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -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(() => {
|
||||
<div v-if="panel === 'review'" class="panel">
|
||||
<h2>Review my explanation</h2>
|
||||
<p class="muted">
|
||||
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 <code>reviews/</code>.
|
||||
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 <code>reviews/</code>.
|
||||
</p>
|
||||
<input type="file" accept="audio/*,.mp3,.m4a,.wav,.webm,.ogg,.flac" @change="pickRecording" />
|
||||
<div class="source">
|
||||
<AudioRecorder
|
||||
:max-bytes="MAX_RECORDING"
|
||||
@start="useRecording(null)"
|
||||
@recorded="tookRecording"
|
||||
@error="recorderError"
|
||||
/>
|
||||
<span class="muted">or</span>
|
||||
<input ref="fileInput" type="file" accept="audio/*,.mp3,.m4a,.wav,.webm,.ogg,.flac" @change="pickRecording" />
|
||||
</div>
|
||||
<audio v-if="recordingUrl" :src="recordingUrl" controls preload="metadata"></audio>
|
||||
<textarea v-model="reviewNote" rows="2" placeholder="Optional context: a mock interview, a time limit, what to focus on"></textarea>
|
||||
<div class="admin-row">
|
||||
<label class="check"><input v-model="reviewCode" type="checkbox" /> Include my code</label>
|
||||
@@ -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%;
|
||||
|
||||
Reference in New Issue
Block a user