From d01efcb3084a0a3bd7302294d1072ab8ab247ecd Mon Sep 17 00:00:00 2001 From: AlexsanderHamir Date: Sat, 15 Nov 2025 15:58:41 -0800 Subject: [PATCH] speech set up --- no_cache_hits.py | 48 +++++++++++++++++++++++++++++++++++++++++++++ speech.mp3 | Bin 0 -> 104 bytes speech_config.yaml | 9 +++++++++ 3 files changed, 57 insertions(+) create mode 100644 no_cache_hits.py create mode 100644 speech.mp3 create mode 100644 speech_config.yaml diff --git a/no_cache_hits.py b/no_cache_hits.py new file mode 100644 index 00000000000..1b3bf895f77 --- /dev/null +++ b/no_cache_hits.py @@ -0,0 +1,48 @@ +from locust import HttpUser, between, task + + +class MyUser(HttpUser): + """ + Minimal Locust user for repeatedly hitting `/v1/audio/speech`. + The goal is to measure server-side performance, so we avoid any extra work + (file writes, random generation, manual timing, custom event hooks, etc.) + that could inflate client-side latency. + """ + + wait_time = between(0.5, 1) + host = "http://0.0.0.0:8090" + + def on_start(self): + self.api_key = "sk-1234" + self.model_name = "fake-openai-speech" + self.headers = { + "Authorization": f"Bearer {self.api_key}", + "Content-Type": "application/json", + } + self.prompt_counter = 0 + + @task + def audio_speech_request(self): + self.prompt_counter += 1 + # Ensure prompts differ slightly so the backend can't reuse cached audio. + prompt = ( + "Generate a short spoken status update mentioning counter " + f"{self.prompt_counter}." + ) + + response = self.client.post( + "v1/audio/speech", + json={ + "model": self.model_name, + "input": prompt, + "voice": "alloy", + "format": "mp3", + }, + headers=self.headers, + name="audio_speech", + ) + + if response.status_code != 200: + # log the errors in error.txt + with open("error.txt", "a") as error_log: + error_log.write(response.text + "\n") \ No newline at end of file diff --git a/speech.mp3 b/speech.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..f4f854d9bd215e2493d48b4bc4d39804bd79c038 GIT binary patch literal 104 NcmezWdjbPJ000JT0*e3u literal 0 HcmV?d00001 diff --git a/speech_config.yaml b/speech_config.yaml new file mode 100644 index 00000000000..ad9920a2793 --- /dev/null +++ b/speech_config.yaml @@ -0,0 +1,9 @@ +model_list: + - model_name: fake-openai-speech + litellm_params: + model: openai/gpt-4o-mini-tts + api_base: http://0.0.0.0:8090/ + api_key: sk-1234 + model_info: + mode: audio_speech + \ No newline at end of file