diff --git a/orpheus-best-performance/call.py b/orpheus-best-performance/call.py index 7d307a067..71f3753a7 100644 --- a/orpheus-best-performance/call.py +++ b/orpheus-best-performance/call.py @@ -1,15 +1,16 @@ import asyncio +import os import aiohttp import uuid import time -import os +import struct from concurrent.futures import ProcessPoolExecutor # Configuration -MODEL = "dq4rlnkw" +MODEL = "YOUR_MODEL_ID" BASETEN_HOST = f"https://model-{MODEL}.api.baseten.co/production/predict" -BASETEN_API_KEY = os.environ["BASETEN_API_KEY"] -PAYLOADS_PER_PROCESS = 2000 +BASETEN_API_KEY = os.getenv("BASETEN_API_KEY") +PAYLOADS_PER_PROCESS = 1 NUM_PROCESSES = 4 MAX_REQUESTS_PER_PROCESS = 8 @@ -87,9 +88,11 @@ async def run_session( return elif run_id < 3: fn = f"output_{ptype}_run{run_id}.wav" + # Convert raw PCM data to proper WAV format + wav_data = pcm_to_wav(buf) with open(fn, "wb") as f: - f.write(buf) - print(f"[{label}] ➔ saved {fn}") + f.write(wav_data) + print(f"[{label}] ➔ saved {fn} (converted to WAV)") except Exception as e: print(f"[{label}] 🛑 failed: {e!r}") @@ -130,5 +133,56 @@ def main(): print("🎉 All processes completed.") +def pcm_to_wav( + pcm_data: bytes, + sample_rate: int = 24000, + channels: int = 1, + bits_per_sample: int = 16, +) -> bytes: + """Convert raw PCM data to WAV format with proper headers.""" + # WAV file header + # RIFF header + riff_header = b"RIFF" + # File size (will be calculated) + file_size = 36 + len(pcm_data) + file_size_bytes = struct.pack("