知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
feat(linux): a Turn on mic button in Live notes and the top-bar menu replaces Listen to, and people at the table are heard over music and with headphones on
wqugurud950c74695e4
diff --git a/linux/cicada/app/debug.py b/linux/cicada/app/debug.pyindex bb315de..f43e17b 100644--- a/linux/cicada/app/debug.py+++ b/linux/cicada/app/debug.py@@ -21,6 +21,7 @@ from __future__ import annotationsimport osimport socketimport threading+import timefrom gi.repository import GLib@@ -132,8 +133,9 @@ def command(app, line: str) -> dict:"pending": listen.pending, "problem": listen.problem, "problemKind": listen.problem_kind, "heardSeconds": round(listen.heard_seconds, 1),"peak": round(listen.peak, 4), "notes": {"title": n.title, "topics": len(n.topics), "status": app.notes.status, "final": n.final},"key": app.ling.key_state, "ai": _ai(app), "view": app.settings.view, "listenSource": app.settings.listenSource,+ "mic": app.mic_on,"hybrid": {"roomSide": listen.hears_room_too, "echoCancel": app.echo.on, "gated": listen.gated,- "note": app.hybrid_note(), "onlinePrompt": app.online_prompt},+ "echo": listen.echo_gate.echo, "music": listen.echo_gate.playing_music(time.monotonic())},"target": app.settings.target_code,"ui": __import__("cicada.core.strings", fromlist=["language"]).language, "records": len(app.store.all()),"tray": app.tray is not None, "home": Paths.data(),@@ -185,12 +187,15 @@ def command(app, line: str) -> dict:if cmd == "settings-ai":app.show_settings(ai=True)return {"ok": True}- if cmd == "listen-source": # 听哪里 (system|room|both), mid-meeting too- app.set_listen_source(arg)- return {"ok": True, "listenSource": app.settings.listenSource, "source": listen.source_kind}- if cmd == "online": # answer 线上也有人? (both|no)- app.answer_online(arg == "both")- return {"ok": True, "listenSource": app.settings.listenSource}+ if cmd in ("mic", "listen-source"): # 打开麦克风 (on|off); listen-source both|room|system, the old names+ app.set_mic(arg in ("on", "both", "room"))+ return {"ok": True, "mic": app.mic_on, "source": listen.source_kind}+ if cmd == "room-echo-sim": # pretend the speakers do (on) or don't (off) reach the room mic; real+ listen.echo_gate.forced = None if arg in ("", "real") else arg != "off"+ return {"ok": True, "echo": listen.echo_gate.echo}+ if cmd == "room-echo": # the sound server's echo cancellation for the room mic (on|off), next start+ app.room_echo_cancel = arg == "on"+ return {"ok": True}if cmd == "room-mic-force": # any source as the room mic, e.g. a null sink's monitor ("" = off)app.forced_room_mic = arg or Nonereturn {"ok": True, "forced": app.forced_room_mic}diff --git a/linux/cicada/app/main.py b/linux/cicada/app/main.pyindex 802f4d0..e75b2a3 100644--- a/linux/cicada/app/main.py+++ b/linux/cicada/app/main.py@@ -83,8 +83,10 @@ class Controller:self.room = VirtualMic()# 电脑和会议室: the online voices taken out of the room mic (module-echo-cancel).self.echo = EchoCanceller()- self.online_prompt = None # 线上也有人?: the meeting app in a call, while only the room is heard- self.online_answered = False+ # Debug (roomEcho on): the room mic through the canceller. Off by default, as on the Mac: there+ # the system's echo cancellation let no echo through but lost most of what the table said;+ # the measured gate (roommic.EchoGate) and EchoMatch are what's left on by default.+ self.room_echo_cancel = Falseself.headset_default = False # the default input is a Bluetooth headset's (the room uses another mic)self.forced_room_mic = Noneself.speak = SpeakEngine(self.ling, self.translator, self.settings, self.store, self.listen, player=lambda: Player())@@ -462,25 +464,28 @@ class Controller:Log.d("room mic: none, listening to the computer instead")return SystemAudio(), "system"- def set_listen_source(self, value: str) -> None:- """听哪里 changed, from the tray, the notes window or 设置; mid-meeting the same meeting goes on- from the new source."""- if value not in AppSettings.SOURCES or value == self.settings.listenSource:+ @property+ def mic_on(self) -> bool:+ return self.settings.listenSource == "both"++ def set_mic(self, on: bool) -> None:+ """打开麦克风 / 关闭麦克风, from the tray, the notes window or the debug pipe (the Mac's setMic):+ the computer's audio is always heard, the mic adds the room to the same meeting. Not kept for+ the next launch; turning it on while nothing is heard starts listening."""+ value = "both" if on else "system"+ if value == self.settings.listenSource:+ if on and not self.listen.listening:+ self.start_listening(*self.heard_source())returnself.settings.listenSource = value- self.settings.save()- Log.d("listenSource=%s" % value)+ Log.d("mic %s" % ("on" if on else "off"))if self.listen.listening and self.listen.source_kind != "file":- if self.listen.hears_room_too:+ if on:+ self._start_room_side()+ else:self._stop_room_side()- # The canceller first: it changes the default output, which the computer's audio is read from.- room = self._room_side_source() if value == "both" else None- source, kind = self.heard_source()- source.on_ended = self._source_ended(kind)- self.listen.source_kind = kind- self.listen.attach(source, mic=kind == "room")- if room is not None:- self.listen.start_room(*room)+ elif on and not self.listen.listening:+ self.start_listening(*self.heard_source())self.changed()def _room_side_source(self):@@ -494,12 +499,12 @@ class Controller:default = capture.default_source()bt = [i.name for i in roommic.parse_sources(capture.sources_text()) if i.bluetooth]self.headset_default = (self.room.real_mic if default == "cicada_mic" else default) in bt- cancelled = None if self.settings.speakHeadphones else self.echo.create(mic)- if cancelled is None and not self.settings.speakHeadphones:- Log.d("hybrid: no echo cancellation, gating the room mic")+ cancelled = self.echo.create(mic) if self.room_echo_cancel else None+ if cancelled is None:+ Log.d("hybrid: the room mic, gated while the computer plays speech that reaches it")source = SystemAudio(cancelled or mic, L("知了 · 会议室"))source.on_ended = self._room_lost- return source, cancelled is None and not self.settings.speakHeadphones+ return source, cancelled is Nonedef _start_room_side(self) -> None:room = self._room_side_source()@@ -524,30 +529,12 @@ class Controller:self.echo.remove()def set_headphones(self, on: bool) -> None:- """戴着耳机 (同声传译's and 会议室's): in 电脑和会议室 the room side starts again with or without- taking the speakers' sound out."""+ """戴着耳机 (同声传译's): whether a sentence said while they talk may be their voice from the+ speakers. The room mic measures that for itself (roommic.EchoGate)."""if on == self.settings.speakHeadphones:returnself.settings.speakHeadphones = onself.settings.save()- if self.listen.listening and self.listen.hears_room_too:- self._stop_room_side()- self._start_room_side()- self.changed()-- def hybrid_note(self) -> str | None:- """The grey line under 听哪里 in 电脑和会议室 (roommic.hybrid_note)."""- key = roommic.hybrid_note(self.listen.hears_room_too, self.echo.on, self.settings.speakHeadphones,- self.headset_default)- return L(key) if key == "线上有人说话时,先不听会议室" else L("用电脑自带的麦克风听会议室") if key else None-- def answer_online(self, both: bool) -> None:- """线上也有人? answered: 也听电脑 turns 电脑和会议室 on in the same meeting; 不用 just goes."""- self.online_answered = True- self.online_prompt = None- Log.d("online prompt: %s" % ("both" if both else "no"))- if both:- self.set_listen_source("both")self.changed()def _source_ended(self, kind: str):@@ -633,8 +620,6 @@ class Controller:self.auto_ended = Falseself.ending = Noneself.end_watch = meeting_end.MeetingEndWatch(self.end_config(), time.time())- self.online_answered = False- self.online_prompt = Noneself.notices.start()room = self._room_side_source() if kind == "both" else Noneself.listen.start(source, kind, mic=kind == "room")@@ -734,12 +719,6 @@ class Controller:s = self.store.get(self.listen.session_id) if self.listen.session_id else Nonereason = w.tick(now, calls, bool(s and s.lines))self._set_ending(w.pending)- ask = roommic.asks_online(self.listen.source_kind == "room", self.online_answered, bool(calls))- prompt = next(iter(calls.values()), None) if ask else None- if prompt != self.online_prompt:- self.online_prompt = prompt- Log.d("online prompt: %s" % ("shown" if prompt else "gone"))- self.changed()if reason is not None:self._auto_end(reason, w)elif not self.listen.listening and self.auto_ended and self.settings.endWithApp and calls:@@ -846,7 +825,6 @@ class Controller:self.auto_ended = auto# stop() waits for Ming's last replies: off the main loop.- self.online_prompt = Nonedef run():sid = self.listen.session_iddiff --git a/linux/cicada/app/notes_window.py b/linux/cicada/app/notes_window.pyindex ef267a6..6254a2c 100644--- a/linux/cicada/app/notes_window.py+++ b/linux/cicada/app/notes_window.py@@ -312,72 +312,25 @@ class NotesWindow(Gtk.Window):self._fill_source()def _fill_source(self) -> None:+ """麦克风 under the header (the Mac's 打开麦克风 beside 结束: here the header's mic icon is+ 同声传译's): what the mic does now, and the button that turns it on or off."""row = self.source_rowui.clear(row)listen = self.app.listenif not listen.listening or listen.source_kind == "file" or self.subtitles:- self.source_open = Falserow.hide()return- from .tray import sources- names = dict(sources())- line = ui.hbox(6, ui.text(names.get(self.app.settings.listenSource, ""), 12, "secondary", wrap=False))- change = ui.link(L("换") + (" ⌃" if self.source_open else " ⌄"), self._toggle_sources)- change.set_can_focus(False)- line.pack_start(change, False, False, 0)+ on = self.app.mic_on+ line = ui.hbox(8, ui.text(L("桌边的人说话也会记下") if on else L("关着 · 只听电脑声音"), 12, "secondary", wrap=False))+ b = ui.button(L("关闭麦克风") if on else L("打开麦克风"), lambda: self.app.set_mic(not on),+ "outline" if on else "darkbtn", "audio-input-microphone-symbolic")+ b.set_can_focus(False)+ line.pack_end(b, False, False, 0)row.pack_start(line, False, False, 0)- if self.source_open:- row.pack_start(self._source_choices(), False, False, 0)- # How the room is heard when it isn't the plain way (one grey line, the Mac's HybridNote).- note = self.app.hybrid_note()- if note:- row.pack_start(ui.text(note, 11, "tertiary", width_chars=40), False, False, 0)- # 线上也有人?: only the room is heard while a meeting app here is in a call.- app_name = self.app.online_prompt- if app_name:- strip = ui.vbox(8, ui.vbox(2, ui.text(L("线上也有人?"), 13, "ink", bold=True, wrap=False),- ui.text(LF("%@ 正在通话", app_name), 12, "secondary", wrap=False)))- buttons = ui.hbox(8, ui.button(L("也听电脑"), lambda: self.app.answer_online(True), "darkbtn"),- ui.button(L("不用"), lambda: self.app.answer_online(False), "outline"))- for b in buttons.get_children():- b.set_can_focus(False)- strip.pack_start(buttons, False, False, 0)- row.pack_start(ui.gap(ui.panel(ui.pad(strip, 12, 14), "endingstrip"), 4), False, False, 0)for c in row.get_children():c.show_all()row.show() # show_all() skips a no_show_all widget itself- source_open = False-- def _toggle_sources(self, on: bool | None = None) -> None:- self.source_open = (not self.source_open) if on is None else on- self._fill_source()-- def _source_choices(self) -> Gtk.Widget:- """听哪里's choices in place, under 换 (as the meeting's language card): a Gtk.Menu popped from- this window, which never takes the focus, came up blank and stopped the app taking input."""- from .tray import sources- box = ui.vbox(0)- for value, label in sources():- def pick(v=value):- self.source_open = False- if v == self.app.settings.listenSource:- self._fill_source()- else:- self.app.set_listen_source(v)- b = Gtk.Button()- current = value == self.app.settings.listenSource- inner = ui.hbox(8, ui.text(label, 13, "ink", bold=current, wrap=False))- if current:- tick = ui.icon("object-select-symbolic", 12)- inner.pack_end(tick, False, False, 0)- b.add(ui.pad(inner, 7, 12))- ui.classes(b, "linkrow")- b.set_can_focus(False)- b.connect("clicked", lambda *_, f=pick: f())- box.pack_start(b, False, False, 0)- return ui.panel(ui.pad(box, 4, 0), "notice")-# 纪要 / 文字记录, side by sidedef _layout(self) -> None:diff --git a/linux/cicada/app/settings_window.py b/linux/cicada/app/settings_window.pyindex 9b47ed9..a486248 100644--- a/linux/cicada/app/settings_window.py+++ b/linux/cicada/app/settings_window.py@@ -422,7 +422,6 @@ class SettingsWindow(Gtk.Window):def phones_toggled(sw, _p):self.app.set_headphones(sw.get_active())- self.room_phones.set_active(sw.get_active()) # 会议室's 戴着耳机 is the same settingphones.connect("notify::active", phones_toggled)self.speak_phones = phonesphones_row = ui.prow(L("戴着耳机"), phones, L("和对方同时说的话也会传出去"))@@ -443,13 +442,12 @@ class SettingsWindow(Gtk.Window):return ui.vbox(6, self._group(L("同声传译"), ui.boxed(rows)), ui.pad(self.speak_status, 0, 4, 0, 4))def _room_group(self):- """会议室: 听哪里, and the microphone that hears the room (自动 picks as roommic.pick does)."""+ """会议室: the microphone 打开麦克风 hears the room with (自动 picks as roommic.pick does). Whether+ it hears the speakers is measured (roommic.EchoGate), not asked."""from ..core import roommicfrom . import capture- from .tray import sourcesapp = self.apps = app.settings- where = choice(sources(), s.listenSource, app.set_listen_source)inputs = [i for i in roommic.parse_sources(capture.sources_text()) if not i.virtual]default = capture.default_source()if default == "cicada_mic":@@ -464,19 +462,8 @@ class SettingsWindow(Gtk.Window):if s.roomMic and all(v != s.roomMic for v, _ in options):options.append((s.roomMic, s.roomMic)) # chosen before, not plugged in nowmic = choice(options, s.roomMic, set_mic)- # 戴着耳机, the same setting as 同声传译's: nothing comes out of the speakers, so no echo to take out.- phones = Gtk.Switch()- phones.set_active(s.speakHeadphones)- phones.set_valign(Gtk.Align.CENTER)- def toggled(sw, _p):- app.set_headphones(sw.get_active())- if getattr(self, "speak_phones", None) is not None:- self.speak_phones.set_active(sw.get_active())- phones.connect("notify::active", toggled)- self.room_phones = phones- rows = [ui.prow(L("听哪里"), where), ui.prow(L("麦克风"), mic, L("戴着蓝牙耳机时,自动用电脑自带的麦克风")),- ui.prow(L("戴着耳机"), phones, L("戴着就不用防回声,桌边的话不会被丢;和同声传译共用这个开关"))]- return self._group(L("会议室"), ui.boxed(rows)), [where, mic]+ rows = [ui.prow(L("麦克风"), mic, L("戴着蓝牙耳机时,自动用电脑自带的麦克风"))]+ return self._group(L("会议室"), ui.boxed(rows)), [mic]def _group(self, title, body, footer=None) -> Gtk.Widget:box = ui.vbox(6, ui.pad(ui.text(title, 12, "group-title", bold=True, wrap=False), 0, 0, 0, 2), body)diff --git a/linux/cicada/app/tray.py b/linux/cicada/app/tray.pyindex e49e24a..92986ca 100644--- a/linux/cicada/app/tray.py+++ b/linux/cicada/app/tray.py@@ -93,17 +93,12 @@ class Tray:self.detail_item = Nonemenu.append(Gtk.SeparatorMenuItem())item(L("结束") if listening else L("开始听"), self.app.request_stop)- # 听哪里, the Mac panel's choice: changed mid-meeting, the same meeting goes on.+ # 麦克风, the Mac panel's 打开麦克风: on mid-meeting, the room joins the same meeting.if self.app.listen.source_kind != "file" or not listening:- menu.append(Gtk.SeparatorMenuItem())- item(L("听哪里"), None, False)- first = None- for value, label in sources():- r = Gtk.RadioMenuItem.new_with_label_from_widget(first, label)- first = first or r- r.set_active(value == self.app.settings.listenSource)- r.connect("toggled", lambda w, v=value: w.get_active() and self.app.set_listen_source(v))- menu.append(r)+ mic = Gtk.CheckMenuItem.new_with_label(L("麦克风"))+ mic.set_active(self.app.mic_on)+ mic.connect("toggled", lambda w: self.app.set_mic(w.get_active()))+ menu.append(mic)menu.append(Gtk.SeparatorMenuItem())if self.app.settings.speakEnabled:item(L("停止说") if self.app.speak.active else L("开始说"), self.app.toggle_speaking)@@ -160,13 +155,6 @@ class Tray:self.lib.app_indicator_set_label(self.ind, self._clock().encode(), b"")-def sources() -> list:- """听哪里's choices, as the tray, the notes window and 设置 list them."""- from ..core.settings import AppSettings- names = {"system": L("电脑声音"), "room": L("会议室"), "both": L("电脑和会议室")}- return [(v, names[v]) for v in AppSettings.SOURCES]--def badged_icon(icon: str) -> str | None:"""A copy of the app icon (an SVG, 100 units square) with the accent dot over its top rightcorner and a white ring around it, written once under the data folder. The logo itself staysdiff --git a/linux/cicada/core/listen.py b/linux/cicada/core/listen.pyindex 7281f5c..ce5789b 100644--- a/linux/cicada/core/listen.py+++ b/linux/cicada/core/listen.py@@ -221,8 +221,11 @@ class ListenEngine:# Silence rather than nothing keeps the segmenter's clock in step.buf = array("h", bytes(len(buf) * 2))now = time.monotonic()- if lane is not self._main and self.gated and self.echo_gate.closed(now):- buf = array("h", bytes(len(buf) * 2))+ if lane is not self._main and self.gated:+ # What the mic really hears, for EchoGate's measurement, before any silencing.+ self.echo_gate.room_level(Wav.rms(buf), seconds, now)+ if self.echo_gate.closed(now):+ buf = array("h", bytes(len(buf) * 2))level = Wav.rms(buf)gate = lane.gateif gate is not None:@@ -420,6 +423,8 @@ class ListenEngine:else:self._record(lane, seg, heard)self._heard_online(heard.original, seg.seconds)+ if heard.original.strip(): # speech, which the room mic is silenced for (EchoGate)+ self.echo_gate.heard_words(time.monotonic())if ready:self._changed()diff --git a/linux/cicada/core/roommic.py b/linux/cicada/core/roommic.pyindex bdae471..f57d94d 100644--- a/linux/cicada/core/roommic.py+++ b/linux/cicada/core/roommic.py@@ -5,6 +5,8 @@ from __future__ import annotationsimport threading+from .support import Log+# Sources Cicada makes itself (app/room.py's 知了 麦克风), never a room microphone.OURS = ("cicada_mic",)@@ -144,43 +146,108 @@ def place_starts(lines) -> set:return out-def asks_online(room_only: bool, answered: bool, in_call: bool) -> bool:- """线上也有人?: listening to the room alone while a meeting app here is in a call, so people online- are likely speaking through it. Once a meeting (the Mac's RoomPrompt.asksOnline)."""- return room_only and not answered and in_call---def hybrid_note(room_running: bool, echo_cancelled: bool, headphones: bool, headset_default: bool):- """The grey line under 听哪里 in 电脑和会议室, when the room isn't heard the plain way (the Mac's- HybridNote): without echo cancellation the room pauses while the computer plays speech; with a- Bluetooth headset as the default input the computer's own mic hears the room. The string's key."""- if not room_running:- return None- if not echo_cancelled and not headphones:- return "线上有人说话时,先不听会议室"- if headset_default:- return "用电脑自带的麦克风听会议室"- return None--class EchoGate:- """电脑和会议室 without echo cancellation: while the computer plays speech, the room mic hears it- again from the speakers. Listening `hold`s the gate on every loud block of the computer's audio;- the room mic hears silence until `hang` after the last one (the speakers' tail, the room's echo)."""+ """打开麦克风 while the computer plays a meeting, without the sound server's echo cancellation: the+ room mic hears the remote voices again from the speakers (the Mac's EchoGate, same rules). The+ room mic hears silence while the computer plays speech, until `hang` after it, but only when+ that is needed and only for speech:++ - Echo is measured: the room mic's loud end while the computer is loud over its floor while the+ computer is quiet. Headphones or a meeting mic leave it where it was, and then nothing is+ silenced, so people at the table are heard over a remote speaker too. Until there is enough+ to tell (and whenever it is unclear) the speakers are taken to echo.+ - Music isn't speech: a loud stretch the computer's side has recognized no words in for `music`+ seconds stops closing the gate; words close it again. Longer than the Mac's 4 s: here words+ only come back after a whole segment has gone to the service."""hang = 0.4+ music = 20.0+ stretch_gap = 1.5+ during = 0.15 # computer audio this recent makes a room block "during"+ quiet_after = 1.0 # …this long ago, "the computer is quiet"+ echo_ratio = 3.0 # at or over: echo; under clear_ratio: none+ clear_ratio = 2.0+ enough = 3.0 # seconds of each a decision needs+ window = 20.0def __init__(self):self._lock = threading.Lock()self._until = 0.0+ self._last_loud = float("-inf")+ self._stretch_start = float("-inf")+ self._last_words = float("-inf")+ self._during: list = [] # (t, rms, seconds) while the computer is loud+ self._quiet: list = []+ self._echo = True+ self.forced = None # debug (roomEchoSim): pretend the measurement says this++ @property+ def echo(self) -> bool:+ with self._lock:+ return self._echo if self.forced is None else self.forced++ def _music(self, now: float) -> bool:+ return (now - self._last_loud <= self.stretch_gap and now - self._stretch_start >= self.music+ and self._last_words < now - self.music)++ def playing_music(self, now: float) -> bool:+ with self._lock:+ return self._music(now)def hold(self, now: float) -> None:+ """A loud block of the computer's audio."""with self._lock:+ if now - self._last_loud > self.stretch_gap:+ self._stretch_start = now+ self._last_loud = now+ echo = self._echo if self.forced is None else self.forced+ if self._music(now) or not echo:+ returnself._until = max(self._until, now + self.hang)+ def heard_words(self, now: float) -> None:+ with self._lock:+ self._last_words = now+def closed(self, now: float) -> bool:with self._lock:return now < self._until+ def room_level(self, rms: float, seconds: float, now: float) -> None:+ """A block of what the room mic heard, before any silencing."""+ with self._lock:+ since = now - self._last_loud+ if since <= self.during:+ self._during.append((now, rms, seconds))+ elif since >= self.quiet_after:+ self._quiet.append((now, rms, seconds))+ else:+ return+ self._during = [b for b in self._during if b[0] >= now - self.window]+ self._quiet = [b for b in self._quiet if b[0] >= now - self.window * 3]+ r = self.ratio([(b[1], b[2]) for b in self._during], [(b[1], b[2]) for b in self._quiet])+ if r is None:+ return+ was = self._echo+ if r >= self.echo_ratio:+ self._echo = True+ elif r < self.clear_ratio:+ self._echo = False+ if was != self._echo:+ Log.d("room echo: %s (x%.1f)" % ("speakers reach the mic" if self._echo else "none", r))+ if not self._echo:+ self._until = 0.0++ @classmethod+ def ratio(cls, during: list, quiet: list):+ """The room mic's loud end (a fifth of it louder) while the computer is loud over its floor+ (the quietest fifth) while it is quiet, or None without `enough` of both. People at the table+ talking over the computer raise it too: that errs on the side of echo."""+ if sum(s for _, s in during) < cls.enough or sum(s for _, s in quiet) < cls.enough:+ return None+ d = sorted(r for r, _ in during)+ q = sorted(r for r, _ in quiet)+ return d[len(d) * 4 // 5] / max(q[len(q) // 5], 0.0002)+class Heard:def __init__(self, text: str, start: float, end: float):diff --git a/linux/cicada/core/settings.py b/linux/cicada/core/settings.pyindex 4f89b62..81ee64c 100644--- a/linux/cicada/core/settings.py+++ b/linux/cicada/core/settings.py@@ -42,9 +42,9 @@ class AppSettings:"speakTo": "room", # what the room hears; "room" = the language they have been speaking"speakVoices": {}, # Ming voice per language key ("en": "US_Emma")"speakHeadphones": False, # 戴着耳机: skip the echo guard, talking over them is fine- # 听哪里 (the Mac's listenSource): "system" (what the computer plays), "room" (a real- # microphone, for a meeting in the room) or "both" (电脑和会议室: people online and in the- # room, each heard on its own); roomMic: the room's microphone, "" = 自动.+ # 打开麦克风 (the Mac's listenSource): "both" while the mic is on (people online and in the+ # room, each heard on its own), else "system"; never kept for the next launch. roomMic: the+ # room's microphone, "" = 自动."listenSource": "system","roomMic": "",# 结束会议 (meeting_end.py), the Mac's keys: end when the meeting app hangs up; when nobody@@ -116,8 +116,8 @@ class AppSettings:# 纪要语言 was "system" or a language code before it took the Mac's two choices.if kw.get("notesLanguage") not in (None, "mine", "source"):kw["notesLanguage"] = "mine"- if kw.get("listenSource") not in (None,) + AppSettings.SOURCES:- kw["listenSource"] = "system"+ # Every launch starts with the microphone off.+ kw.pop("listenSource", None)return AppSettings(**kw)except OSError as e:Log.d("settings: unreadable, defaults used (%s)" % type(e).__name__)diff --git a/linux/strings/en.lproj/Linux.strings b/linux/strings/en.lproj/Linux.stringsindex c4b8b80..e534473 100644--- a/linux/strings/en.lproj/Linux.strings+++ b/linux/strings/en.lproj/Linux.strings@@ -180,15 +180,10 @@"文字 %@ 秒" = "text %@ s";"听 %@ 秒" = "hearing %@ s";"知了 · 会议室" = "Cicada · Room";-"换" = "Change";"正在用麦克风听会议室,有人说话后约 3 秒出字幕" = "Listening to the room through the microphone. Subtitles appear about 3 s after someone speaks";"戴着蓝牙耳机时,自动用电脑自带的麦克风" = "With a Bluetooth headset on, Auto uses the computer's own mic";-"用电脑自带的麦克风听会议室" = "Hearing the room with the computer's own mic";"知了 · 防回声" = "Cicada · Echo Cancellation";-"戴着就不用防回声,桌边的话不会被丢;和同声传译共用这个开关" = "With headphones on there's no echo to remove, so nothing said at the table is lost. Shared with Interpreting";"电脑和会议室" = "Computer + Room";-"电脑声音" = "This computer";-"也听电脑" = "Hear the computer too";"电脑里放出来的" = "Played by the computer";/* The proxy hint for GNOME's proxy (proxy.py). */"代理 %@ 没有回应。打开代理软件,或在 设置 › 网络 › 网络代理 里改正。" = "The proxy %@ doesn’t answer. Open your proxy app, or fix it in Settings › Network › Network Proxy.";diff --git a/linux/strings/ja.lproj/Linux.strings b/linux/strings/ja.lproj/Linux.stringsindex b623e5b..e8d6f8e 100644--- a/linux/strings/ja.lproj/Linux.strings+++ b/linux/strings/ja.lproj/Linux.strings@@ -180,15 +180,10 @@"文字 %@ 秒" = "テキスト %@ 秒";"听 %@ 秒" = "聞き取り %@ 秒";"知了 · 会议室" = "知了 · 会議室";-"换" = "変更";"正在用麦克风听会议室,有人说话后约 3 秒出字幕" = "マイクで会議室を聞いています。話し始めて約 3 秒で字幕が出ます";"戴着蓝牙耳机时,自动用电脑自带的麦克风" = "Bluetooth ヘッドセット使用中は、自動でパソコン内蔵のマイクを使います";-"用电脑自带的麦克风听会议室" = "パソコン内蔵のマイクで会議室を聞いています";"知了 · 防回声" = "知了 · エコー除去";-"戴着就不用防回声,桌边的话不会被丢;和同声传译共用这个开关" = "ヘッドホン使用中はエコー除去が不要になり、会議室の発言も落ちません。同時通訳と共通の設定です";"电脑和会议室" = "パソコンと会議室";-"电脑声音" = "このパソコン";-"也听电脑" = "パソコンも聞く";"电脑里放出来的" = "パソコンから流れた";/* The proxy hint for GNOME's proxy (proxy.py). */"代理 %@ 没有回应。打开代理软件,或在 设置 › 网络 › 网络代理 里改正。" = "プロキシ %@ が応答しません。プロキシアプリを開くか、設定 › ネットワーク › ネットワークプロキシ で直してください。";diff --git a/linux/strings/ko.lproj/Linux.strings b/linux/strings/ko.lproj/Linux.stringsindex d9f95f8..79c3ce3 100644--- a/linux/strings/ko.lproj/Linux.strings+++ b/linux/strings/ko.lproj/Linux.strings@@ -180,15 +180,10 @@"文字 %@ 秒" = "텍스트 %@초";"听 %@ 秒" = "듣기 %@초";"知了 · 会议室" = "Cicada · 회의실";-"换" = "변경";"正在用麦克风听会议室,有人说话后约 3 秒出字幕" = "마이크로 회의실을 듣고 있습니다. 말하면 약 3초 뒤 자막이 나옵니다";"戴着蓝牙耳机时,自动用电脑自带的麦克风" = "블루투스 헤드셋을 쓰는 동안 자동으로 컴퓨터 내장 마이크를 씁니다";-"用电脑自带的麦克风听会议室" = "컴퓨터 내장 마이크로 회의실을 듣고 있습니다";"知了 · 防回声" = "Cicada · 에코 제거";-"戴着就不用防回声,桌边的话不会被丢;和同声传译共用这个开关" = "헤드폰을 쓰면 에코 제거가 필요 없어 회의실의 말도 빠지지 않습니다. 동시통역과 같은 설정입니다";"电脑和会议室" = "컴퓨터와 회의실";-"电脑声音" = "이 컴퓨터";-"也听电脑" = "컴퓨터도 듣기";"电脑里放出来的" = "컴퓨터에서 재생된 말";/* The proxy hint for GNOME's proxy (proxy.py). */"代理 %@ 没有回应。打开代理软件,或在 设置 › 网络 › 网络代理 里改正。" = "프록시 %@이(가) 응답하지 않아요. 프록시 앱을 열거나 설정 › 네트워크 › 네트워크 프록시에서 고치세요.";diff --git a/linux/tests/test_hybrid.py b/linux/tests/test_hybrid.pyindex e956aa7..135615a 100644--- a/linux/tests/test_hybrid.py+++ b/linux/tests/test_hybrid.py@@ -12,7 +12,7 @@ from cicada.core.ling import LingClientfrom cicada.core.listen import ROOM_IDS, ListenEnginefrom cicada.core.models import TranscriptLinefrom cicada.core.notes import NotesEngine-from cicada.core.roommic import (EchoGate, EchoMatch, Heard, Input, VoiceGate, asks_online, heard_both, hybrid_note, parse_sources,+from cicada.core.roommic import (EchoGate, EchoMatch, Heard, Input, VoiceGate, heard_both, parse_sources,pick, place_starts)from cicada.core.session_store import SessionStorefrom cicada.core.settings import AppSettings@@ -234,19 +234,45 @@ class Places(Base):ls = [line("a"), line("b"), line("c", via="room"), line("d", "me"), line("e", via="room"), line("f")]self.assertEqual({"a", "c", "e", "f"}, place_starts(ls))- def test_online_prompt_asks_only_in_the_room_during_a_call(self):- self.assertTrue(asks_online(True, False, True))- self.assertFalse(asks_online(True, False, False))- self.assertFalse(asks_online(True, True, True))- self.assertFalse(asks_online(False, False, True))-- def test_note_says_how_the_room_is_heard(self):- self.assertIsNone(hybrid_note(True, True, False, False))- self.assertIsNone(hybrid_note(False, False, False, True))- self.assertEqual("线上有人说话时,先不听会议室", hybrid_note(True, False, False, True))- self.assertEqual("用电脑自带的麦克风听会议室", hybrid_note(True, True, False, True))- # 戴着耳机: nothing to cancel, nothing paused.- self.assertIsNone(hybrid_note(True, False, True, False))+ def test_music_stops_closing_the_gate(self):+ g = EchoGate()+ t = 0.0+ while t < EchoGate.music - 1:+ g.hold(t)+ t += 0.1+ self.assertTrue(g.closed(t)) # no words yet: still taken for speech+ while t < EchoGate.music + 1:+ g.hold(t)+ t += 0.1+ self.assertTrue(g.playing_music(t))+ t += EchoGate.hang + 0.01+ g.hold(t)+ self.assertFalse(g.closed(t + 0.01))+ g.heard_words(t + 0.1) # someone talks over it: words close it again+ g.hold(t + 0.2)+ self.assertTrue(g.closed(t + 0.3))++ def _play(self, g, start, level):+ t = start+ for _ in range(60):+ g.hold(t)+ g.room_level(level, 0.1, t + 0.05)+ t += 0.1+ for _ in range(60):+ t += 0.1+ g.room_level(0.001, 0.1, t)+ return t++ def test_headphones_keep_the_room_open(self):+ g = EchoGate()+ self.assertTrue(g.echo) # until measured+ t = self._play(g, 0, 0.001)+ self.assertFalse(g.echo)+ g.hold(t + 1)+ self.assertFalse(g.closed(t + 1.1))+ self._play(g, t + 100, 0.03) # the speakers reach the mic again+ self.assertTrue(g.echo)+ self.assertIsNone(EchoGate.ratio([(0.001, 1)], [(0.001, 10)]))ONLINE = "Revenue grew by 12%, mostly from the new region."