Add flac and ogg support

This commit is contained in:
Jaret Burkett 2026-04-10 12:10:54 -06:00
parent bfb373c8fa
commit 0b9c365acb
9 changed files with 11 additions and 7 deletions

View File

@ -36,7 +36,7 @@ export async function POST(request: Request) {
* @returns Array of absolute paths to image files
*/
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[] = [];
const items = fs.readdirSync(dir);

View File

@ -62,6 +62,8 @@ export async function GET(request: NextRequest, { params }: { params: { filePath
// Audio
'.mp3': 'audio/mpeg',
'.wav': 'audio/wav',
'.flac': 'audio/flac',
'.ogg': 'audio/ogg',
};
const contentType = contentTypeMap[ext] || 'application/octet-stream';

View File

@ -24,6 +24,8 @@ const contentTypeMap: { [key: string]: string } = {
// Audio
'.mp3': 'audio/mpeg',
'.wav': 'audio/wav',
'.flac': 'audio/flac',
'.ogg': 'audio/ogg',
};
export async function GET(request: NextRequest, { params }: { params: { imagePath: string } }) {

View File

@ -15,7 +15,7 @@ export async function POST(request: Request) {
}
// 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 });
}

View File

@ -29,7 +29,7 @@ export async function GET(request: NextRequest, { params }: { params: { jobID: s
const samples = fs
.readdirSync(samplesFolder)
.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 => {
return path.join(samplesFolder, file);

View File

@ -210,7 +210,7 @@ export default function AddImagesModal() {
() => ({
'image/*': ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp'],
'video/*': ['.mp4', '.avi', '.mov', '.mkv', '.wmv', '.m4v', '.flv'],
'audio/*': ['.mp3', '.wav'],
'audio/*': ['.mp3', '.wav', '.flac', '.ogg'],
'text/*': ['.txt'],
}),
[],

View File

@ -18,7 +18,7 @@ export const defaultCaptionJobConfig: CaptionJobConfig = {
quantize: true,
qtype: 'float8',
low_vram: true,
extensions: ['mp3', 'wav'],
extensions: ['mp3', 'wav', 'flac', 'ogg'],
path_to_caption: '',
recaption: false,
},

View File

@ -16,7 +16,7 @@ export interface CaptionOption {
const defaultNameOrPath = '';
const extensionsAudio = ['mp3', 'wav'];
const extensionsAudio = ['mp3', 'wav', 'flac', 'ogg'];
const extensionsImage = ['jpg', 'jpeg', 'png', 'bmp', 'webp'];
const defaultExtensions = [...extensionsImage];

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 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 isImage = (filePath: string) => imgExtensions.includes(filePath.toLowerCase().slice(-4));