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
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and

## [Unreleased]

## [1.7.1] - 2026-11-21

### Fixed

- Plaud 4.0 recordings delivered as headerless constant-frame-size raw Opus streams (such as long hardware recordings whose `AUDIO_TRANSCODED` task is absent or still pending) are detected automatically and wrapped losslessly into standard Ogg/Opus `.ogg` containers before storage, so playback, waveform generation, and transcription work without re-encoding.
- Plaud 4.0 audio selection skips unready `AUDIO_TRANSCODED` entries (`task_status` other than `1`) and falls back cleanly to `AUDIO`, while later metadata-only sync updates preserve the wrapped `.ogg` file size and MD5.
- On startup, the server repairs previously synced local `.mp3` recordings that contain headerless raw Opus bytes into `.ogg`, resets failed auto-export attempts, backfills missing waveform peaks, and repairs matching raw Opus desktop auto-export files without creating duplicate library entries.
- Plaud 4.0 sync now remembers a failed workspace token re-mint for the rest of the run instead of repeating it per recording, restarts listing from the first 4.0 page if an account switches to 4.0 mid-run, keeps user-visible display folder names untouched during title push, and always records `filesize` and `file_md5` from the downloaded audio bytes.

## [1.7.0] - 2026-11-20

### Added
Expand Down Expand Up @@ -213,7 +222,8 @@ Initial release.
- **Self-hosting.** A single container image for linux/amd64 and linux/arm64, a Docker Compose file, a one-line installer, a health endpoint, and a single SQLite data volume.
- **Mac app.** A desktop app for Apple Silicon Macs that runs the server locally, with a menu bar item, launch at login, and a local data folder.

[Unreleased]: https://github.com/JeremyL691/OpenAudioHub/compare/v1.7.0...HEAD
[Unreleased]: https://github.com/JeremyL691/OpenAudioHub/compare/v1.7.1...HEAD
[1.7.1]: https://github.com/JeremyL691/OpenAudioHub/compare/v1.7.0...v1.7.1
[1.7.0]: https://github.com/JeremyL691/OpenAudioHub/compare/v1.6.0...v1.7.0
[1.6.0]: https://github.com/JeremyL691/OpenAudioHub/compare/v1.5.0...v1.6.0
[1.5.0]: https://github.com/JeremyL691/OpenAudioHub/compare/v1.4.0...v1.5.0
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["crates/oah", "desktop-tauri"]
resolver = "3"

[workspace.package]
version = "1.7.0"
version = "1.7.1"
edition = "2024"
# The AWS SDK here needs 1.94.1, so that is the floor for the whole workspace.
rust-version = "1.94.1"
Expand Down
36 changes: 36 additions & 0 deletions contract-tests/fakes/fake-plaud.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ import { gzipSync } from "node:zlib";
const port = Number(process.argv[2] ?? process.env.FAKE_PLAUD_PORT ?? 3298);
const origin = `http://127.0.0.1:${port}`;
const AUDIO = readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), "../fixtures/tone-3s.mp3"));
// 150 frames * 80 bytes = 3.0s of headerless CBR CELT WB 20ms mono Opus frames (TOC 0xB8).
const RAW_OPUS_AUDIO = (() => {
const buf = Buffer.alloc(150 * 80);
for (let i = 0; i < 150; i++) {
buf[i * 80] = 0xb8;
buf[i * 80 + 1] = 0xff;
buf[i * 80 + 2] = 0xfe;
}
return buf;
})();
const DAY = 24 * 3600;

