Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-inbox-recording-autotranscribe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Inbox recordings are transcribed automatically when you stop, with the hive's transcription provider (auto: the built-in whisper first), with the usual progress bar and time-left estimate. The transcriber reads the recording from the hive's own disk (new `AudioOpener`; no HTTP call to itself). Nothing runs until `inbox.transcription` is enabled with consent; from then on every dashboard recording counts as opted in whatever the mode, and recordings made while it was off are picked up by the transcription sweep.
9 changes: 9 additions & 0 deletions src/cmd/hive/boot_inbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,20 @@ func (b *boot) startInboxRecordingSweep(svc *inbox.Service) {
if b.dashSrv != nil {
b.dashSrv.AuditLog(a.Actor, a.Action, a.Detail(), "")
}
}, TranscribeAudit: func(a inbox.TranscribeAudit) {
if b.dashSrv != nil {
b.dashSrv.AuditLog(a.Actor, "inbox_transcribe", a.Detail(), "")
}
}}
sweep := func() {
if _, err := svc.RecordingSweep(opts); err != nil {
b.logger.Warn("inbox recording sweep", "error", err)
}
// Recordings finished while transcription was off are transcribed
// once it is enabled with consent.
tctx, cancel := context.WithTimeout(ctx, inboxSweepTimeout)
b.inboxTranscribeSweep(tctx, svc)
cancel()
}
go func() {
sweep()
Expand Down
21 changes: 21 additions & 0 deletions src/docs/inbox-recording.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ you. Good practice:
notice;
- do not record people who have not been told.

## Transcription

When you stop, the hive transcribes the recording automatically with its
[transcription provider](inbox-transcription.md) (`provider: auto` picks the
built-in whisper first, so the audio stays on the hive), with the same
progress bar and time-left estimate as any other Inbox transcription. The
transcriber reads the file from the hive's own disk; nothing is fetched over
HTTP. The transcript is written into the recording's Knowledge fact.

- Recording does **not** replace the hive-wide transcription consent: nothing
is transcribed until an owner enables `inbox.transcription` with
`consent_acknowledged: true`. Once that is done, every dashboard recording
counts as opted in, whatever `inbox.transcription.mode` says.
- While transcription is off you can still record; the consent notice says
the recording will not be transcribed yet, and the item shows why. The
transcription sweep (every 10 minutes and after connector syncs) picks up
such recordings once transcription is enabled, as long as their audio has
not expired.
- Transcription limits (`max_bytes`, `max_duration_minutes`, daily and
monthly budgets) apply as for every other source.

## Retention

| What | Kept |
Expand Down
4 changes: 4 additions & 0 deletions src/pkg/dashboard/api_inbox_recordings.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func (s *Server) inboxRecordingOptions(r *http.Request) inbox.RecordingOptions {
if s.audit != nil {
s.audit.Log(a.Actor, a.Action, auditDetail(a.Fields...), "")
}
}, TranscribeAudit: func(a inbox.TranscribeAudit) {
if s.audit != nil {
s.audit.Log(a.Actor, "inbox_transcribe", auditDetail(a.Fields()...), "")
}
}}
}

Expand Down
2 changes: 1 addition & 1 deletion src/pkg/dashboard/inbox_recorder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ test('consent text: responsibility, retention, transcription off hint, tab parti
const tab = lib.inboxRecConsentText({ tab: true, retentionDays: 1, transcribes: true }).join(' ');
assert.match(tab, /remote participants of that meeting too: they must have been told/);
assert.match(tab, /1 day and/);
assert.match(tab, /can be transcribed on this hive/);
assert.match(tab, /transcribes the recording automatically/);
});

