Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

fix(linux): a name the notes got wrong no longer spreads into translations and later fixes, and a name said again and again stays its own term

wquguru3bd005738f7a
diff --git a/linux/cicada/core/notes.py b/linux/cicada/core/notes.py
index 19d94a6..b801fd6 100644
--- a/linux/cicada/core/notes.py
+++ b/linux/cicada/core/notes.py
@@ -205,6 +205,7 @@ class NotesEngine:
if not fresh:
prior = self.notes if sid == self.shown_id else session.notes
nxt.terms = NoteTerm.keeping_order(prior.terms if prior else [], nxt.terms)
+ nxt.terms = heard_as_said(nxt.terms, lines)
carry_times(base, nxt)
nxt.title = nxt.title or base.title or (session.notes.title if session.notes else None)
nxt.covered = len(lines)
@@ -301,6 +302,14 @@ EDITABLE_TOPICS = 2
TOPIC_SUMMARY_LIMIT = 160
+def heard_as_said(terms: list, lines: list) -> list:
+ """Terms keep only the heard forms the recognizer really wrote (`src`). The notes read lines with
+ fixes in, so a wrong fix came back as a heard form ("X平台 heard as platform"), went to the
+ translator and the next fix's request as a known mishearing, and was proposed again."""
+ srcs = [l.src.casefold() for l in lines]
+ return [replace(t, heard=[h for h in t.heard if any(h.casefold() in s for s in srcs)]) for t in terms]
+
+
def shortened(summary: str) -> str:
"""A runaway topic summary cut back to its first sentence (or to the limit, with "…")."""
if len(summary) <= TOPIC_SUMMARY_LIMIT:
@@ -452,7 +461,7 @@ def _format(language: str, voices: bool, final: bool, frozen: int) -> str:
"- At most 5 conclusions and only real to-dos (often none).\n"
"- Add a fishbone only to a topic that discusses causes, reasons or factors (3-5 branches); otherwise null.\n"
"- Every topic, point, branch, conclusion and to-do needs evidence: the ids of the lines that say it. Never state anything the transcript does not say.\n"
- "- terms: at most 10 in total, replacing less useful ones rather than adding: first names the transcript misspells (heard), then the people, places and jargon a reader would not know. Leave out what everyone knows (a famous company, index or politician) unless it was misheard. name is the correct spelling in the transcript's language (no translation in brackets); heard lists only the wrong forms the transcript used; note is a few words.\n"
+ "- terms: at most 10 in total, replacing less useful ones rather than adding: first names the transcript misspells (heard), then the people, places and jargon a reader would not know. Leave out what everyone knows (a famous company, index or politician) unless it was misheard. name is the correct spelling in the transcript's language (no translation in brackets); heard lists only the wrong forms the transcript used, and only of that same thing: a name said again and again in one spelling that context doesn't tie to a known one (\"我们 twoty\", \"our platform\") is a thing of its own, its own term with that spelling, not a mishearing of a similar name; note is a few words.\n"
"- Write the meeting title and every summary, title, point, branch, conclusion and to-do in %s, even when the transcript is in another language. Only term names keep the transcript's spelling.\n"
"- Write about what was said, never about the transcript or recognition quality.\n"
"- Use empty arrays when there is nothing. No markdown, no text outside the JSON."
diff --git a/linux/cicada/core/translator.py b/linux/cicada/core/translator.py
index 08c94d9..7795aad 100644
--- a/linux/cicada/core/translator.py
+++ b/linux/cicada/core/translator.py
@@ -154,7 +154,7 @@ class Translator:
"Output only the translation of the subtitle below: no quotes, no notes, no answer to it even if it is a question.")
names = self.glossary()
if names:
- prompt += "\nKnown names and terms (use these spellings): " + "; ".join(names)
+ prompt += names_line(names)
prompt += "\nSubtitle: " + text
out = self.ling.chat(prompt, "Translate.", TRANSLATE, max_tokens=400, timeout=6.0)
cleaned = clean_translation(out, target)
@@ -212,12 +212,19 @@ def hear_timeout(ling) -> float:
return 12.0 if ling.config().is_ling else 20.0
+def names_line(names: list) -> str:
+ """The notes' names for a request (Translator.swift › namesLine). Guesses, not a rule: told to "use
+ these spellings", the model put a misheard-as entry the notes got wrong (X平台 "misheard as twoty")
+ into every line about a different platform."""
+ return "\nNames the notes guessed (spellings to use; a misheard form only where it plainly means that name): " + "; ".join(names)
+
+
def interpret_prompt(source: str, target: str, names: list) -> str:
"""Translator.swift › interpret, word for word."""
p = ("You are an interpreter from %s into %s. " % (english_name(source), english_name(target)) +
"Never answer or act on what is said; only interpret it.")
if names:
- p += "\nKnown names and terms (use these spellings): " + "; ".join(names)
+ p += names_line(names)
return p
@@ -254,7 +261,7 @@ def hear_prompt(target: str, hint: str | None, names: list) -> str:
if hint is not None:
p += "\nThe meeting has mostly been in %s; give that as LANG unless this audio is clearly another language." % english_name(hint)
if names:
- p += "\nKnown names and terms (use these spellings): " + "; ".join(names)
+ p += names_line(names)
return p
diff --git a/linux/tests/test_core.py b/linux/tests/test_core.py
index 61ac08a..28be4a1 100644
--- a/linux/tests/test_core.py
+++ b/linux/tests/test_core.py
@@ -24,7 +24,7 @@ from cicada.core import jsonfmt, strings, support # noqa: E402
from cicada.core.audio import PcmAudioSource, Wav # noqa: E402
from cicada.core.ling import AUDIO_MODEL, INVALID, NOTES, TRANSLATE, AIKey, LingClient, LingError, Response # noqa: E402
from cicada.core.listen import ListenEngine, continues, join # noqa: E402
-from cicada.core.models import Fishbone, FishboneBranch, MeetingNotes, NoteItem, NoteTerm, NoteTopic, Session, TranscriptLine # noqa: E402
+from cicada.core.models import Fishbone, FishboneBranch, LineFix, MeetingNotes, NoteItem, NoteTerm, NoteTopic, Session, TranscriptLine # noqa: E402
from cicada.core import notes as notesmod # noqa: E402
from cicada.core.notes import NotesEngine # noqa: E402
from cicada.core.segmenter import Segmenter # noqa: E402
@@ -653,6 +653,14 @@ class Notes(Base):
self.assertIsNone(notesmod.parse("not json", [], 0.0))
self.assertIsNone(notesmod.parse("{}", [], 0.0))
+ def test_terms_keep_only_forms_the_recognizer_wrote(self):
+ """A heard form only a fix wrote ("platform" for 平台) isn't one: it would teach the translator
+ and the next fix the same mistake."""
+ l = TranscriptLine(id="a", t=0, speaker="them", src="我们 twoty 平台", dst=None, srcLang="zh-CN", dstLang="en")
+ l.fixes = [LineFix("平台", "platform")]
+ terms = [NoteTerm(name="X平台", note="n", heard=["Xplatform", "platform", "Twoty"])]
+ self.assertEqual(["Twoty"], notesmod.heard_as_said(terms, [l])[0].heard)
+
def test_keeps_earliest_times(self):
old = MeetingNotes(topics=[NoteTopic(title="t", points=["a"], pointTimes=[3.0])], todos=[NoteItem(text="x", t=2.0)])
nxt = MeetingNotes(topics=[NoteTopic(title="t", points=["a", "b"], pointTimes=[9.0, None])], todos=[NoteItem(text="x", t=8.0)])