AnkushMalaker / AnkushMalaker/python-audio-interfaces

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

オープン
#10 コメント 0 件 リアクション 0 件 担当者 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 を短くまとめたダイジェスト。