mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-27 00:53:37 +00:00
Documented the transcription bitrate decisions and hardened its fallback
This commit is contained in:
parent
edfb9a5819
commit
3d0761f243
@ -582,6 +582,9 @@ CONFIG["SETTINGS"] = {}
|
||||
-- Allowed values are: KBPS_32, KBPS_64, KBPS_128, KBPS_256
|
||||
-- Higher bitrates improve transcription accuracy on noisy or quiet recordings, at the cost of
|
||||
-- a larger upload to the transcription provider. KBPS_128 is recommended.
|
||||
-- Please note: this bitrate applies whenever a recording has to be re-encoded. A file which already
|
||||
-- is a single mono 48 kHz Opus track in a WebM container and stays below 25 MiB is forwarded to the
|
||||
-- transcription provider unchanged, keeping the bitrate it was created with.
|
||||
-- CONFIG["SETTINGS"]["DataApp.OpusBitrate"] = "KBPS_32"
|
||||
--
|
||||
-- Allow the user to change the Opus bitrate even though your organization set a default above:
|
||||
|
||||
@ -327,6 +327,8 @@ public static class ConfigurationSelectDataFactory
|
||||
public static IEnumerable<ConfigurationSelectData<TranscriptionOpusBitrate>> GetTranscriptionOpusBitrateData()
|
||||
{
|
||||
foreach (var bitrate in Enum.GetValues<TranscriptionOpusBitrate>())
|
||||
{
|
||||
yield return new(bitrate.GetName(), bitrate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,6 +115,13 @@ public sealed class DataApp(Expression<Func<Data, DataApp>>? configSelection = n
|
||||
/// <summary>
|
||||
/// The Opus bitrate used when normalizing uploaded audio/video for transcription.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Every recording is re-encoded to mono Opus before it goes to the transcription provider. That
|
||||
/// encoding used to be fixed at 32 kbps, which cost the transcription models entire quiet passages:
|
||||
/// a greeting spoken softly at the start of a recording was simply missing from the transcript. The
|
||||
/// same recording compared at 64 and 128 kbps came back complete, which is why 128 kbps is the
|
||||
/// default here. Users trading accuracy for a smaller upload can still pick a lower bitrate.
|
||||
/// </remarks>
|
||||
public TranscriptionOpusBitrate OpusBitrate { get; set; } = ManagedConfiguration.Register(configSelection, n => n.OpusBitrate, TranscriptionOpusBitrate.KBPS_128);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -2,8 +2,13 @@ namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public enum TranscriptionOpusBitrate
|
||||
{
|
||||
// The recommended bitrate is deliberately the member with the underlying value 0: when the
|
||||
// settings file holds a value TolerantEnumConverter cannot read, it falls back to that member.
|
||||
// Landing on the lowest bitrate there would silently reintroduce the very defect this setting
|
||||
// exists to prevent -- transcripts losing what was said quietly.
|
||||
KBPS_128 = 0,
|
||||
|
||||
KBPS_32,
|
||||
KBPS_64,
|
||||
KBPS_128,
|
||||
KBPS_256,
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,9 @@ public static class TranscriptionOpusBitrateExtensions
|
||||
TranscriptionOpusBitrate.KBPS_64 => 64_000,
|
||||
TranscriptionOpusBitrate.KBPS_128 => 128_000,
|
||||
TranscriptionOpusBitrate.KBPS_256 => 256_000,
|
||||
_ => 32_000,
|
||||
|
||||
// A value we do not know must never mean the lowest quality: that is how quiet passages
|
||||
// went missing from transcripts in the first place. Fall back to the recommended bitrate.
|
||||
_ => 128_000,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -647,9 +647,14 @@ public sealed class MediaTranscriptionService(
|
||||
MediaOperation operation,
|
||||
bool updateImportState)
|
||||
{
|
||||
// The bitrate governs re-encoding, not every upload: the runtime hands a file through
|
||||
// unchanged when it already is a single mono 48 kHz Opus track in a WebM container and small
|
||||
// enough. Such a file keeps whatever bitrate it was made with, which is the better outcome --
|
||||
// re-encoding it could only take quality away, never add any.
|
||||
var opusBitrateBps = settingsManager.ConfigurationData.App.OpusBitrate.GetBitsPerSecond();
|
||||
|
||||
// The quick POST is intentionally not cancelled: losing its response could orphan a job
|
||||
// whose ID the client never received. Cancellation is applied immediately after ownership.
|
||||
var opusBitrateBps = settingsManager.ConfigurationData.App.OpusBitrate.GetBitsPerSecond();
|
||||
var jobId = await rustService.StartMediaJobAsync(mediaPath, normalizedPath, opusBitrateBps, CancellationToken.None);
|
||||
operation.JobId = jobId;
|
||||
|
||||
|
||||
@ -60,6 +60,11 @@ const OPUS_PRE_SKIP: u16 = 312;
|
||||
const DEFAULT_MAX_PASS_THROUGH_BYTES: u64 = 25 * 1024 * 1024;
|
||||
|
||||
/// Default target bitrate for mono speech-oriented Opus output, used when a request omits it.
|
||||
///
|
||||
/// AI Studio always states a bitrate, so this default only covers requests which leave it out. It is
|
||||
/// 128 kbps because the 32 kbps this encoder used to be fixed at cost transcription models whole
|
||||
/// quiet passages: a softly spoken greeting at the start of a recording never reached the transcript,
|
||||
/// while the same recording at 128 kbps came back complete.
|
||||
const DEFAULT_OPUS_BITRATE_BPS: u32 = 128_000;
|
||||
|
||||
/// Bounded input block used for streaming resampling.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user