test('upload queue resumes after a network failure and keeps order', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/dashboard/static-src/js/inbox-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
];
if (o.tab) parts.push('Including tab audio captures the remote participants of that meeting too: they must have been told that you are recording.');
parts.push('The raw audio is kept on this hive for ' + days + ' day' + (days === 1 ? '' : 's') + ' and then deleted; its transcript and Knowledge fact are kept.');
parts.push(o.transcribes ? 'When you stop, it can be transcribed on this hive with 🎧 Transcribe.' : 'Transcription is off on this hive, so this recording is not transcribed until an owner enables it in Inbox ⚙ → Transcription.');
parts.push(o.transcribes ? 'When you stop, this hive transcribes the recording automatically.' : 'Transcription is off on this hive, so this recording is not transcribed until an owner enables it in Inbox ⚙ → Transcription.');
return parts;
}
const INBOX_REC_CONSENT_ACK = 'I have told everyone who will be recorded, and I am responsible for this recording.';
Expand Down Expand Up @@ -531,7 +531,7 @@
if (m.uploader) html += '<div class="muted-xs inbox-rec-upload" data-inbox-rec-upload aria-live="polite">' + escapeHtml(inboxRecUploadText(m.uploader.state)) + '</div>';
if (m.warning) html += '<div class="kc-error muted-xs" role="alert">' + escapeHtml(m.warning) + '</div>';
if (m.error) html += '<div class="kc-error muted-xs" role="alert">' + escapeHtml(m.error) + '</div>';
if (m.state === 'done') html += '<div class="muted-xs">' + escapeHtml(m.transcribes ? 'It appears in the Inbox below; use 🎧 Transcribe on it.' : 'It appears in the Inbox below. Transcription is off on this hive, so it is not transcribed yet.') + '</div>';
if (m.state === 'done') html += '<div class="muted-xs">' + escapeHtml(m.transcribes ? 'The hive is transcribing it now; follow the progress on the item in the Inbox below.' : 'It appears in the Inbox below. Transcription is off on this hive, so it is not transcribed yet.') + '</div>';
html += '<div class="kc-actions mt-2">';
if (m.state === 'recording') html += '<button type="button" class="hv-btn btn-secondary btn-sm" data-action="inboxRecPause">⏸ Pause</button>';
if (m.state === 'paused') html += '<button type="button" class="hv-btn btn-secondary btn-sm" data-action="inboxRecResume">⏺ Resume</button>';
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49276,7 +49276,7 @@ <h3 class="modal-h">How Agents Use Knowledge (Priming)</h3>
];
if (o.tab) parts.push('Including tab audio captures the remote participants of that meeting too: they must have been told that you are recording.');
parts.push('The raw audio is kept on this hive for ' + days + ' day' + (days === 1 ? '' : 's') + ' and then deleted; its transcript and Knowledge fact are kept.');
parts.push(o.transcribes ? 'When you stop, it can be transcribed on this hive with 🎧 Transcribe.' : 'Transcription is off on this hive, so this recording is not transcribed until an owner enables it in Inbox ⚙ → Transcription.');
parts.push(o.transcribes ? 'When you stop, this hive transcribes the recording automatically.' : 'Transcription is off on this hive, so this recording is not transcribed until an owner enables it in Inbox ⚙ → Transcription.');
return parts;
}
const INBOX_REC_CONSENT_ACK = 'I have told everyone who will be recorded, and I am responsible for this recording.';
Expand Down Expand Up @@ -49698,7 +49698,7 @@ <h3 class="modal-h">How Agents Use Knowledge (Priming)</h3>
if (m.uploader) html += '<div class="muted-xs inbox-rec-upload" data-inbox-rec-upload aria-live="polite">' + escapeHtml(inboxRecUploadText(m.uploader.state)) + '</div>';
if (m.warning) html += '<div class="kc-error muted-xs" role="alert">' + escapeHtml(m.warning) + '</div>';
if (m.error) html += '<div class="kc-error muted-xs" role="alert">' + escapeHtml(m.error) + '</div>';
if (m.state === 'done') html += '<div class="muted-xs">' + escapeHtml(m.transcribes ? 'It appears in the Inbox below; use 🎧 Transcribe on it.' : 'It appears in the Inbox below. Transcription is off on this hive, so it is not transcribed yet.') + '</div>';
if (m.state === 'done') html += '<div class="muted-xs">' + escapeHtml(m.transcribes ? 'The hive is transcribing it now; follow the progress on the item in the Inbox below.' : 'It appears in the Inbox below. Transcription is off on this hive, so it is not transcribed yet.') + '</div>';
html += '<div class="kc-actions mt-2">';
if (m.state === 'recording') html += '<button type="button" class="hv-btn btn-secondary btn-sm" data-action="inboxRecPause">⏸ Pause</button>';
if (m.state === 'paused') html += '<button type="button" class="hv-btn btn-secondary btn-sm" data-action="inboxRecResume">⏺ Resume</button>';
Expand Down
81 changes: 81 additions & 0 deletions src/pkg/inbox/audioopener.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package inbox

import (
"context"
"io"
"os"
"time"

"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/transcribe"
)

// LocalAudio is an audio (or video) file on this hive's own disk.
type LocalAudio struct {
File *os.File
// Name is the file name http.ServeContent uses for type fallbacks.
Name string
// MIME is the media type it is served and transcribed as.
MIME string
Size int64
ModTime time.Time
}

// AudioOpener is optionally implemented by any source whose audio lives on
// this hive (dashboard recordings, uploaded audio and video files, ...).
// Playback serves the file directly with Range support, and transcription
// reads it from disk: nothing makes an HTTP call to the hive itself. A
// source that implements AudioOpener should also implement AudioSource so
// the item counts as having audio. OpenAudio returns ErrNoAudio (or an
// error wrapping it) when the item has no audio file.
type AudioOpener interface {
OpenAudio(ctx context.Context, it Item) (LocalAudio, error)
}

// localTranscribeAudio opens a hive-local file for a transcription run. The
// first open happens here so the provider gets the file's MIME type and
// size; retries reopen it. The source checked the container when the file
// arrived; decoding is the provider's job (the sandboxed whisper subprocess
// by default). The returned cleanup closes the first handle if the provider
// never read it.
func (s *Service) localTranscribeAudio(ctx context.Context, it Item, op AudioOpener, cfg config.InboxTranscription, rec *TranscriptRecord, job *txJob) (transcribe.Audio, func(), error) {
s.txProgress(job, transcribe.Progress{Phase: transcribe.PhaseDownloading, ProcessedSeconds: -1})
first, err := op.OpenAudio(ctx, it)
if err != nil {
return transcribe.Audio{}, nil, err
}
maxBytes := cfg.EffectiveMaxBytes()
rec.AudioSize = first.Size
pending := &first
cleanup := func() {
if pending != nil {
_ = pending.File.Close()
pending = nil
}
}
if maxBytes > 0 && first.Size > maxBytes {
cleanup()
return transcribe.Audio{}, nil, transcribe.ErrTooLarge
}
a := transcribe.Audio{
MIME: first.MIME,
Size: first.Size,
Duration: time.Duration(it.DurationMS) * time.Millisecond,
Lang: cfg.EffectiveLanguage(),
Progress: func(p transcribe.Progress) { s.txProgress(job, p) },
}
a.Open = func(ctx context.Context) (io.ReadCloser, error) {
la := pending
pending = nil
if la == nil {
s.txProgress(job, transcribe.Progress{Phase: transcribe.PhaseDownloading, ProcessedSeconds: -1})
reopened, err := op.OpenAudio(ctx, it)
if err != nil {
return nil, err
}
la = &reopened
}
return readCloser{Reader: transcribe.LimitReader(la.File, maxBytes), Closer: la.File}, nil
}
return a, cleanup, nil
}
Loading
Loading