const accounts = new Map(); // email -> { recordings: Map<id, record>, devices: [], revoked: boolean, migratedV4: boolean }
Expand Down Expand Up @@ -194,6 +204,12 @@ const server = createServer(async (req, res) => {
res.writeHead(200, { "content-type": "audio/mpeg", "content-length": AUDIO.length });
return res.end(AUDIO);
}
const rawAudio = url.pathname.match(/^\/audio-raw\/[^/]+$/);
if (req.method === "GET" && rawAudio) {
logRequest(req, url.pathname, "");
res.writeHead(200, { "content-type": "application/octet-stream", "content-length": RAW_OPUS_AUDIO.length });
return res.end(RAW_OPUS_AUDIO);
}
const content = url.pathname.match(/^\/content\/([^/]+)\/(transcript|summary)\.json$/);
if (req.method === "GET" && content) {
logRequest(req, url.pathname, "");
Expand Down Expand Up @@ -459,6 +475,26 @@ const server = createServer(async (req, res) => {
object_size: rec.filesize,
task_status: 1,
});
} else if (audioMode === "raw_opus") {
const rawUrl = `${origin}/audio-raw/${rec.id}.mp3`;
objects.push({
object_id: `obj_at_${fileId}`,
object_type: "AUDIO_TRANSCODED",
content_id: cidTranscoded,
content_url: null,
mime_type: "audio/mpeg",
object_size: rec.filesize,
task_status: 0,
});
objects.push({
object_id: `obj_a_${fileId}`,
object_type: "AUDIO",
content_id: cidAudio,
content_url: rawUrl,
mime_type: "audio/opus",
object_size: RAW_OPUS_AUDIO.length,
task_status: null,
});
}

if (rec.is_trans) {
Expand Down
95 changes: 95 additions & 0 deletions contract-tests/tests/plaud.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1381,4 +1381,99 @@ test.describe("plaud: 4.0 migrated accounts", () => {
expect(status).toMatchObject({ connected: true, needsReconnect: false });
await api.dispose();
});

test("raw headerless Opus AUDIO streams are wrapped into playable .ogg and transcribe cleanly", async () => {
const api = await freshUser("plaud-v4-raw-opus");
const email = uniq("v4-raw-opus");
const id = `f_raw_opus_${Date.now()}`;

await fakeControl("/account", {
email,
migratedV4: true,
recordings: [
{
id,
isV4New: true,
filename: "Long raw Opus recording",
audioMode: "raw_opus",
duration: 3000,
version_ms: 6100,
},
],
});
await signInV4(api, email);
expect(
(
await api.post("/api/settings/ai/providers", {
data: {
provider: "Custom",
apiKey: "plaud-v4-raw-opus-key",
baseUrl: fakeAiBaseUrl,
defaultModel: "fake-chat-1",
isDefaultTranscription: true,
isDefaultEnhancement: true,
},
})
).status(),
).toBe(200);

const before = (await v4FakeRequests()).length;
const sync = await (await api.post("/api/plaud/sync")).json();
expect(sync).toMatchObject({ success: true, newRecordings: 1, updatedRecordings: 0, errors: [] });

const requests = (await v4FakeRequests()).slice(before);
expect(requests.some((q) => q.path === `/audio-raw/${id}.mp3`)).toBe(true);
expect(requests.some((q) => q.path === "/file-app/v4/files/content/url")).toBe(false);

const list = (await (await api.get("/api/recordings")).json()).recordings as Array<Record<string, unknown>>;
const row = list.find((x) => x.plaudFileId === id);
expect(row, `recording ${id}`).toBeTruthy();
expect(String(row!.storagePath)).toMatch(/\.ogg$/);
expect(Number(row!.filesize)).toBeGreaterThan(12_000);
expect(Array.isArray(row!.waveformPeaks)).toBe(true);
expect((row!.waveformPeaks as number[]).length).toBe(256);

const audioRes = await api.get(`/api/recordings/${row!.id as string}/audio`);
expect(audioRes.status()).toBe(200);
expect(audioRes.headers()["content-type"]).toBe("audio/ogg");
const audioBuf = await audioRes.body();
expect(audioBuf.subarray(0, 4).toString("ascii")).toBe("OggS");
expect(audioBuf.includes(Buffer.from("OpusHead"))).toBe(true);

// A later Plaud version bump updates metadata without clobbering wrapped .ogg size or MD5.
const wrappedSize = row!.filesize;
const wrappedMd5 = row!.fileMd5;
await fakeControl("/account", {
email,
recordings: [
{
id,
filename: "Long raw Opus renamed",
version_ms: 6200,
filesize: 12_000,
},
],
});
const resync = await (await api.post("/api/plaud/sync")).json();
expect(resync).toMatchObject({ success: true, newRecordings: 0, updatedRecordings: 1, errors: [] });
const after = ((await (await api.get("/api/recordings")).json()).recordings as Array<Record<string, unknown>>).find(
(x) => x.plaudFileId === id,
);
expect(after).toMatchObject({
filename: "Long raw Opus renamed",
plaudVersion: "6200",
filesize: wrappedSize,
fileMd5: wrappedMd5,
storagePath: row!.storagePath,
});

const tr = await api.post(`/api/recordings/${row!.id as string}/transcribe`);
expect(tr.status()).toBe(200);
const detail = await waitFor(async () => {
const d = await (await api.get(`/api/recordings/${row!.id as string}`)).json();
return d.transcription ? d : undefined;
});
expect(detail.transcription.text.length).toBeGreaterThan(0);
await api.dispose();
});
});
8 changes: 6 additions & 2 deletions crates/oah/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,14 @@ pub fn start_workers(state: &AppState) {
summary::spawn(state);
webhooks::spawn(state);
plaud::spawn(state);
export::spawn(state);
zip_merge::spawn(state);
local_folder::spawn(state);
routes::recordings::spawn_waveform_backfill(state);
let startup_media = state.clone();
tokio::spawn(async move {
plaud::raw_opus::repair_stored_raw_opus(&startup_media).await;
export::spawn(&startup_media);
routes::recordings::backfill_waveforms(&startup_media).await;
});
}

