diff --git a/CHANGELOG.md b/CHANGELOG.md
index adc62f3..26ae576 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,7 +20,7 @@ version may change things that need attention when updating, and these notes say
FLAC. Visitors hear a copy in the item page's own player, which can jump about. Names, places, dates, cover pictures
and everything else the file carries in tags are cut out of that copy; the sound itself is not re-encoded. The original
stays with curators. A file whose structure the archive cannot follow is refused rather than served. OGG/Opus is not
- accepted yet. Recordings are not yet searched or transcribed.
+ accepted yet. An item with a recording is published only when its description holds the transcript or "Still needs a transcription" is ticked; the handbook shows how to make one on your own computer with whisper.cpp.
### For people running an archive
diff --git a/docs/curator-handbook.md b/docs/curator-handbook.md
index 008b53c..cf04a1b 100644
--- a/docs/curator-handbook.md
+++ b/docs/curator-handbook.md
@@ -62,8 +62,15 @@ sound itself is exactly the original's. The original stays with curators ("Origi
sense of a file, it says "No preview could be created" and offers nothing to visitors: try saving it again from the recorder
or converting it to MP3 or WAV. OGG and Opus are not accepted yet.
-A recording cannot be searched. Write down in the description what is said, or at least who and where, and tick "Still needs a
-transcription" until there is a transcript.
+Sound cannot be searched, and not everyone can listen. So an item with a recording is published only when its description holds
+the transcript, or when "Still needs a transcription" is ticked. Visitors then read the description beside the player, and
+search finds the words in it.
+
+**Making a transcript on your own computer.** Nothing is sent anywhere. Install [whisper.cpp](https://github.com/ggml-org/whisper.cpp),
+download one of its models (the "small" model is a good start) and run, for example,
+`whisper-cli -m ggml-small.bin -l de -f interview.wav -otxt`. It needs a WAV file at 16 kHz; `ffmpeg -i interview.mp3 -ar 16000
+-ac 1 interview.wav` makes one. Read the result through while listening: names and dialect words are often wrong. Paste it into the
+description and untick the box once it is checked.
## Rights, credit and what only you see
diff --git a/docs/handbuch-kuratoren.md b/docs/handbuch-kuratoren.md
index 860c265..f90a7d6 100644
--- a/docs/handbuch-kuratoren.md
+++ b/docs/handbuch-kuratoren.md
@@ -69,8 +69,15 @@ ist genau der des Originals. Das Original bleibt bei den Kuratoren („Original
anfangen, steht dort „Es konnte keine Vorschau erstellt werden“, und Besucher bekommen nichts: speichern Sie sie noch einmal aus dem
Aufnahmegerät oder wandeln Sie sie in MP3 oder WAV um. OGG und Opus werden noch nicht angenommen.
-Eine Aufnahme lässt sich nicht durchsuchen. Schreiben Sie in die Beschreibung, was gesagt wird, oder wenigstens wer und wo, und setzen Sie
-den Haken bei „Muss noch abgeschrieben werden“, bis es eine Abschrift gibt.
+Ton lässt sich nicht durchsuchen, und nicht jeder kann zuhören. Darum wird ein Eintrag mit einer Aufnahme nur veröffentlicht, wenn die
+Beschreibung die Abschrift enthält oder „Muss noch abgeschrieben werden“ angehakt ist. Besucher lesen die Beschreibung neben dem Player,
+und die Suche findet die Wörter darin.
+
+**Eine Abschrift auf dem eigenen Computer erstellen.** Nichts wird irgendwohin gesendet. Installieren Sie
+[whisper.cpp](https://github.com/ggml-org/whisper.cpp), laden Sie eines seiner Modelle herunter (das Modell „small“ ist ein guter Anfang) und
+starten Sie zum Beispiel `whisper-cli -m ggml-small.bin -l de -f gespraech.wav -otxt`. Es braucht eine WAV-Datei mit 16 kHz;
+`ffmpeg -i gespraech.mp3 -ar 16000 -ac 1 gespraech.wav` erzeugt eine. Lesen Sie das Ergebnis beim Zuhören durch: Namen und Mundartwörter
+sind oft falsch. Fügen Sie es in die Beschreibung ein und nehmen Sie den Haken heraus, sobald es geprüft ist.
## Rechte, Nennung und was nur Sie sehen
diff --git a/docs/roadmap.md b/docs/roadmap.md
index 79cb222..7b544cd 100644
--- a/docs/roadmap.md
+++ b/docs/roadmap.md
@@ -524,7 +524,7 @@ shows the years of its published items. M19 is complete.
of its own and is not worth holding the rest up.
*Built:* a recording is a `MediaFile` with an `audio/*` type and no picture sizes, so every query that picks a cover skips
it; its stripped copy is `audio/{StorageId}`. No new column, so no migration and no change to the export.
-- **Part 2: the transcript.** An item with audio needs a transcript before it is published, or the "transcript to follow"
+- **Part 2: the transcript** (built: the description is the transcript, shown beside the player and searched like any text). An item with audio needs a transcript before it is published, or the "transcript to follow"
flag (the existing "needs transcription" flag). The transcript is searched and shown beside the player. The handbook
documents a local whisper.cpp workflow, as "Not planned" promises.
diff --git a/src/Commonage.Web/Pages/Admin/Items/Bulk.cshtml b/src/Commonage.Web/Pages/Admin/Items/Bulk.cshtml
index c8b43de..af4b6f0 100644
--- a/src/Commonage.Web/Pages/Admin/Items/Bulk.cshtml
+++ b/src/Commonage.Web/Pages/Admin/Items/Bulk.cshtml
@@ -51,6 +51,10 @@
{
@T["Left out, because they have no title yet: {0}.", Model.WithoutTitle]
}
+ @if (Model.NoTranscript > 0)
+ {
+ @T["Left out, because a recording has no transcript yet: {0}.", Model.NoTranscript]
+ }
@if (Model.NotDrafts > 0)
{
@T["Left out, because they are not drafts: {0}. A contribution needs a decision of its own, on its own page.", Model.NotDrafts]
diff --git a/src/Commonage.Web/Pages/Admin/Items/Bulk.cshtml.cs b/src/Commonage.Web/Pages/Admin/Items/Bulk.cshtml.cs
index 5579857..715b940 100644
--- a/src/Commonage.Web/Pages/Admin/Items/Bulk.cshtml.cs
+++ b/src/Commonage.Web/Pages/Admin/Items/Bulk.cshtml.cs
@@ -71,6 +71,7 @@ public string? Back
public int WithoutTitle { get; private set; }
public int NotDrafts { get; private set; }
+ public int NoTranscript { get; private set; }
/// Items that already hold a date or a statement, which would be replaced.
public int WouldBeReplaced { get; private set; }
@@ -150,6 +151,9 @@ public async Task OnPostApplyAsync(CancellationToken cancellation
.Where(i => ids.Contains(i.Id))
.OrderBy(i => i.Id)
.ToListAsync(cancellationToken);
+ // A recording nobody can read needs its transcript first, as on the item's own page.
+ if (Action == BulkAction.Publish)
+ withoutTranscript = await WithoutTranscript(db.ArchiveItems.Where(i => ids.Contains(i.Id))).Select(i => i.Id).ToHashSetAsync(cancellationToken);
var tags = Action == BulkAction.AddTags ? await db.FindOrCreateTagsAsync(tagNames, cancellationToken) : [];
var now = DateTime.UtcNow;
@@ -215,7 +219,13 @@ private bool Apply(ArchiveItem item, List tags, DateTime now)
}
}
- private static bool IsPublishable(ArchiveItem item) => item.Status == ItemStatus.Draft && item.CanBePublished;
+ private HashSet withoutTranscript = [];
+
+ private bool IsPublishable(ArchiveItem item) => item.Status == ItemStatus.Draft && item.CanBePublished && !withoutTranscript.Contains(item.Id);
+
+ private static IQueryable WithoutTranscript(IQueryable items) =>
+ items.Where(i => i.Status == ItemStatus.Draft && (i.Description == null || i.Description.Trim() == "") && !i.NeedsTranscription
+ && i.MediaFiles.Any(f => f.ContentType.StartsWith("audio/")));
private List ParseIds() =>
Ids.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(id => int.TryParse(id, out var number) ? number : 0).Where(id => id > 0).ToList();
@@ -226,7 +236,8 @@ private async Task ShowAsync(List ids, CancellationToken cancellationToken)
Count = await items.CountAsync(cancellationToken);
WithoutTitle = await items.CountAsync(i => i.Status == ItemStatus.Draft && i.Title == "", cancellationToken);
NotDrafts = await items.CountAsync(i => i.Status != ItemStatus.Draft, cancellationToken);
- WillChange = Action == BulkAction.Publish ? Count - WithoutTitle - NotDrafts : Count;
+ NoTranscript = Action == BulkAction.Publish ? await WithoutTranscript(items).CountAsync(i => i.Title != "", cancellationToken) : 0;
+ WillChange = Action == BulkAction.Publish ? Count - WithoutTitle - NotDrafts - NoTranscript : Count;
WouldBeReplaced = Action switch
{
BulkAction.SetDate => await items.CountAsync(i => i.DateText != null, cancellationToken),
diff --git a/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml.cs b/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml.cs
index 9caf00c..f3207c7 100644
--- a/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml.cs
+++ b/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml.cs
@@ -283,6 +283,12 @@ public async Task OnPostAsync(int? id, string? command, string? t
}
}
+ // A recording nobody can read is not found by search and is closed to anyone who cannot listen: it needs a
+ // transcript in the description, or the promise of one.
+ if (command == "publish" && id is not null && string.IsNullOrWhiteSpace(Input.Description) && !Input.NeedsTranscription
+ && await db.MediaFiles.AnyAsync(f => f.ArchiveItemId == id && f.ContentType.StartsWith("audio/")))
+ ModelState.AddModelError("Input.Description", localizer["A recording needs its transcript in the description before it is published, or tick that a transcript will follow."]);
+
if (!ModelState.IsValid)
{
// A browser cannot fill in chosen files again when a form comes back, so it has to be said.
diff --git a/src/Commonage.Web/Resources/SharedResource.de.resx b/src/Commonage.Web/Resources/SharedResource.de.resx
index 5943702..532caf0 100644
--- a/src/Commonage.Web/Resources/SharedResource.de.resx
+++ b/src/Commonage.Web/Resources/SharedResource.de.resx
@@ -995,4 +995,6 @@
Aufnahme: {0}
Aufnahme wird vorbereitet…
Aufnahme {0} von {1}
+ Eine Aufnahme braucht vor der Veröffentlichung ihre Abschrift in der Beschreibung, oder setzen Sie den Haken, dass eine Abschrift folgt.
+ Ausgelassen, weil eine Aufnahme noch keine Abschrift hat: {0}.
diff --git a/src/Commonage.Web/Resources/SharedResource.resx b/src/Commonage.Web/Resources/SharedResource.resx
index 117daab..259ccb5 100644
--- a/src/Commonage.Web/Resources/SharedResource.resx
+++ b/src/Commonage.Web/Resources/SharedResource.resx
@@ -22,6 +22,7 @@
A new name changes the tag on every item that has it, also in the search.
A new setup link lets the person choose a new password, for example when they forgot theirs. Earlier links stop working. A disabled account cannot log in, but its history stays in the activity log.
A photo description can be at most {0, plural, one {# character} other {# characters}} long.Has a count. Write a form for each one your language needs, in ICU MessageFormat.
+ A recording needs its transcript in the description before it is published, or tick that a transcript will follow.
A rights statement
A tag can be at most {0, plural, one {# character} other {# characters}} long.Has a count. Write a form for each one your language needs, in ICU MessageFormat.
A tag can be at most {1} characters long.
@@ -349,6 +350,7 @@
Later
Later: {0}
Leave this field empty
+ Left out, because a recording has no transcript yet: {0}.
Left out, because the archive already has them: {0}
Left out, because they are not drafts: {0}. A contribution needs a decision of its own, on its own page.
Left out, because they have no title yet: {0}.
diff --git a/tests/Commonage.Tests/AudioTests.cs b/tests/Commonage.Tests/AudioTests.cs
index 9c99edd..de1c749 100644
--- a/tests/Commonage.Tests/AudioTests.cs
+++ b/tests/Commonage.Tests/AudioTests.cs
@@ -4,6 +4,7 @@
using System.Text;
using Commonage.Web.Domain;
using Commonage.Web.Media;
+using Commonage.Web.Pages.Admin.Items;
using Microsoft.EntityFrameworkCore;
namespace Commonage.Tests;
@@ -234,6 +235,86 @@ await app.WithDbAsync(async db =>
Assert.Equal(HttpStatusCode.NotFound, (await visitor.GetAsync($"/media/{file.Id}/audio")).StatusCode);
}
+ [Fact]
+ public async Task A_recording_is_published_only_with_a_transcript_or_the_promise_of_one()
+ {
+ using var curator = app.CreateClient();
+ await Browser.LogInAsCuratorAsync(curator);
+ var (itemId, _) = await UploadAsync(curator, "interview.mp3", RecordingWithTags());
+ await app.WithDbAsync(async db => { (await db.ArchiveItems.SingleAsync(i => i.Id == itemId)).Status = ItemStatus.Draft; return await db.SaveChangesAsync(); });
+ var item = await app.WithDbAsync(db => db.ArchiveItems.AsNoTracking().SingleAsync(i => i.Id == itemId));
+
+ async Task PublishAsync(string description, bool transcriptToFollow)
+ {
+ var fields = new Dictionary
+ {
+ ["Input.Title"] = item.Title, ["Input.CollectionId"] = item.CollectionId.ToString(),
+ ["Input.Description"] = description, ["command"] = "publish",
+ };
+ if (transcriptToFollow)
+ fields["Input.NeedsTranscription"] = "true";
+ return await Browser.SendFormAsync(curator, $"/Admin/Items/Edit/{itemId}", fields);
+ }
+
+ async Task StatusAsync() => (await app.WithDbAsync(db => db.ArchiveItems.AsNoTracking().SingleAsync(i => i.Id == itemId))).Status;
+
+ await PublishAsync(" ", false);
+ Assert.Equal(ItemStatus.Draft, await StatusAsync());
+
+ await PublishAsync("", true);
+ Assert.Equal(ItemStatus.Published, await StatusAsync());
+ }
+
+ [Fact]
+ public async Task Publishing_many_leaves_out_a_recording_that_has_no_transcript()
+ {
+ using var curator = app.CreateClient();
+ await Browser.LogInAsCuratorAsync(curator);
+ var (bare, _) = await UploadAsync(curator, "one.mp3", RecordingWithTags());
+ var (promised, _) = await UploadAsync(curator, "two.mp3", RecordingWithTags());
+ await app.WithDbAsync(async db =>
+ {
+ foreach (var item in await db.ArchiveItems.Where(i => i.Id == bare || i.Id == promised).ToListAsync())
+ {
+ item.Status = ItemStatus.Draft;
+ item.Description = null;
+ item.NeedsTranscription = item.Id == promised;
+ }
+ return await db.SaveChangesAsync();
+ });
+
+ var page = await curator.GetStringAsync("/Admin");
+ var response = await curator.PostAsync("/Admin/Items/Bulk?handler=Apply", new FormUrlEncodedContent(new Dictionary
+ {
+ ["__RequestVerificationToken"] = Browser.Token(page), ["Action"] = nameof(BulkAction.Publish), ["Ids"] = $"{bare},{promised}",
+ }));
+ response.EnsureSuccessStatusCode();
+
+ var after = await app.WithDbAsync(db => db.ArchiveItems.AsNoTracking().Where(i => i.Id == bare || i.Id == promised).ToDictionaryAsync(i => i.Id, i => i.Status));
+ Assert.Equal(ItemStatus.Draft, after[bare]);
+ Assert.Equal(ItemStatus.Published, after[promised]);
+ }
+
+ [Fact]
+ public async Task A_recording_with_a_transcript_in_the_description_is_published_and_found_by_its_words()
+ {
+ using var curator = app.CreateClient();
+ await Browser.LogInAsCuratorAsync(curator);
+ var (itemId, _) = await UploadAsync(curator, "interview.mp3", RecordingWithTags());
+ await app.WithDbAsync(async db => { (await db.ArchiveItems.SingleAsync(i => i.Id == itemId)).Status = ItemStatus.Draft; return await db.SaveChangesAsync(); });
+ var item = await app.WithDbAsync(db => db.ArchiveItems.AsNoTracking().SingleAsync(i => i.Id == itemId));
+ var word = $"smithy{Guid.NewGuid():N}";
+
+ await Browser.SendFormAsync(curator, $"/Admin/Items/Edit/{itemId}", new()
+ {
+ ["Input.Title"] = item.Title, ["Input.CollectionId"] = item.CollectionId.ToString(),
+ ["Input.Description"] = $"We walked past the {word} every morning.", ["command"] = "publish",
+ });
+
+ using var visitor = app.CreateClient();
+ Assert.Contains($"/items/{itemId}", await visitor.GetStringAsync($"/search?q={word}"));
+ }
+
[Fact]
public async Task A_recording_that_is_not_built_as_it_says_fails_without_a_copy_for_anyone()
{