mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-11 19:06:11 +00:00
Let OpenRouter subtitles use a chosen model instead of whisper-1
A timestamped run on OpenRouter always asked openai/whisper-1 for the segments, whatever model was picked for plain transcription. Not every model there returns segment times, so the one to use is now its own setting, openrouter_subtitle_model, shown in the speech-to-text box only when OpenRouter is the provider. Empty keeps the old whisper-1 fallback. Target carries the choice as subtitle_model and timestamp_model() reads it; the other providers are unchanged.
This commit is contained in:
@@ -53,6 +53,16 @@ class TimestampModel(unittest.TestCase):
|
||||
self.assertEqual(api.timestamp_model("openai", "gpt-4o-transcribe"),
|
||||
"whisper-1")
|
||||
|
||||
def test_openrouter_takes_the_subtitle_model_that_was_set(self):
|
||||
self.assertEqual(
|
||||
api.timestamp_model("openrouter", "openai/gpt-4o-transcribe",
|
||||
"openai/whisper-large-v3"),
|
||||
"openai/whisper-large-v3")
|
||||
|
||||
def test_openrouter_with_no_subtitle_model_falls_back_to_whisper(self):
|
||||
self.assertEqual(api.timestamp_model("openrouter", "openai/gpt-4o-transcribe", ""),
|
||||
"openai/whisper-1")
|
||||
|
||||
|
||||
class Explain(DikteTest):
|
||||
def error(self, status):
|
||||
@@ -318,6 +328,13 @@ class TranscribeSegments(DikteTest):
|
||||
api.transcribe_segments(OPENROUTER, self.wav)
|
||||
self.assertEqual(multipart_fields(calls[0])["model"], "openai/whisper-1")
|
||||
|
||||
def test_openrouter_asks_for_the_subtitle_model_when_one_is_set(self):
|
||||
target = OPENROUTER._replace(subtitle_model="mistralai/voxtral-mini-transcribe")
|
||||
with fake_urlopen(self.reply([{"start": 0, "end": 1, "text": "hi"}])) as calls:
|
||||
api.transcribe_segments(target, self.wav)
|
||||
self.assertEqual(multipart_fields(calls[0])["model"],
|
||||
"mistralai/voxtral-mini-transcribe")
|
||||
|
||||
def test_groq_stays_on_the_model_it_was_given(self):
|
||||
target = GROQ._replace(model="whisper-large-v3")
|
||||
with fake_urlopen(self.reply([{"start": 0, "end": 1, "text": "hi"}])) as calls:
|
||||
|
||||
@@ -220,6 +220,19 @@ class TranscribeTarget(DikteTest):
|
||||
self.assertEqual(target.service, "OpenRouter")
|
||||
self.assertEqual(target.api_key, "sk-or-test")
|
||||
self.assertEqual(target.model, "openai/whisper-1")
|
||||
self.assertEqual(target.subtitle_model, "")
|
||||
|
||||
def test_openrouter_carries_its_subtitle_model(self):
|
||||
conf = self.config(transcribe_provider="openrouter",
|
||||
openrouter_api_key="sk-or-test",
|
||||
openrouter_subtitle_model=" openai/whisper-large-v3 ")
|
||||
self.assertEqual(conf.transcribe_target().subtitle_model,
|
||||
"openai/whisper-large-v3")
|
||||
|
||||
def test_only_openrouter_has_a_subtitle_model(self):
|
||||
conf = self.config(transcribe_provider="openai", openai_api_key="sk-test",
|
||||
openrouter_subtitle_model="openai/whisper-large-v3")
|
||||
self.assertEqual(conf.transcribe_target().subtitle_model, "")
|
||||
|
||||
def test_groq_when_it_is_picked(self):
|
||||
conf = self.config(transcribe_provider="groq", groq_api_key="gsk-test",
|
||||
|
||||
@@ -504,6 +504,20 @@ class Settings(DikteTest):
|
||||
self.assertEqual(conf["transcribe_model"], "gpt-4o-transcribe")
|
||||
self.assertEqual(conf["groq_transcribe_model"], "whisper-large-v3")
|
||||
|
||||
def test_the_subtitle_model_is_saved_and_only_shown_for_openrouter(self):
|
||||
self.write_config({"transcribe_provider": "openrouter",
|
||||
"openrouter_subtitle_model": "openai/whisper-large-v3"})
|
||||
conf = cfg.Config()
|
||||
window = self.window(conf)
|
||||
self.assertEqual(window.subtitle_model.currentText(), "openai/whisper-large-v3")
|
||||
self.assertTrue(window.stt_form.isRowVisible(window.subtitle_model_row))
|
||||
window.subtitle_model.setCurrentText(" deepgram/nova-3 ")
|
||||
window._save()
|
||||
self.assertEqual(conf["openrouter_subtitle_model"], "deepgram/nova-3")
|
||||
window.transcribe_provider.setCurrentIndex(
|
||||
window.transcribe_provider.findData("openai"))
|
||||
self.assertFalse(window.stt_form.isRowVisible(window.subtitle_model_row))
|
||||
|
||||
def test_the_provider_box_offers_every_provider_config_knows(self):
|
||||
window = self.window(cfg.Config())
|
||||
offered = [window.transcribe_provider.itemData(i)
|
||||
|
||||
Reference in New Issue
Block a user