-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
@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())
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels