Add flac and ogg support

This commit is contained in:
Jaret Burkett committed 2026-04-10 12:10:54 -06:00
1 parent bfb373c8fa
commit 0b9c365acb
9 files changed
+11 -7

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@ export async function POST(request: Request) {
* @returns Array of absolute paths to image files * @returns Array of absolute paths to image files
*/ */
function findImagesRecursively(dir: string): string[] { function findImagesRecursively(dir: string): string[] {
const imageExtensions = ['.png', '.jpg', '.jpeg', '.webp', '.mp4', '.avi', '.mov', '.mkv', '.wmv', '.m4v', '.flv', '.mp3', '.wav']; const imageExtensions = ['.png', '.jpg', '.jpeg', '.webp', '.mp4', '.avi', '.mov', '.mkv', '.wmv', '.m4v', '.flv', '.mp3', '.wav', '.flac', '.ogg'];
let results: string[] = []; let results: string[] = [];
const items = fs.readdirSync(dir); const items = fs.readdirSync(dir);
@@ -62,6 +62,8 @@ export async function GET(request: NextRequest, { params }: { params: { filePath
// Audio // Audio
'.mp3': 'audio/mpeg', '.mp3': 'audio/mpeg',
'.wav': 'audio/wav', '.wav': 'audio/wav',
'.flac': 'audio/flac',
'.ogg': 'audio/ogg',
}; };
const contentType = contentTypeMap[ext] || 'application/octet-stream'; const contentType = contentTypeMap[ext] || 'application/octet-stream';
@@ -24,6 +24,8 @@ const contentTypeMap: { [key: string]: string } = {
// Audio // Audio
'.mp3': 'audio/mpeg', '.mp3': 'audio/mpeg',
'.wav': 'audio/wav', '.wav': 'audio/wav',
'.flac': 'audio/flac',
'.ogg': 'audio/ogg',
}; };
export async function GET(request: NextRequest, { params }: { params: { imagePath: string } }) { export async function GET(request: NextRequest, { params }: { params: { imagePath: string } }) {
+1 -1
View File
@@ -15,7 +15,7 @@ export async function POST(request: Request) {
} }
// make sure it is an image // make sure it is an image
if (!/\.(jpg|jpeg|png|bmp|gif|tiff|webp|mp4|mp3|wav)$/i.test(imgPath.toLowerCase())) { if (!/\.(jpg|jpeg|png|bmp|gif|tiff|webp|mp4|mp3|wav|flac|ogg)$/i.test(imgPath.toLowerCase())) {
return NextResponse.json({ error: 'Not an image' }, { status: 400 }); return NextResponse.json({ error: 'Not an image' }, { status: 400 });
} }
+1 -1
View File
@@ -29,7 +29,7 @@ export async function GET(request: NextRequest, { params }: { params: { jobID: s
const samples = fs const samples = fs
.readdirSync(samplesFolder) .readdirSync(samplesFolder)
.filter(file => { .filter(file => {
return file.endsWith('.png') || file.endsWith('.jpg') || file.endsWith('.jpeg') || file.endsWith('.webp') || file.endsWith('.mp4') || file.endsWith('mp3') || file.endsWith('wav'); return file.endsWith('.png') || file.endsWith('.jpg') || file.endsWith('.jpeg') || file.endsWith('.webp') || file.endsWith('.mp4') || file.endsWith('mp3') || file.endsWith('wav') || file.endsWith('flac') || file.endsWith('ogg');
}) })
.map(file => { .map(file => {
return path.join(samplesFolder, file); return path.join(samplesFolder, file);
+1 -1
View File
@@ -210,7 +210,7 @@ export default function AddImagesModal() {
() => ({ () => ({
'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp'], 'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp'],
'video/*': ['.mp4', '.avi', '.mov', '.mkv', '.wmv', '.m4v', '.flv'], 'video/*': ['.mp4', '.avi', '.mov', '.mkv', '.wmv', '.m4v', '.flv'],
'audio/*': ['.mp3', '.wav'], 'audio/*': ['.mp3', '.wav', '.flac', '.ogg'],
'text/*': ['.txt'], 'text/*': ['.txt'],
}), }),
[], [],
+1 -1
View File
@@ -18,7 +18,7 @@ export const defaultCaptionJobConfig: CaptionJobConfig = {
quantize: true, quantize: true,
qtype: 'float8', qtype: 'float8',
low_vram: true, low_vram: true,
extensions: ['mp3', 'wav'], extensions: ['mp3', 'wav', 'flac', 'ogg'],
path_to_caption: '', path_to_caption: '',
recaption: false, recaption: false,
}, },
+1 -1
View File
@@ -16,7 +16,7 @@ export interface CaptionOption {
const defaultNameOrPath = ''; const defaultNameOrPath = '';
const extensionsAudio = ['mp3', 'wav']; const extensionsAudio = ['mp3', 'wav', 'flac', 'ogg'];
const extensionsImage = ['jpg', 'jpeg', 'png', 'bmp', 'webp']; const extensionsImage = ['jpg', 'jpeg', 'png', 'bmp', 'webp'];
const defaultExtensions = [...extensionsImage]; const defaultExtensions = [...extensionsImage];
+1 -1
View File
@@ -6,7 +6,7 @@ export const wait = (ms: number) => new Promise(resolve => setTimeout(resolve, m
export const imgExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg', '.bmp']; export const imgExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg', '.bmp'];
export const videoExtensions = ['.mp4', '.avi', '.mov', '.mkv', '.wmv', '.m4v', '.flv']; export const videoExtensions = ['.mp4', '.avi', '.mov', '.mkv', '.wmv', '.m4v', '.flv'];
export const audioExtensions = ['.mp3', '.wav']; export const audioExtensions = ['.mp3', '.wav', '.flac', '.ogg'];
export const isVideo = (filePath: string) => videoExtensions.includes(filePath.toLowerCase().slice(-4)); export const isVideo = (filePath: string) => videoExtensions.includes(filePath.toLowerCase().slice(-4));
export const isImage = (filePath: string) => imgExtensions.includes(filePath.toLowerCase().slice(-4)); export const isImage = (filePath: string) => imgExtensions.includes(filePath.toLowerCase().slice(-4));