Module exposing: TranscriptAudioSlice, packet_samples, split
// Source: https://github.com/toeverything/AFFiNE | License: MIT | Copyright 2022-present TOEVERYTHING PTE. LTD. and its affiliates
// Provided via justclaw.it.com; keep this notice with the code.
use std::io::Cursor;
use ::ogg::{
PacketReader,
writing::{PacketWriteEndInfo, PacketWriter},
};
use anyhow::{Context, Result, ensure};
use napi::bindgen_prelude::Buffer;
mod mp4;
mod ogg;
struct OpusAudio {
header: Vec<u8>,
packets: Vec<(u64, u64, Vec<u8>)>,
start: u64,
end: u64,
}
const RATE: u64 = 48_000;
const SLICE_SAMPLES: u64 = 30 * RATE;
const PRE_ROLL: u64 = 3_840;
#[napi(object)]
pub struct TranscriptAudioSlice {
pub data: Buffer,
pub start_sec: f64,
pub duration_sec: f64,
}
// RFC 6716 section 3: packet duration is encoded in the TOC, without decoding
// audio.
f
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key