Skip to main content

Professional Audio Processing API Client for Python

Project description

AudioPod Python SDK

The official Python SDK for the AudioPod API - Professional Audio Processing powered by AI.

PyPI version Python 3.8+ License: MIT

Features

  • 🎵 Music Generation - Create music from text prompts, lyrics, or audio samples
  • 🎤 Voice Cloning - Clone voices from audio samples and generate speech
  • 📝 Transcription - Convert speech to text with speaker diarization
  • 🌍 Translation - Translate audio and video content between languages
  • 🎬 Karaoke Generation - Create karaoke videos with synchronized lyrics
  • 🔊 Audio Enhancement - Denoise and improve audio quality
  • 👥 Speaker Analysis - Identify and separate speakers in audio
  • 💰 Credit Management - Track usage and manage API credits

Installation

pip install audiopod

Quick Start

Authentication

Get your API key from the AudioPod Dashboard and set it as an environment variable:

export AUDIOPOD_API_KEY="ap_your_api_key_here"

Or pass it directly to the client:

import audiopod

client = audiopod.Client(api_key="ap_your_api_key_here")

Basic Usage

Voice Cloning

import audiopod

# Initialize client
client = audiopod.Client()

# Clone a voice and generate speech
job = client.voice.clone_voice(
    voice_file="path/to/voice_sample.wav",
    text="Hello! This is a cloned voice speaking.",
    language="en",
    wait_for_completion=True
)

print(f"Generated audio URL: {job['output_url']}")

Music Generation

# Generate music from text
music_job = client.music.generate_music(
    prompt="upbeat electronic dance music with heavy bass",
    duration=120.0,  # 2 minutes
    wait_for_completion=True
)

print(f"Generated music URL: {music_job.output_url}")

Audio Transcription

# Transcribe audio with speaker diarization
transcript = client.transcription.transcribe_audio(
    audio_file="path/to/audio.mp3",
    language="en",
    enable_speaker_diarization=True,
    wait_for_completion=True
)

print(f"Transcript: {transcript.transcript}")
print(f"Detected {len(transcript.segments)} speakers")

Audio Translation

# Translate audio to another language
translation = client.translation.translate_audio(
    audio_file="path/to/english_audio.wav",
    target_language="es",  # Spanish
    wait_for_completion=True
)

print(f"Translated audio URL: {translation.audio_output_url}")

Async Support

The SDK supports async/await for better performance:

import asyncio
import audiopod

async def main():
    async with audiopod.AsyncClient() as client:
        # All the same methods are available with async support
        job = await client.voice.clone_voice(
            voice_file="voice.wav",
            text="Async voice cloning!",
            wait_for_completion=True
        )
        print(f"Async result: {job['output_url']}")

asyncio.run(main())

Advanced Examples

Create Voice Profile for Reuse

# Create a reusable voice profile
voice_profile = client.voice.create_voice_profile(
    name="My Custom Voice",
    voice_file="voice_sample.wav",
    description="A professional voice for narration",
    wait_for_completion=True
)

# Use the voice profile for speech generation
speech = client.voice.generate_speech(
    voice_id=voice_profile.id,
    text="This uses my custom voice profile!",
    wait_for_completion=True
)

Batch Processing

# Process multiple files
audio_files = ["file1.mp3", "file2.wav", "file3.m4a"]
jobs = []

for audio_file in audio_files:
    job = client.transcription.transcribe_audio(
        audio_file=audio_file,
        language="en"
    )
    jobs.append(job)

# Wait for all jobs to complete
for job in jobs:
    completed_job = client.transcription.get_transcription_job(job.id)
    while completed_job.job.status != "completed":
        time.sleep(5)
        completed_job = client.transcription.get_transcription_job(job.id)
    
    print(f"Transcript for {job.id}: {completed_job.transcript}")

Music Generation with Custom Parameters

# Generate rap music with specific parameters
rap_job = client.music.generate_rap(
    lyrics="""
    Started from the bottom now we're here
    Building dreams with every single year
    AI music generation so clear
    AudioPod making magic appear
    """,
    style="modern",
    tempo=120,
    wait_for_completion=True
)

# Share the generated music
share_result = client.music.share_music_track(
    job_id=rap_job.job.id,
    platform="social",
    message="Check out this AI-generated rap!"
)
print(f"Shareable URL: {share_result['share_url']}")

Karaoke Video Generation

# Generate karaoke video from YouTube URL
karaoke_job = client.karaoke.generate_karaoke(
    youtube_url="https://www.youtube.com/watch?v=example",
    video_style="modern",
    wait_for_completion=True
)

print(f"Karaoke video URL: {karaoke_job.result['karaoke_video_path']}")

Error Handling

import audiopod
from audiopod.exceptions import (
    AudioPodError,
    AuthenticationError,
    RateLimitError,
    ValidationError,
    ProcessingError
)

try:
    client = audiopod.Client(api_key="invalid_key")
    job = client.voice.clone_voice("voice.wav", "Test text")
    
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limit exceeded. Retry after: {e.retry_after} seconds")
except ValidationError as e:
    print(f"Invalid input: {e.message}")
except ProcessingError as e:
    print(f"Processing failed: {e.message}")
except AudioPodError as e:
    print(f"General API error: {e.message}")

Credit Management

# Check credit balance
credits = client.credits.get_credit_balance()
print(f"Available credits: {credits.total_available_credits}")
print(f"Next reset: {credits.next_reset_date}")

# Get usage history
usage = client.credits.get_usage_history()
for record in usage:
    print(f"Service: {record['service_type']}, Credits: {record['credits_used']}")

# Get credit multipliers
multipliers = client.credits.get_credit_multipliers()
print(f"Voice cloning: {multipliers['voice_cloning']} credits/second")

Configuration

Environment Variables

  • AUDIOPOD_API_KEY: Your AudioPod API key
  • AUDIOPOD_BASE_URL: Custom API base URL (optional)
  • AUDIOPOD_TIMEOUT: Request timeout in seconds (default: 30)

Client Configuration

client = audiopod.Client(
    api_key="your_api_key",
    base_url="https://api.audiopod.ai",  # Custom base URL
    timeout=60,  # 60 second timeout
    max_retries=5,  # Retry failed requests
    verify_ssl=True,  # SSL verification
    debug=True  # Enable debug logging
)

API Reference

Client Classes

  • audiopod.Client: Synchronous client
  • audiopod.AsyncClient: Asynchronous client

Services

  • client.voice: Voice cloning and TTS operations
  • client.music: Music generation and editing
  • client.transcription: Speech-to-text transcription
  • client.translation: Audio/video translation
  • client.speaker: Speaker analysis and diarization
  • client.denoiser: Audio denoising and enhancement
  • client.karaoke: Karaoke video generation
  • client.credits: Credit management and usage tracking

Models

  • Job: Base job information and status
  • VoiceProfile: Voice profile details
  • TranscriptionResult: Transcription results and metadata
  • MusicGenerationResult: Music generation results
  • TranslationResult: Translation job results
  • CreditInfo: User credit information

CLI Usage

The SDK includes a command-line interface:

# Check API status
audiopod health

# Get credit balance  
audiopod credits balance

# Clone a voice
audiopod voice clone voice.wav "Hello world!" --language en

# Generate music
audiopod music generate "upbeat electronic music" --duration 60

# Transcribe audio
audiopod transcription transcribe audio.mp3 --language en

Requirements

  • Python 3.8+
  • Active AudioPod account with API access
  • Valid API key

Support

License

This SDK is released under the MIT License. See LICENSE for details.


Made with ❤️ by the AudioPod team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

audiopod-1.1.0.tar.gz (38.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

audiopod-1.1.0-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

Details for the file audiopod-1.1.0.tar.gz.

File metadata

  • Download URL: audiopod-1.1.0.tar.gz
  • Upload date:
  • Size: 38.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for audiopod-1.1.0.tar.gz
Algorithm Hash digest
SHA256 278d7835a691683559235cdd4e0fcb36ea8a666186b473e496f48e9d0838ac83
MD5 6751e2ca78166e4de36615ebfae3966d
BLAKE2b-256 e172c8a13e165bfb7417c51e864a8bbd7ae086bd872e27fd87a47692b09783b1

See more details on using hashes here.

File details

Details for the file audiopod-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: audiopod-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for audiopod-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f2f94b9ae4a41a9444448a05b3b6fe8054edc56188db93fb5c03b69542818f0
MD5 6c6669812263fe9b7453507fa9bff6f0
BLAKE2b-256 d7ca3e8c32c9e917bdc19ccf2fb87879181eca48a128ff1309cc381e72683a1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page