FileZen + ElevenLabs Audio Generation Integration
Learn how to integrate FileZen’s powerful file upload capabilities with ElevenLabs AI audio generation to automatically save generated audio files to your cloud storage. This recipe demonstrates how to create an AI audio generator using ElevenLabs that seamlessly uploads results to FileZen.
Overview
This integration combines ElevenLabs’ high-quality text-to-speech service with FileZen’s file management to create a complete workflow: generate audio from text prompts and automatically store them in your cloud storage with CDN delivery.
Key Benefits
- 🔗 CDN Delivery: Get optimized CDN URLs for all generated audio files
- 📝 Metadata Support: Store generation prompts and other metadata with files
- 🎨 Rich Integration: Seamlessly combine AI generation with cloud storage
Prerequisites
Before starting, make sure you have:
- Node.js 18+ installed
- A FileZen account and API key
- An ElevenLabs account and API key
- Basic knowledge of React and Next.js
- FileZen set up in your project (follow the Next.js guide or other framework guides)
Install the ElevenLabs SDK:
npm install @elevenlabs/elevenlabs-jsCore Integration
Here’s how to integrate ElevenLabs audio generation with FileZen upload:
import { useZenClient } from '@filezen/react';
import { ElevenLabsClient } from '@elevenlabs/elevenlabs-js';
const zenClient = useZenClient();
const elevenlabs = new ElevenLabsClient({
apiKey: process.env.ELEVENLABS_API_KEY || '',
});
// Generate AI audio and upload to FileZen in one workflow
const generateAndUpload = async (text: string, voiceId: string): Promise<ZenFile> => {
// Step 1: Generate audio using ElevenLabs SDK
const audio = await elevenlabs.textToSpeech.convert(voiceId, {
text: text,
modelId: 'eleven_multilingual_v2',
voiceSettings: {
stability: 0.5,
similarityBoost: 0.5,
},
});
// Step 2: Upload generated audio to FileZen
const uploadResult = await zenClient.upload(audio, {
name: `elevenlabs-audio-${Date.now()}.mp3`,
mimeType: 'audio/mpeg',
metadata: {
text: text,
voiceId: voiceId,
generatedAt: new Date().toISOString(),
source: 'elevenlabs-audio-generation',
},
});
if (uploadResult.error) {
throw new Error(uploadResult.error.message);
}
return uploadResult.file;
};This integration provides a complete workflow for ElevenLabs-powered audio generation with automatic cloud storage, making it easy to create, manage, and serve AI-generated audio content through FileZen’s robust infrastructure.