/// The full HTTP application.
Expand Down
64 changes: 56 additions & 8 deletions crates/oah/src/plaud/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use serde_json::Value;
use tokio::io::{AsyncReadExt, AsyncWriteExt};

use super::api::{self, Client};
use super::raw_opus;
use super::sync::ItemError;
use crate::{AppState, ids};

Expand All @@ -16,6 +17,7 @@ pub struct Stored {
pub peaks: Option<Vec<f64>>,
pub byte_len: i64,
pub file_md5: String,
pub remuxed: bool,
}

/// Downloads a recording's original audio to the active storage backend and returns where it went.
Expand Down Expand Up @@ -60,22 +62,68 @@ async fn stage_downloaded(
file_md5: String,
) -> Result<Stored, ItemError> {
let head = read_head(temp).await?;
let ext = sniff_ext(&head);
let key = free_key(state, user_id, file_id, ext).await?;
let mut ext = sniff_ext(&head);
let mut final_temp = temp.to_path_buf();
let mut final_len = byte_len;
let mut final_md5 = file_md5;
let mut remuxed = false;
let mut wrapped_temp: Option<std::path::PathBuf> = None;

if !raw_opus::is_known_container(&head) {
let dir = temp.parent().unwrap_or(&state.config.storage_root);
let muxed = dir.join(format!(".plaud-ogg-{}.partial", ids::token_hex(8)));
match raw_opus::wrap_if_raw_opus(&state.config.ffprobe, temp, &muxed).await {
Ok(Some((ogg_len, ogg_md5))) => {
wrapped_temp = Some(muxed.clone());
final_temp = muxed;
final_len = ogg_len;
final_md5 = ogg_md5;
ext = "ogg";
remuxed = true;
}
Ok(None) => {
let _ = tokio::fs::remove_file(&muxed).await;
}
Err(e) => {
let _ = tokio::fs::remove_file(&muxed).await;
tracing::warn!(file_id, error = %e, "wrapping raw Opus audio into Ogg failed");
}
}
}

let key = match free_key(state, user_id, file_id, ext).await {
Ok(k) => k,
Err(e) => {
if let Some(p) = &wrapped_temp {
let _ = tokio::fs::remove_file(p).await;
}
return Err(e);
}
};
let mime = crate::routes::recordings::mime_for(ext);
let peaks =
crate::routes::recordings::media::compute_peaks(&state.config.ffmpeg, temp, 256).await;
state
crate::routes::recordings::media::compute_peaks(&state.config.ffmpeg, &final_temp, 256)
.await;
if let Err(e) = state
.storage
.store_staged(&key, temp, Some(mime))
.store_staged(&key, &final_temp, Some(mime))
.await
.map_err(|e| ItemError::Failed(format!("could not store the audio: {e}")))?;
{
if let Some(p) = &wrapped_temp {
let _ = tokio::fs::remove_file(p).await;
}
return Err(ItemError::Failed(format!("could not store the audio: {e}")));
}
if wrapped_temp.is_some() {
let _ = tokio::fs::remove_file(temp).await;
}
Ok(Stored {
storage_type: state.storage.active_type(),
key,
peaks,
byte_len,
file_md5,
byte_len: final_len,
file_md5: final_md5,
remuxed,
})
}

Expand Down
1 change: 1 addition & 0 deletions crates/oah/src/plaud/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
mod api;
mod connect;
mod import;
pub(crate) mod raw_opus;
pub(crate) mod sync;
mod v4;

Expand Down
Loading
Loading