Repository navigation
feat(attachments): Transcribe audio and video attachments with transcribeAudio - #3489
Conversation
…ribeAudio Co-Authored-By: Thomas Jiang <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
27 screenshot changes — 27 changed · 0 added · 0 removed Review screenshots in Frameshift Show 12 more changed screenshots9 more changed screenshots in Frameshift. |
… the sandbox Co-Authored-By: Thomas Jiang <[email protected]>
Co-Authored-By: Thomas Jiang <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ebbb589. Configure here.
| return { | ||
| ...result, | ||
| transcript: inline.text, | ||
| ...(inline.truncated ? { truncated: true } : undefined), |
There was a problem hiding this comment.
Truncation drops transcript after failed save
Medium Severity
leadingLines still cuts the inline transcript after a sandbox write failure. When saved is false there is no transcript_path, so the unpaid tail of a long, already-billed transcript is discarded. The model only sees the first fitting lines, truncated: true, and the unsaved note.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit ebbb589. Configure here.
There was a problem hiding this comment.
Declining this. The cut after a failed save is the behavior the requester approved. If the tool returned the full transcript inline, the generic result cut would split it anyway. That cut saves its spill file through the same sandbox, so after a sandbox failure the spill likely fails too. The model would then get a head and a tail with a gap in the middle, instead of clean leading lines. With truncated: true and the note, the model knows the rest is missing and can call the tool again when the sandbox works.
| const secs = String(Math.floor(tenths / 10) % 60).padStart(2, "0"); | ||
| const time = `${minutes}:${secs}.${tenths % 10}`; | ||
| return hours > 0 ? `${hours}:${time}` : time; | ||
| } |
There was a problem hiding this comment.
Timestamps lose a tenth to float math
Low Severity
timestamp uses Math.floor(seconds * 10) to get tenths. For values such as 0.3 and 0.6, seconds * 10 is slightly under the integer, so the displayed time is one tenth too early. Timed transcript lines then disagree with the provider’s start times.
Reviewed by Cursor Bugbot for commit ebbb589. Configure here.
There was a problem hiding this comment.
Declining this, because the example does not reproduce. In JavaScript, 0.3 * 10 === 3 and 0.6 * 10 === 6. I checked every millisecond value from 0 to 10,000 s (i / 1000): Math.floor(s * 10) always equals Math.floor(i / 100), with 0 mismatches. ElevenLabs returns times with millisecond precision, so timestamp() shows the correct tenth for every start time it can get.
Large Slack files (non-image, over 25 MiB) are recorded with `storage_key = NULL` and were never stored (#3339). Now the first call that needs the bytes streams the file from Slack into attachment storage once and fills in `storage_key`, `sha256` and `bytes`. Later reads use storage. So `transcribeAudio` (#3489) can sign a storage URL with `createDownloadUrl` (#3488) for every file. **Behavior** - `storeDeferredAttachment` (`store.ts`) streams the source through the existing `writeAttachmentObject` path (fresh write key, retries, size check, sha256). Then it updates the row only where `storage_key IS NULL`, the row is not delete-requested, and the conversation is not purged. When the update misses, it deletes our object and returns the winner's row, or null when the row is no longer live. - `storeAttachmentOnFirstUse` (`download.ts`) does the Slack lookup and the size check, maps errors to `AttachmentDownloadError`, and wraps the store in an `attachment.store` span. - `loadAttachment` and `transcribeAudio` call it first. `transcribeAudio` no longer refuses unstored files. - `writeAttachmentObject` no longer retries `AttachmentSourceUnavailableError`. A file that Slack deleted is not transient. - The dashboard byte route does **not** store. It keeps streaming files from Slack until a tool stores them. **Notes** - No migration: `0107_attachment_deferred_download.sql` already made `storage_key` and `sha256` nullable. - `model-input.ts` is unchanged except for a comment. Only web uploads reach it, and they are always stored. It reads bytes only for images up to 5 MB, and deferred rows are non-images over 25 MiB. **Open risk** - Nobody has checked yet that ElevenLabs can fetch a Vercel Blob signed URL in production. <!-- junior-request-attribution:start --> via @thomasjiangcy. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A71078a65e4a20ded28d6e80cfc50ba2d --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A71078a65e4a20ded28d6e80cfc50ba2d) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A71078a65e4a20ded28d6e80cfc50ba2d/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Thomas Jiang <[email protected]>


Junior cannot read speech in voice clips, meeting recordings, or screen recordings that people attach. This PR adds the deferred
transcribeAudiotool, so Junior can transcribe an audio or video attachment of the current Conversation. It uses the signed download URLs from #3488. Junior builds the tool only when the attachment storage can sign download URLs (S3 and Vercel Blob).The tool signs a new 5-minute URL for each call. It sends the URL to ElevenLabs Scribe v2 through AI Gateway as
sourceUrl, with empty audio. ElevenLabs downloads the file, so the file never goes through Junior. The AI SDKtranscribe()call with an emptyUint8Arrayworks: I tested it against the live Gateway with an mp3 file and with an mp4 file that has no audio track.The result is
{ transcript, transcript_path?, note?, language?, duration_seconds?, truncated? }. The transcript has one line for each entry, with the start time first:A speech line ends when the speaker changes or a sentence ends. Each sound is on its own line. The tool writes the full transcript to
.junior/attachments/<id>.transcript.txtin the sandbox. When the transcript does not fit in a tool result, the tool returns the first lines that fit andtruncated: true. The model then reads the file withreadFileor searches it withgrep. The generic cut of a tool result would save one long JSON line, whichreadFilecannot page. When the sandbox write fails, the tool still returns the inline transcript, withouttranscript_path, and withnote: "The full transcript was not saved.". It logstool.transcript.write.failed.The tool gives a tool error for an attachment that is not found, for a large Slack file that Junior did not store, for a file that is not audio or video, and for a file with no audio (
invalid_audio).The signed URL is a bearer credential. It is not in the tool result, the
gen_ai.transcriptionspan, or the logs. A failed call drops the SDK error, because that error keeps the request body. The cost goes to the Conversation as thetranscriptionoperation. Set the model withAI_TRANSCRIPTION_MODELortranscriptionModelId.Limits:
localhostis not reachable from ElevenLabs, so local dev cannot transcribe.watch-videoskill update follows after release.via @thomasjiangcy.
--
View Session [Sentry]