Review recorded explanations of a solution on the site
The admin can upload a recording of themselves explaining a problem's solution out loud (mp3, m4a, wav, webm, ogg or flac, up to 25 MB) and get interview-style feedback, committed as reviews/<id>.md so every attempt is kept. Claude can't take audio, so the recording is transcribed first by an OpenAI-compatible endpoint (whisper-1 by default; TRANSCRIBE_API_KEY, with TRANSCRIBE_URL for a self-hosted server). Pace, pauses, filler words and when complexity first comes up are measured from the word timestamps and given to Claude with the timestamped transcript, the statement and optionally the code. The reply covers the verdict, scores in five areas, the approach and its complexity, missed edge cases, delivery and what to work on. Recordings are kept for playback in an S3 bucket (Garage) when the S3_* settings are given, and are thrown away otherwise. Reviews are admin-only. The job runs in the background like Explain, and the statement fetch and save-error handling are now shared between the two. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// Command usacosite serves the USACO practice log at /usaco/: the problems
|
||||
// from adamf/usaco on the site's Gitea, their solutions and tests, and a few
|
||||
// admin edits (problem link, notes, statement, status) and Claude-written
|
||||
// explanations that it commits back to git.
|
||||
// admin edits (problem link, notes, statement, status), Claude-written
|
||||
// explanations and reviews of recorded explanations that it commits back to
|
||||
// git.
|
||||
//
|
||||
// It is built to sit behind adam-french.co.uk's nginx and borrow its login
|
||||
// (internal/auth), like the job tracker. There is no database: the server
|
||||
@@ -21,10 +22,12 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"adam-french.co.uk/usaco-site/internal/audiostore"
|
||||
"adam-french.co.uk/usaco-site/internal/auth"
|
||||
"adam-french.co.uk/usaco-site/internal/claude"
|
||||
"adam-french.co.uk/usaco-site/internal/handlers"
|
||||
"adam-french.co.uk/usaco-site/internal/repo"
|
||||
"adam-french.co.uk/usaco-site/internal/transcribe"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -78,6 +81,38 @@ func main() {
|
||||
log.Printf("[claude] %v: explanations are off", err)
|
||||
}
|
||||
|
||||
// REVIEWS
|
||||
// A recording needs a transcriber as well as Claude. OPENAI_API_KEY is
|
||||
// accepted too, as the key most people already have under that name.
|
||||
tkey := os.Getenv("TRANSCRIBE_API_KEY")
|
||||
if tkey == "" {
|
||||
tkey = os.Getenv("OPENAI_API_KEY")
|
||||
}
|
||||
if t, err := transcribe.New(os.Getenv("TRANSCRIBE_URL"), tkey, os.Getenv("TRANSCRIBE_MODEL")); err == nil {
|
||||
srv.Transcriber = t
|
||||
log.Printf("[review] recordings are transcribed with %s", t.Model())
|
||||
} else {
|
||||
log.Printf("[review] %v: recording reviews are off", err)
|
||||
}
|
||||
// Optional on top: without it, recordings are thrown away once
|
||||
// transcribed. A half-filled config is a mistake worth stopping for.
|
||||
store, err := audiostore.New(audiostore.Config{
|
||||
Endpoint: os.Getenv("S3_ENDPOINT"),
|
||||
Region: os.Getenv("S3_REGION"),
|
||||
Bucket: os.Getenv("S3_BUCKET"),
|
||||
AccessKeyID: os.Getenv("S3_ACCESS_KEY_ID"),
|
||||
SecretAccessKey: os.Getenv("S3_SECRET_ACCESS_KEY"),
|
||||
})
|
||||
switch {
|
||||
case err != nil:
|
||||
log.Fatal(err)
|
||||
case store != nil:
|
||||
srv.Audio = store
|
||||
log.Printf("[review] recordings are kept in the %s bucket", store.Bucket())
|
||||
default:
|
||||
log.Println("[review] S3_ENDPOINT is not set: recordings are not kept")
|
||||
}
|
||||
|
||||
rp, err := repo.New(repo.Config{
|
||||
Dir: filepath.Join(dataDir, "repo"),
|
||||
Remote: remote,
|
||||
|
||||
Reference in New Issue
Block a user