INNER CODE UNIT · Python

create_audio_from_text_elevenlabs

rohitg00/awesome-ai-apps · multimodal-apps/hedra-live-avatars-demo/hedra-avatar-backend/app/main.py:126

def create_audio_from_text_elevenlabs(text: str, voice_id: str) -> bytes:
    """Create audio from text using ElevenLabs API"""
    try:
        logger.info(f"🎤 Creating ElevenLabs audio: '{text[:50]}...' with voice: {voice_id}")
        
        # Generate audio using ElevenLabs new API
        audio = elevenlabs_client.text_to_speech.convert(
            text=text,
            voice_id=voice_id,
            model_id="eleven_multilingual_v2",  # High quality model
            output_format="mp3_44100_128"
        )
        
        # Convert audio response to bytes
        audio_data = b"".join(audio)
        
        logger.info(f"✅ ElevenLabs audio created: {len(audio_data)} bytes")
        return audio_data

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…