AnkushMalaker / AnkushMalaker/python-audio-interfaces

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

未關閉
#10 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
1
分支
0
PR 合併指標
30 天內沒有已合併 PR

描述

@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())

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。