Skip to content

We should add an interface for to load io.BytesIO? #10

Description

@AnkushMalaker

@app.post("/api/process-audio-files")
async def process_audio_files(
files: List[UploadFile] = File(...),
current_user: User = Depends(current_active_user),
device_name: Optional[str] = "file_upload"
):
"""Process uploaded audio files (.wav) and add them to the audio processing pipeline."""
try:
if not files:
raise HTTPException(status_code=400, detail="No files provided")

    # Generate client ID for file processing
    client_id = generate_client_id(current_user, device_name)
    
    # Create client state for processing
    client_state = await create_client_state(client_id, current_user, device_name)
    
    processed_files = []
    
    for file in files:
        # Check if file is a WAV file
        if not file.filename.lower().endswith('.wav'):
            audio_logger.warning(f"Skipping non-WAV file: {file.filename}")
            continue
            
        try:
            # Read file content
            content = await file.read()
            
            # Process WAV file
            with wave.open(io.BytesIO(content), 'rb') as wav_file:
                # Get audio parameters
                sample_rate = wav_file.getframerate()
                sample_width = wav_file.getsampwidth()
                channels = wav_file.getnchannels()
                
                # Read all audio data
                audio_data = wav_file.readframes(wav_file.getnframes())

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions