Identify Blurt in OpenRouter requests
This commit is contained in:
@@ -24,6 +24,8 @@ from scipy.io import wavfile
|
||||
|
||||
OPENAI_TRANSCRIPTIONS_URL = "https://api.openai.com/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_LANGUAGE = "en"
|
||||
# (model_id, menu_label, provider). The provider selects both the API endpoint
|
||||
@@ -484,7 +486,7 @@ class BlurtApp:
|
||||
result = self._transcribe_openrouter(wav_bytes)
|
||||
else:
|
||||
result = self._transcribe_openai(wav_bytes)
|
||||
text = result.get("text", "")
|
||||
text = result.get("text", "").lstrip()
|
||||
logging.info("Transcription text length: %d", len(text))
|
||||
if "usage" in result:
|
||||
logging.info("Transcription usage: %s", result["usage"])
|
||||
@@ -547,7 +549,11 @@ class BlurtApp:
|
||||
audio_b64 = base64.b64encode(wav_bytes).decode("ascii")
|
||||
response = self.session.post(
|
||||
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={
|
||||
"model": self.transcription_model,
|
||||
"input_audio": {"data": audio_b64, "format": "wav"},
|
||||
|
||||
Reference in New Issue
Block a user