Identify Blurt in OpenRouter requests

This commit is contained in:
2026-08-08 15:19:59 -04:00
parent da941035f9
commit 0b94bcd1c0
+8 -2
View File
@@ -24,6 +24,8 @@ from scipy.io import wavfile
OPENAI_TRANSCRIPTIONS_URL = "https://api.openai.com/v1/audio/transcriptions" OPENAI_TRANSCRIPTIONS_URL = "https://api.openai.com/v1/audio/transcriptions"
OPENROUTER_TRANSCRIPTIONS_URL = "https://openrouter.ai/api/v1/audio/transcriptions" OPENROUTER_TRANSCRIPTIONS_URL = "https://openrouter.ai/api/v1/audio/transcriptions"
OPENROUTER_APP_URL = "https://git.felixm.de/felixm/blurt"
OPENROUTER_APP_TITLE = "Blurt"
DEFAULT_TRANSCRIPTION_MODEL = "whisper-1" DEFAULT_TRANSCRIPTION_MODEL = "whisper-1"
DEFAULT_TRANSCRIPTION_LANGUAGE = "en" DEFAULT_TRANSCRIPTION_LANGUAGE = "en"
# (model_id, menu_label, provider). The provider selects both the API endpoint # (model_id, menu_label, provider). The provider selects both the API endpoint
@@ -484,7 +486,7 @@ class BlurtApp:
result = self._transcribe_openrouter(wav_bytes) result = self._transcribe_openrouter(wav_bytes)
else: else:
result = self._transcribe_openai(wav_bytes) result = self._transcribe_openai(wav_bytes)
text = result.get("text", "") text = result.get("text", "").lstrip()
logging.info("Transcription text length: %d", len(text)) logging.info("Transcription text length: %d", len(text))
if "usage" in result: if "usage" in result:
logging.info("Transcription usage: %s", result["usage"]) logging.info("Transcription usage: %s", result["usage"])
@@ -547,7 +549,11 @@ class BlurtApp:
audio_b64 = base64.b64encode(wav_bytes).decode("ascii") audio_b64 = base64.b64encode(wav_bytes).decode("ascii")
response = self.session.post( response = self.session.post(
OPENROUTER_TRANSCRIPTIONS_URL, OPENROUTER_TRANSCRIPTIONS_URL,
headers={"Authorization": f"Bearer {self.api_keys['openrouter']}"}, headers={
"Authorization": f"Bearer {self.api_keys['openrouter']}",
"HTTP-Referer": OPENROUTER_APP_URL,
"X-OpenRouter-Title": OPENROUTER_APP_TITLE,
},
json={ json={
"model": self.transcription_model, "model": self.transcription_model,
"input_audio": {"data": audio_b64, "format": "wav"}, "input_audio": {"data": audio_b64, "format": "wav"},