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.

feat(windows): Listen to › PC + Room hears people online and at the table together, each line marked In room or Online

wqugurub566fff397f6
diff --git a/site/changelog.json b/site/changelog.json
index 076d29b..a2bf67a 100644
--- a/site/changelog.json
+++ b/site/changelog.json
@@ -117,6 +117,14 @@
],
"title": "Windows 也能听会议室:用麦克风听桌边的人。",
"text": "托盘面板的“听哪里”选“会议室”;默认麦克风是蓝牙耳机时改用别的麦克风,按住说话时麦克风先不听;会议中途切换,同一场会议接着记。"
+ },
+ {
+ "kind": "new",
+ "platforms": [
+ "windows"
+ ],
+ "title": "Windows 的“听哪里”也有了“电脑和会议室”:线上和桌边的人一起听,每句标出现场还是线上。",
+ "text": "电脑声音和麦克风各认各的语言。Windows 上没有可用的回声消除,电脑在放人声时麦克风先不听,最后再按文字去掉重复的一句;只听会议室时会议软件开始通话,会问要不要也听电脑。"
}
]
},
diff --git a/windows/src/Cicada.Cli/Program.cs b/windows/src/Cicada.Cli/Program.cs
index 5cc62b3..5d1eb23 100644
--- a/windows/src/Cicada.Cli/Program.cs
+++ b/windows/src/Cicada.Cli/Program.cs
@@ -3,7 +3,8 @@
// cicada-cli listen <file.wav> [--target zh-CN] [--speed 1|0] [--notes]
// Plays the file into ListenEngine as if the PC were playing it, prints each line as it is
// recorded, then the record's folder. --speed 0 feeds it as fast as it can; --notes waits
-// for the final notes and prints them.
+// for the final notes and prints them. --room <mic.wav> hears that file as the room mic too
+// (电脑和会议室: two engines, the echo gate and EchoMatch); --room-only hears it alone (会议室).
// cicada-cli check the AI service's key check: state, hears, catalog sizes
// cicada-cli speak <text> <out.wav> the service's voice for <text>, as a 24 kHz WAV
// cicada-cli segments <file.wav> where the segmenter cuts (compare with ming_asr.py)
@@ -103,14 +104,16 @@ switch (args_[0])
var store = new SessionStore();
var notes = new NotesEngine(ling, store);
var engine = new ListenEngine(ling, new Translator(ling), store, notes, settings);
+ var roomFile = Opt("--room", "");
+ var roomOnly = args_.Contains("--room-only");
+ var roomEngine = roomFile.Length > 0 && !roomOnly ? new ListenEngine(ling, new Translator(ling), store, notes, settings, roomSide: true) : null;
var printed = new HashSet<string>();
var shown = new Dictionary<string, string>();
var started = DateTime.UtcNow;
- engine.Changed += () =>
+ void show()
{
- var s = store.Get(engine.SessionId!);
- if (s is null) return;
+ if (engine.SessionId is null || store.Get(engine.SessionId) is not { } s) return;
lock (shown)
{
foreach (var l in s.Lines)
@@ -119,16 +122,32 @@ switch (args_[0])
if (shown.TryGetValue(l.Id, out var before) && before == text) continue;
var tag = shown.ContainsKey(l.Id) ? "upd" : "new";
shown[l.Id] = text;
- Console.WriteLine($"[{(DateTime.UtcNow - started).TotalSeconds,5:F1}] {tag} {Languages.Clock(l.T)} {l.SrcLang,-5} {text}");
+ Console.WriteLine($"[{(DateTime.UtcNow - started).TotalSeconds,5:F1}] {tag} {Languages.Clock(l.T)} {(l.Via == "room" ? "现场" : roomEngine is null ? "" : "线上"),-2} {l.SrcLang,-5} {text}");
}
}
- };
- var source = new FileAudioSource(args_[1], double.Parse(Opt("--speed", "1"), System.Globalization.CultureInfo.InvariantCulture));
+ }
+ engine.Changed += show;
+ var speed = double.Parse(Opt("--speed", "1"), System.Globalization.CultureInfo.InvariantCulture);
+ IAudioSource source = new FileAudioSource(roomOnly ? roomFile : args_[1], speed);
+ if (roomOnly) source = new GatedSource(source);
var ended = new TaskCompletionSource();
source.Ended += _ => ended.TrySetResult();
- engine.Start(source);
- await ended.Task;
- await Task.Delay(1500);
+ engine.Start(source, room: roomOnly);
+ var roomEnded = Task.CompletedTask;
+ if (roomEngine is not null)
+ {
+ var echo = new EchoFilter(new EchoGate());
+ engine.Echo = echo; roomEngine.Echo = echo;
+ var mic = new GatedSource(new FileAudioSource(roomFile, speed)) { Silenced = () => echo.Gate.Closed };
+ var done = new TaskCompletionSource();
+ mic.Ended += _ => done.TrySetResult();
+ roomEnded = done.Task;
+ roomEngine.Changed += show;
+ roomEngine.Join(mic, engine.SessionId!, store.Get(engine.SessionId!)!.StartedAt);
+ }
+ await Task.WhenAll(ended.Task, roomEnded);
+ await Task.Delay(TimeSpan.FromSeconds(1.5 + (roomEngine is null ? 0 : EchoMatch.Hold)));
+ if (roomEngine is not null) await roomEngine.Stop();
await engine.Stop();
var id = engine.SessionId!;
if (args_.Contains("--notes"))
diff --git a/windows/src/Cicada.Core/Hybrid.cs b/windows/src/Cicada.Core/Hybrid.cs
new file mode 100644
index 0000000..2c01e49
--- /dev/null
+++ b/windows/src/Cicada.Core/Hybrid.cs
@@ -0,0 +1,137 @@
+namespace Cicada;
+
+// 电脑和会议室: the room side's echo handling, and how its lines are shown (RoomMic.swift,
+// EchoMatch.swift, RecordList.swift).
+
+/// 电脑和会议室 without echo cancellation (Windows has none we can use): while the computer plays
+/// speech, the room mic hears it again from the speakers. The computer's side `Hold`s the gate on
+/// every loud buffer; the room mic hears silence until `Hang` after the last one. Room speech over a
+/// remote speaker is lost this way; EchoMatch catches what still gets through.
+public sealed class EchoGate(Func<double>? clock = null)
+{
+ public const double Hang = 0.4;
+ /// Seconds; a monotonic clock shared with EchoMatch's times.
+ public readonly Func<double> Clock = clock ?? (() => Environment.TickCount64 / 1000.0);
+ readonly object gate = new();
+ double until = double.NegativeInfinity;
+
+ /// When the computer last played something loud.
+ public double LastLoud { get { lock (gate) return until - Hang; } }
+
+ public void Hold() { var now = Clock(); lock (gate) until = Math.Max(until, now + Hang); }
+ public bool Closed { get { var now = Clock(); lock (gate) return now < until; } }
+}
+
+/// 电脑和会议室's last line of defence against hearing a remote sentence twice: once from the
+/// computer's audio, once more from the speakers into the room mic. A room line made mostly of
+/// what the computer played around the same time is dropped (EchoMatch.swift, same numbers).
+public static class EchoMatch
+{
+ /// Times in seconds on EchoGate's clock.
+ public sealed record Heard(string Text, double Start, double End);
+
+ /// Seconds around the room line where the computer's lines count.
+ public const double Window = 3.0;
+ /// How long a room line waits for the computer's line it may echo.
+ public const double Hold = 2.5;
+ /// Share of the room line found in the computer's lines that makes it an echo.
+ public const double Contained = 0.6;
+
+ public static bool IsEcho(Heard room, IEnumerable<Heard> online)
+ {
+ var near = online.Where(o => o.End >= room.Start - Window && o.Start <= room.End + Window).ToList();
+ if (near.Count == 0) return false;
+ var r = Units(room.Text);
+ if (r.Count == 0) return false;
+ var o = near.Select(n => Units(n.Text)).ToList();
+ // A word or two ("OK", "对"): the very same words near it.
+ if (r.Count <= 2) return o.Any(x => x.SequenceEqual(r));
+ var mine = Pairs(r).ToHashSet();
+ var theirs = o.SelectMany(Pairs).ToHashSet();
+ return (double)mine.Count(theirs.Contains) / mine.Count >= Contained;
+ }
+
+ /// Lower-case words, each CJK character on its own; punctuation and spacing don't count.
+ public static List<string> Units(string text)
+ {
+ var output = new List<string>();
+ var word = new System.Text.StringBuilder();
+ foreach (var rune in text.ToLowerInvariant().EnumerateRunes())
+ {
+ if (Cjk(rune.Value))
+ {
+ if (word.Length > 0) { output.Add(word.ToString()); word.Clear(); }
+ output.Add(rune.ToString());
+ }
+ else if (System.Text.Rune.IsLetterOrDigit(rune)) word.Append(rune.ToString());
+ else if (word.Length > 0) { output.Add(word.ToString()); word.Clear(); }
+ }
+ if (word.Length > 0) output.Add(word.ToString());
+ return output;
+ }
+
+ static IEnumerable<string> Pairs(List<string> u) => u.Count < 2 ? u : Enumerable.Range(1, u.Count - 1).Select(i => u[i - 1] + " " + u[i]);
+
+ static bool Cjk(int v) => v is >= 0x3040 and <= 0x30FF or >= 0x3400 and <= 0x4DBF or >= 0x4E00 and <= 0x9FFF or >= 0xAC00 and <= 0xD7AF or >= 0xF900 and <= 0xFAFF;
+}
+
+/// The computer's recent lines, for the room side to check its own against.
+public sealed class EchoFilter(EchoGate gate)
+{
+ public readonly EchoGate Gate = gate;
+ readonly List<EchoMatch.Heard> online = [];
+
+ public void Online(EchoMatch.Heard h)
+ {
+ lock (online)
+ {
+ online.Add(h);
+ online.RemoveAll(o => o.End < h.End - 20);
+ }
+ }
+
+ public bool IsEcho(EchoMatch.Heard room) { lock (online) return EchoMatch.IsEcho(room, online); }
+
+ /// The computer played nothing loud around this room line: there is nothing for it to echo.
+ public bool Quiet(EchoMatch.Heard room) => Gate.LastLoud < room.Start - EchoMatch.Window;
+}
+
+/// 线上也有人?: listening to the room alone while a meeting app is in a call, so people online are
+/// likely speaking through it. Once a meeting.
+public static class RoomPrompt
+{
+ public static bool AsksOnline(bool roomOnly, bool answered, bool inCall) => roomOnly && !answered && inCall;
+}
+
+/// A meeting that heard both: each of the other side's lines says where (RecordList.swift).
+public static class Places
+{
+ /// The room mic and the computer's audio both brought in the other side's lines.
+ public static bool HeardBoth(IEnumerable<TranscriptLine> lines)
+ {
+ bool room = false, computer = false;
+ foreach (var l in lines)
+ {
+ if (l.Speaker != "them") continue;
+ if (l.Via == "room") room = true; else computer = true;
+ if (room && computer) return true;
+ }
+ return false;
+ }
+
+ /// The other side's lines where the place changes from the line before: their label shows again.
+ public static HashSet<string> Starts(IEnumerable<TranscriptLine> lines)
+ {
+ var output = new HashSet<string>();
+ string? last = "\0";
+ foreach (var l in lines)
+ {
+ var key = l.Speaker == "me" ? "me" : l.Via;
+ if (l.Speaker != "me" && key != last) output.Add(l.Id);
+ last = key;
+ }
+ return output;
+ }
+
+ public static string Place(TranscriptLine l) => l.Via == "room" ? Strings.L("现场") : Strings.L("线上");
+}
diff --git a/windows/src/Cicada.Core/ListenEngine.cs b/windows/src/Cicada.Core/ListenEngine.cs
index 9903896..0edeaf0 100644
--- a/windows/src/Cicada.Core/ListenEngine.cs
+++ b/windows/src/Cicada.Core/ListenEngine.cs
@@ -92,21 +92,65 @@ public sealed class ListenEngine
/// 会议室: what listening hears is a microphone (its speech line follows the room's noise).
public bool Room { get; private set; }
+ /// 电脑和会议室's room side (the Mac's `.room` role): it adds to the main engine's meeting rather
+ /// than keeping one, with its own language and pauses; its lines say `via: "room"` and their ids
+ /// start at RoomIDs, so the two never share one.
+ public bool RoomSide { get; }
+ public const int RoomIDs = 1_000_000;
+ /// 电脑和会议室: the main side holds the gate on loud audio and lists what it heard; the room
+ /// side checks its lines against that before recording them.
+ public EchoFilter? Echo { get; set; }
+ /// Seconds from the meeting's start to this side's first sample (the room side joins later).
+ double offset;
+ Channel<(Segment seg, Heard heard, double at, double queued)>? held;
+ Task? holding;
+ CancellationTokenSource? flush;
+ readonly Dictionary<int, double> emitted = [];
+
+ public ListenEngine(LingClient ling, Translator translator, SessionStore store, NotesEngine notes, AppSettings settings, bool roomSide)
+ : this(ling, translator, store, notes, settings) { RoomSide = roomSide; }
+
public void Start(IAudioSource from, bool room = false)
{
- if (Listening) return;
+ if (Listening || RoomSide) return;
var session = store.Begin();
SessionId = session.Id;
Room = room;
if (room) store.MarkRoom(session.Id);
+ Begin(from, room, 0);
+ notes.Language = () => Languages.EnglishName(settings.NotesCode);
+ notes.Begin(session.Id);
+ Log.Debug($"listen: started {session.Id} target={Target}");
+ Changed?.Invoke();
+ }
+
+ /// The room side joins the meeting `sessionId`, which began at `startedAt`.
+ public void Join(IAudioSource mic, string sessionId, DateTimeOffset startedAt)
+ {
+ if (Listening || !RoomSide) return;
+ SessionId = sessionId;
+ Room = true;
+ store.MarkRoom(sessionId);
+ Begin(mic, true, Math.Max(0, (DateTimeOffset.Now - startedAt).TotalSeconds));
+ if (Echo is { } echo)
+ {
+ held = Channel.CreateUnbounded<(Segment, Heard, double, double)>(new UnboundedChannelOptions { SingleReader = true });
+ flush = new CancellationTokenSource();
+ holding = Hold(held.Reader, echo, flush.Token);
+ }
+ Log.Debug($"listen: room side joined {sessionId} at {offset:F1}s");
+ Changed?.Invoke();
+ }
+
+ void Begin(IAudioSource from, bool room, double at)
+ {
lock (gate)
{
- done.Clear(); segments.Clear(); inFlight.Clear(); prints.Clear(); clusterer = new();
- nextToDeliver = 1; lineCount = 0; last = null; lastEnd = 0;
+ done.Clear(); segments.Clear(); inFlight.Clear(); prints.Clear(); clusterer = new(); emitted.Clear();
+ nextToDeliver = 1; lineCount = RoomSide ? RoomIDs : 0; last = null; lastEnd = 0;
hint = null; candidate = null; candidateVotes = 0; Problem = null;
}
- notes.Language = () => Languages.EnglishName(settings.NotesCode);
- notes.Begin(session.Id);
+ offset = at;
segmenter = new Segmenter(room ? new VoiceGate() : null);
segmenter.Emitted += Send;
audio = Channel.CreateUnbounded<short[]>(new UnboundedChannelOptions { SingleReader = true });
@@ -116,8 +160,10 @@ public sealed class ListenEngine
{
await foreach (var buf in reader.ReadAllAsync())
{
- segmenter.Feed(buf);
Level = Rms(buf);
+ // The computer is playing speech: the room mic would hear it from the speakers.
+ if (!RoomSide && Echo is { } echo && Level >= Segmenter.Threshold) echo.Gate.Hold();
+ segmenter.Feed(buf);
}
segmenter.Flush();
});
@@ -125,8 +171,25 @@ public sealed class ListenEngine
source.Samples += OnSamples;
source.Start();
Listening = true;
- Log.Debug($"listen: started {session.Id} target={Target}");
- Changed?.Invoke();
+ }
+
+ /// The room side's lines wait a moment for the computer's line they may echo (EchoMatch.Hold),
+ /// in order; one around which the computer played nothing goes straight in. Stopping records
+ /// what still waits without the wait: it was said.
+ async Task Hold(ChannelReader<(Segment seg, Heard heard, double at, double queued)> reader, EchoFilter echo, CancellationToken stopping)
+ {
+ await foreach (var (seg, heard, at, queued) in reader.ReadAllAsync())
+ {
+ var h = new EchoMatch.Heard(heard.Original, at - seg.Seconds, at);
+ if (!echo.Quiet(h))
+ {
+ var wait = queued + EchoMatch.Hold - echo.Gate.Clock();
+ if (wait > 0) try { await Task.Delay(TimeSpan.FromSeconds(wait), stopping); } catch (OperationCanceledException) { }
+ }
+ if (echo.IsEcho(h)) { Log.Debug($"listen: room line dropped as an echo ({heard.Original.Length} chars)"); continue; }
+ Record(seg, heard);
+ Changed?.Invoke();
+ }
}
void OnSamples(short[] buf) => audio?.Writer.TryWrite(buf);
@@ -169,6 +232,17 @@ public sealed class ListenEngine
lock (gate) waiting = inFlight.ToArray();
await Task.WhenAny(Task.WhenAll(waiting), Task.Delay(15_000));
var id = SessionId!;
+ if (RoomSide)
+ {
+ // The meeting is the main side's to end; lines still waiting for their echo check go in.
+ held?.Writer.TryComplete();
+ flush?.Cancel();
+ if (holding is not null) await holding;
+ held = null; holding = null;
+ Log.Debug($"listen: room side stopped, {lineCount - RoomIDs} lines");
+ Changed?.Invoke();
+ return;
+ }
store.End(id, endedAt);
Log.Debug($"listen: stopped {id}, {lineCount} lines");
Changed?.Invoke();
@@ -182,6 +256,7 @@ public sealed class ListenEngine
lock (gate)
{
segments[seg.Index] = seg; lang = hint;
+ if (Echo is { } echo) emitted[seg.Index] = echo.Gate.Clock();
if (settings.SpeakerVoices && Voiceprint is { } vp) prints[seg.Index] = Task.Run(() => vp.Embed(seg.Samples));
}
Changed?.Invoke();
@@ -220,14 +295,31 @@ public sealed class ListenEngine
nextToDeliver++;
}
}
- foreach (var (seg, heard) in ready) if (heard is not null) Record(seg, heard);
+ foreach (var (seg, heard) in ready)
+ {
+ if (heard is null) continue;
+ if (RoomSide && held is { } h && Echo is { } echo) h.Writer.TryWrite((seg, heard, EmittedAt(seg), echo.Gate.Clock()));
+ else Record(seg, heard);
+ }
if (ready.Count > 0) Changed?.Invoke();
}
+ /// When the segmenter let go of `seg` (just after its last word), on EchoGate's clock.
+ double EmittedAt(Segment seg)
+ {
+ lock (gate) return emitted.Remove(seg.Index, out var at) ? at : Echo?.Gate.Clock() ?? 0;
+ }
+
void Record(Segment seg, Heard heard)
{
var id = SessionId!;
var target = Target;
+ // 电脑和会议室: what the computer said, for the room side to tell its copy of it.
+ if (!RoomSide && Echo is { } echo)
+ {
+ var at = EmittedAt(seg);
+ echo.Online(new EchoMatch.Heard(heard.Original, at - seg.Seconds, at));
+ }
// The meeting's language moves only after two segments agree, so one misheard stretch
// doesn't flip the hint (the Mac waits for confidence the same way).
lock (gate)
@@ -267,8 +359,9 @@ public sealed class ListenEngine
{
line = new TranscriptLine
{
- Id = $"h{++lineCount}-{seg.Index}", T = seg.Start, Speaker = "them",
+ Id = $"h{++lineCount}-{(RoomSide ? RoomIDs : 0) + seg.Index}", T = Math.Round(offset + seg.Start, 3), Speaker = "them",
Src = heard.Original, Dst = heard.Translation, SrcLang = heard.Lang, DstLang = target, Voice = voice,
+ Via = RoomSide ? "room" : null,
};
last = line;
}
diff --git a/windows/src/Cicada/App.cs b/windows/src/Cicada/App.cs
index 808c9b9..53ab44e 100644
--- a/windows/src/Cicada/App.cs
+++ b/windows/src/Cicada/App.cs
@@ -116,6 +116,9 @@ sealed class Controller
() => Listen.Listening && Listen.SessionId is { } id && Store.Get(id) is { } s ? (id, s.StartedAt) : null, WindowsVoice);
Speak.Changed += () => Dispatch.BeginInvoke(() => { speakBar ??= new SpeakBar(this); speakBar.Refresh(); });
Listen.Voiceprint = new WinVoiceprint();
+ // No voices on the room side: its numbers would collide with the PC's.
+ RoomListen = new ListenEngine(Ling, Translator, Store, Notes, Settings, roomSide: true);
+ RoomListen.Changed += Changed;
Listen.Changed += Changed;
Notes.Changed += Changed;
Store.Changed += _ => Changed();
@@ -340,7 +343,82 @@ sealed class Controller
Settings.ListenSourceValue = value;
Settings.Save();
Log.Debug($"listen source: {value}");
- if (Listen.Listening && Listen.Room != Settings.ListensToRoom) Listen.SwitchSource(Watch(NewSource()), Settings.ListensToRoom);
+ if (Listen.Listening)
+ {
+ if (!Settings.HearsBoth) _ = StopRoomSide();
+ if (Listen.Room != Settings.ListensToRoom) Listen.SwitchSource(Watch(NewSource()), Settings.ListensToRoom);
+ if (Settings.HearsBoth) StartRoomSide();
+ }
+ Changed();
+ }
+
+ // MARK: 电脑和会议室
+
+ /// The room side of 电脑和会议室: its own engine on the room mic, adding to the same meeting.
+ public readonly ListenEngine RoomListen;
+ /// 线上也有人?: the meeting app in a call while only the room is heard; answered once a meeting.
+ public string? OnlinePrompt { get; private set; }
+ bool onlinePromptAnswered;
+ /// 电脑和会议室 but Windows won't give Cicada the microphone: the PC's side keeps recording.
+ public bool HybridMicDenied { get; private set; }
+
+ /// The grey line under 听哪里 while both are heard: without echo cancellation the room pauses
+ /// while the PC plays speech (HybridNote on the Mac, whose other cases Windows doesn't have).
+ public string? HybridNote => Listen.Listening && RoomListen.Listening ? L("线上有人说话时,先不听会议室") : null;
+
+ void StartRoomSide()
+ {
+ if (RoomListen.Listening || !Listen.Listening || Listen.SessionId is not { } id || Store.Get(id) is not { } session) return;
+ var echo = new EchoFilter(new EchoGate());
+ Listen.Echo = echo;
+ RoomListen.Echo = echo;
+ var mic = RoomSource();
+ mic.Silenced = () => echo.Gate.Closed;
+ roomSources.Add(mic);
+ mic.Ended += reason =>
+ {
+ if (reason is null) return;
+ Log.Debug($"hybrid: room mic ended {reason}");
+ Dispatch.BeginInvoke(() =>
+ {
+ if (reason == "denied")
+ {
+ HybridMicDenied = true;
+ Toast(L("听会议室要先允许麦克风"), L("电脑声音照常在记"), () => Open("ms-settings:privacy-microphone"));
+ }
+ else if (reason == "none") Toast(L("没有可用的麦克风"), L("电脑声音照常在记"));
+ _ = StopRoomSide();
+ Changed();
+ });
+ };
+ HybridMicDenied = false;
+ RoomListen.Join(mic, id, session.StartedAt);
+ Log.Debug("hybrid: room side started");
+ }
+
+ async Task StopRoomSide()
+ {
+ Listen.Echo = null;
+ if (!RoomListen.Listening) return;
+ await RoomListen.Stop();
+ Log.Debug("hybrid: room side stopped");
+ }
+
+ /// 也听电脑 / 不用 on 线上也有人?.
+ public void AnswerOnlinePrompt(bool both)
+ {
+ onlinePromptAnswered = true;
+ OnlinePrompt = null;
+ Log.Debug($"hybrid: online prompt answered {(both ? "both" : "no")}");
+ if (both) SetListenSource(ListenSource.Both); else Changed();
+ }
+
+ void UpdateOnlinePrompt(Dictionary<string, string> calls)
+ {
+ var app = RoomPrompt.AsksOnline(Listen.Listening && Settings.ListensToRoom, onlinePromptAnswered, calls.Count > 0) ? calls.Values.First() : null;
+ if (app == OnlinePrompt) return;
+ OnlinePrompt = app;
+ if (app is not null) Log.Debug($"hybrid: online prompt for {app}");
Changed();
}
@@ -445,6 +523,9 @@ sealed class Controller
Ending = null;
endWatch = new MeetingEndWatch(EndConfig(), DateTimeOffset.Now);
Listen.Start(source, room: source is GatedSource);
+ onlinePromptAnswered = false;
+ OnlinePrompt = null;
+ if (Settings.HearsBoth && source is SystemAudioTap) StartRoomSide();
ShowNotes();
}
@@ -455,6 +536,9 @@ sealed class Controller
Ending = null;
ConfirmingEnd = false;
AutoEnded = auto;
+ OnlinePrompt = null;
+ HybridMicDenied = false;
+ await StopRoomSide();
roomSources.Clear();
await Listen.Stop(endedAt);
Changed();
@@ -485,9 +569,13 @@ sealed class Controller
bool live = Listen.Listening && endWatch is not null, after = !Listen.Listening && AutoEnded;
if (readingCalls || !(live || after) || (!live && !Settings.EndWithApp)) return;
readingCalls = true;
- Dictionary<string, string> calls = !Settings.EndWithApp ? new() : FakeCalls ?? await Task.Run(MicReaders.Calls);
+ // 线上也有人? needs the calls too, whatever 结束会议 says.
+ var asking = live && Settings.ListensToRoom && !onlinePromptAnswered;
+ Dictionary<string, string> found = Settings.EndWithApp || asking ? FakeCalls ?? await Task.Run(MicReaders.Calls) : new();
readingCalls = false;
+ var calls = Settings.EndWithApp ? found : new();
var now = DateTimeOffset.Now;
+ UpdateOnlinePrompt(asking ? found : new());
if (Listen.Listening && endWatch is { } w)
{
w.Settings = EndConfig();
@@ -894,7 +982,7 @@ sealed class Controller
public void OpenReleaseNotes() { if (Updates.Available is { } u) Open(u.Page); }
- static void Open(string url)
+ public static void Open(string url)
{
try { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url) { UseShellExecute = true }); }
catch (Exception e) { Log.Debug($"update: open failed {e.GetType().Name}"); }
diff --git a/windows/src/Cicada/MainWindow.cs b/windows/src/Cicada/MainWindow.cs
index 6e2a99a..79e1d81 100644
--- a/windows/src/Cicada/MainWindow.cs
+++ b/windows/src/Cicada/MainWindow.cs
@@ -17,6 +17,8 @@ static class Records
? local.ToString("HH:mm", Culture)
: local.ToString(L("M月d日"), Culture);
var parts = new List<string> { day, LF("%@ 分钟", Math.Max(1, (int)Math.Round(s.Duration.TotalMinutes))) };
+ // The Mac marks these with a mic and a display; a word reads the same here.
+ if (Places.HeardBoth(s.Lines)) parts.Add(L("电脑和会议室"));
if (s.Notes?.Todos.Count is > 0 and var n) parts.Add(LF("待办 %@", n));
return string.Join(" · ", parts);
}
@@ -401,7 +403,7 @@ sealed class MainWindow : Window
var into = s.Lines.Select(l => l.DstLang).FirstOrDefault(x => x is not null);
var meta = new List<string> { local.ToString(L("M月d日"), Culture) + " " + local.ToString("HH:mm", Culture) };
meta.Add(live ? L("正在听") : LF("%@ 分钟", Math.Max(1, (int)Math.Round(s.Duration.TotalMinutes))));
- if (s.Room == true) meta.Add(L("会议室"));
+ if (s.Room == true) meta.Add(Places.HeardBoth(s.Lines) ? L("电脑和会议室") : L("会议室"));
if (spoken is not null && into is not null) meta.Add($"{Ui.SpokenName(spoken)} → {Ui.TargetName(into)}");
top.Children.Add(Ui.Text(string.Join(" · ", meta), 13, live ? Palette.AccentText : Palette.Secondary));
@@ -560,9 +562,9 @@ sealed class MainWindow : Window
FrameworkElement? target = null;
// The line nearest the topic's time (older notes may hold a time no line has).
var nearest = jumpTo is { } t0 && s.Lines.Count > 0 ? s.Lines.MinBy(l => Math.Abs(l.T - t0)) : null;
- foreach (var (l, who, ink) in NotesWindow.Speakers(s.Lines, app.Settings.SpeakerVoices))
+ foreach (var (l, who, ink, place) in NotesWindow.Speakers(s.Lines, app.Settings.SpeakerVoices))
{
- var line = NotesWindow.TranscriptRow(l, who, ink);
+ var line = NotesWindow.TranscriptRow(l, who, ink, place);
if (ReferenceEquals(l, nearest)) target = line;
body.Children.Add(line);
}
diff --git a/windows/src/Cicada/NotesWindow.cs b/windows/src/Cicada/NotesWindow.cs
index 3a523e6..5053701 100644
--- a/windows/src/Cicada/NotesWindow.cs
+++ b/windows/src/Cicada/NotesWindow.cs
@@ -128,7 +128,13 @@ sealed class NotesWindow : Window
{
if (!app.Listen.Listening) return new Border();
if (app.ConfirmingEnd) return ConfirmEnd();
- if (app.Ending is not { } p) return new Border();
+ if (app.Ending is not { } p)
+ {
+ if (app.OnlinePrompt is not { } meetingApp) return new Border();
+ var strip = TrayFlyout.OnlineStrip(app, meetingApp);
+ strip.Margin = new Thickness(12, 0, 12, 8);
+ return strip;
+ }
Detach(endingDetail);
var buttons = Ui.Row(8, Ui.Button(L("继续记录"), app.KeepRecording, Ui.Kind.Primary, height: 32),
Ui.Button(L("现在结束"), () => _ = app.StopListening(), height: 32));
@@ -174,7 +180,7 @@ sealed class NotesWindow : Window
if (key != headerKey) { headerKey = key; header.Content = Header(); }
Tick();
if (Subtitles) { live.Content = SubtitleLine(); return; }
- var ek = !app.Listen.Listening ? null : app.ConfirmingEnd ? "confirm" : app.Ending is { } p ? p.Reason.ToString() : null;
+ var ek = !app.Listen.Listening ? null : app.ConfirmingEnd ? "confirm" : app.Ending is { } p ? p.Reason.ToString() : app.OnlinePrompt is { } o ? "online " + o : null;
if (ek != endingKey) { endingKey = ek; ending.Content = EndingStrip(); }
var bk = $"{app.Listen.Problem}|{(app.Listen.Listening && app.Notes.Status is NotesEngine.State.Failed or NotesEngine.State.RateLimited ? app.Notes.Status : null)}|{app.Ling.Health.Failure?.Why}|{app.Ling.Health.Proxy}|{app.Settings.ShowInCapture}|{hiddenFromCapture}";
if (bk != barsKey) { barsKey = bk; bars.Content = Bars(); }
@@ -401,39 +407,44 @@ sealed class NotesWindow : Window
var body = new StackPanel();
// Stored as they arrive (the notes count them); shown in time order, so a sentence I said
// sits between the other side's, which come back from Ming a little later.
- foreach (var (l, who, ink) in Speakers(lines, app.Settings.SpeakerVoices)) body.Children.Add(TranscriptRow(l, who, ink));
+ foreach (var (l, who, ink, place) in Speakers(lines, app.Settings.SpeakerVoices)) body.Children.Add(TranscriptRow(l, who, ink, place));
return body;
}
/// Lines in time order with who said them, named only where the speaker changes (as chat apps
- /// do): 你 for what I said into the meeting, 说话人 N once voices are told apart.
- internal static IEnumerable<(TranscriptLine line, string? who, Brush? ink)> Speakers(IReadOnlyList<TranscriptLine> lines, bool voices)
+ /// do): 你 for what I said into the meeting, 说话人 N once voices are told apart. A meeting that
+ /// heard the PC and the room says 现场 / 线上 where that changes too (`place`).
+ internal static IEnumerable<(TranscriptLine line, string? who, Brush? ink, bool place)> Speakers(IReadOnlyList<TranscriptLine> lines, bool voices)
{
var numbers = voices ? SpeakerLabels.Numbers(lines) : [];
+ var both = Places.HeardBoth(lines);
string? last = null;
foreach (var l in lines.OrderBy(x => x.T))
{
- var key = l.Speaker == "me" ? "me" : numbers.TryGetValue(l.Id, out var n) ? $"n{n}" : "them";
+ var key = l.Speaker == "me" ? "me" : (numbers.TryGetValue(l.Id, out var n) ? $"n{n}" : "them") + (both ? "|" + l.Via : "");
string? who = null; Brush? ink = null;
+ var place = false;
if (key != last)
{
+ place = both && l.Speaker != "me";
if (key == "me") { who = L("你"); ink = Palette.AccentText; }
else if (numbers.TryGetValue(l.Id, out var m)) { who = LF("说话人 %lld", m); ink = Palette.Speaker(m); }
- else if (numbers.Count > 0) { who = L("未识别"); ink = Palette.Tertiary; }
+ else if (numbers.Count > 0 && l.Via != "room") { who = L("未识别"); ink = Palette.Tertiary; } // the room side tells no voices apart
}
last = key;
- yield return (l, who, ink);
+ yield return (l, who, ink, place);
}
}
/// One line of the transcript as on the Mac: who (in their colour) and when, the original in
/// grey, the translation in ink.
- internal static FrameworkElement TranscriptRow(TranscriptLine l, string? who = null, Brush? ink = null)
+ internal static FrameworkElement TranscriptRow(TranscriptLine l, string? who = null, Brush? ink = null, bool place = false)
{
- var text = new StackPanel { Margin = new Thickness(0, who is null ? 0 : 6, 0, 12) };
+ var text = new StackPanel { Margin = new Thickness(0, who is null && !place ? 0 : 6, 0, 12) };
var head = Ui.Row(8, Ui.Text(Languages.Clock(l.T), 12, Palette.Tertiary, wrap: false));
+ if (place) head.Children.Insert(0, PlaceTag(l));
if (who is not null) head.Children.Insert(0, Ui.Text(who, 12, ink ?? Palette.Secondary, wrap: false));
- if (head.Children.Count > 1) ((FrameworkElement)head.Children[1]).Margin = new Thickness(8, 0, 0, 0);
+ for (int i = 1; i < head.Children.Count; i++) ((FrameworkElement)head.Children[i]).Margin = new Thickness(i == 1 && place && who is not null ? 6 : 8, 0, 0, 0);
text.Children.Add(head);
var translated = !string.IsNullOrEmpty(l.Dst) && l.Dst != l.Src;
text.Children.Add(Gap(Ui.Text(l.Src, translated ? 13 : 15, translated ? Palette.Secondary : Palette.Ink), 3, top: true));
@@ -441,6 +452,19 @@ sealed class NotesWindow : Window
return text;
}
+ /// 现场 / 线上 (SpeakerViews.swift › PlaceTag): the room's filled, the PC's outlined.
+ internal static FrameworkElement PlaceTag(TranscriptLine l)
+ {
+ var room = l.Via == "room";
+ return new Border
+ {
+ Background = room ? Palette.Mica : Brushes.Transparent, BorderBrush = room ? Brushes.Transparent : Palette.Line, BorderThickness = new Thickness(1),
+ CornerRadius = new CornerRadius(4), Padding = new Thickness(5, 0, 5, 1), VerticalAlignment = VerticalAlignment.Center,
+ Child = Ui.Text(Places.Place(l), 11, Palette.Secondary, wrap: false),
+ ToolTip = room ? L("会议室的麦克风听到的") : L("电脑里放出来的"),
+ };
+ }
+
/// Who can see this window, and when the notes change next.
FrameworkElement Footer()
{
diff --git a/windows/src/Cicada/Strings/en.lproj/Windows.strings b/windows/src/Cicada/Strings/en.lproj/Windows.strings
index bc3dc4c..d77c230 100644
--- a/windows/src/Cicada/Strings/en.lproj/Windows.strings
+++ b/windows/src/Cicada/Strings/en.lproj/Windows.strings
@@ -304,3 +304,10 @@
"插上麦克风后再开始听。" = "Plug in a microphone, then start again.";
"电脑声音" = "This PC";
"电脑声音(线上会议、视频)" = "This PC (online meetings, videos)";
+
+/* 听哪里 › 电脑和会议室: the Mac's words name the Mac. */
+"电脑和会议室" = "PC + Room";
+"电脑和会议室 · %@" = "PC + Room · %@";
+"电脑和会议室(线上和桌边的人都听)" = "PC + Room (people online and at the table)";
+"也听电脑" = "Hear the PC too";
+"电脑里放出来的" = "Played on the PC";
diff --git a/windows/src/Cicada/Strings/ja.lproj/Windows.strings b/windows/src/Cicada/Strings/ja.lproj/Windows.strings
index 126d300..130f630 100644
--- a/windows/src/Cicada/Strings/ja.lproj/Windows.strings
+++ b/windows/src/Cicada/Strings/ja.lproj/Windows.strings
@@ -304,3 +304,10 @@
"插上麦克风后再开始听。" = "マイクをつないでからもう一度始めてください。";
"电脑声音" = "この PC";
"电脑声音(线上会议、视频)" = "この PC(オンライン会議・動画)";
+
+/* 听哪里 › 电脑和会议室: the Mac's words name the Mac. */
+"电脑和会议室" = "PC と会議室";
+"电脑和会议室 · %@" = "PC と会議室 · %@";
+"电脑和会议室(线上和桌边的人都听)" = "PC と会議室(オンラインとテーブルの両方)";
+"也听电脑" = "PC も聞く";
+"电脑里放出来的" = "PC で再生された音声";
diff --git a/windows/src/Cicada/Strings/ko.lproj/Windows.strings b/windows/src/Cicada/Strings/ko.lproj/Windows.strings
index 69c5523..5e6948b 100644
--- a/windows/src/Cicada/Strings/ko.lproj/Windows.strings
+++ b/windows/src/Cicada/Strings/ko.lproj/Windows.strings
@@ -304,3 +304,10 @@
"插上麦克风后再开始听。" = "마이크를 연결한 뒤 다시 시작하세요.";
"电脑声音" = "이 PC";
"电脑声音(线上会议、视频)" = "이 PC (온라인 회의, 동영상)";
+
+/* 听哪里 › 电脑和会议室: the Mac's words name the Mac. */
+"电脑和会议室" = "PC와 회의실";
+"电脑和会议室 · %@" = "PC와 회의실 · %@";
+"电脑和会议室(线上和桌边的人都听)" = "PC와 회의실 (온라인과 테이블 모두)";
+"也听电脑" = "PC도 듣기";
+"电脑里放出来的" = "PC에서 재생된 소리";
diff --git a/windows/src/Cicada/TrayFlyout.cs b/windows/src/Cicada/TrayFlyout.cs
index e301ada..e9f44d9 100644
--- a/windows/src/Cicada/TrayFlyout.cs
+++ b/windows/src/Cicada/TrayFlyout.cs
@@ -155,8 +155,20 @@ sealed class TrayFlyout : Window
var target = s.Target == "system" ? spoken ?? "zh-Hans" : s.Target;
stack.Children.Add(Gap(ChoiceRow(L("翻译成"), Ui.TargetName(target), s.Target == "system" ? L("跟随系统") : null, Ui.TargetOptions(), s.Target, app.SetTarget), 12));
// 听哪里 (the Mac panel's row): changing it mid-meeting carries the same meeting on.
- var sources = new[] { (ListenSource.System, L("电脑声音(线上会议、视频)")), (ListenSource.Room, L("会议室(用麦克风听桌边的人)")) };
+ var sources = new[] { (ListenSource.System, L("电脑声音(线上会议、视频)")), (ListenSource.Room, L("会议室(用麦克风听桌边的人)")), (ListenSource.Both, L("电脑和会议室(线上和桌边的人都听)")) };
stack.Children.Add(Gap(ChoiceRow(L("听哪里"), SourceName(s.Listens), null, sources, s.Listens, app.SetListenSource), 8));
+ if (app.HybridNote is { } note) stack.Children.Add(Gap(Ui.Text(note, 12, Palette.Secondary), 6));
+ if (app.OnlinePrompt is { } meetingApp) stack.Children.Add(Gap(OnlineStrip(app, meetingApp, Hide), 10));
+ if (app.HybridMicDenied)
+ {
+ var text = Ui.Stack(2, Ui.Text(L("听会议室要先允许麦克风"), 13, Palette.AccentText, Palette.Strong), Ui.Text(L("电脑声音照常在记"), 11, Palette.Secondary));
+ var open = Ui.Button(L("去设置"), () => Do(() => Controller.Open("ms-settings:privacy-microphone")), Ui.Kind.Primary, height: 30);
+ open.VerticalAlignment = VerticalAlignment.Center; open.Margin = new Thickness(10, 0, 0, 0);
+ var dock = new DockPanel();
+ DockPanel.SetDock(open, Dock.Right);
+ dock.Children.Add(open); dock.Children.Add(text);
+ stack.Children.Add(new Border { Background = Palette.AccentPale, CornerRadius = new CornerRadius(9), Padding = new Thickness(10), Margin = new Thickness(0, 10, 0, 0), Child = dock });
+ }
// 同声传译
stack.Children.Add(Rule());
@@ -192,6 +204,17 @@ sealed class TrayFlyout : Window
return stack;
}
+ /// 线上也有人? / Zoom 正在通话 / 也听电脑 · 不用 (the Mac panel's strip), here and in the notes window.
+ public static FrameworkElement OnlineStrip(Controller app, string meetingApp, Action? after = null)
+ {
+ var stack = Ui.Stack(3, Ui.Text(L("线上也有人?"), 14, Palette.Ink, FontWeights.Bold), Ui.Text(LF("%@ 正在通话", meetingApp), 12, Palette.Secondary));
+ var buttons = Ui.Row(8, Ui.Button(L("也听电脑"), () => { after?.Invoke(); app.AnswerOnlinePrompt(true); }, Ui.Kind.Primary, height: 32),
+ Ui.Button(L("不用"), () => { after?.Invoke(); app.AnswerOnlinePrompt(false); }, height: 32));
+ buttons.Margin = new Thickness(0, 10, 0, 0);
+ stack.Children.Add(buttons);
+ return new Border { Background = Palette.AccentPale, CornerRadius = new CornerRadius(12), Padding = new Thickness(14), Child = stack };
+ }
+
public static string SourceName(string source) => source switch
{
ListenSource.Room => L("会议室"),
diff --git a/windows/tests/Cicada.Tests/Program.cs b/windows/tests/Cicada.Tests/Program.cs
index 36e6a4f..7b8a73b 100644
--- a/windows/tests/Cicada.Tests/Program.cs
+++ b/windows/tests/Cicada.Tests/Program.cs
@@ -762,6 +762,119 @@ static class Tests
sealed class FakePrint(Func<short[], float[]?> f) : IVoiceprint { public float[]? Embed(short[] s) => f(s); }
+ // MARK: 电脑和会议室
+
+ static EchoMatch.Heard H(string t, double s, double e) => new(t, s, e);
+
+ public static void TheRoomsCopyOfARemoteSentenceIsAnEcho()
+ {
+ // EchoMatchTests on the Mac, case for case.
+ List<EchoMatch.Heard> online = [H("Revenue grew by 12%, mostly from the new region.", 10, 14)];
+ Check(EchoMatch.IsEcho(H("revenue grew by 12% mostly from new region", 10.3, 14.2), online), "heard worse, a word lost");
+ Check(!EchoMatch.IsEcho(H("I think we should check the numbers for Europe first", 11, 15), online), "room speech is kept");
+ Check(!EchoMatch.IsEcho(H("我觉得应该先看一下欧洲的情况", 11, 15), online), "room speech in Chinese is kept");
+ Check(EchoMatch.IsEcho(H("这个季度的数据收入增长了百分之十二", 0.8, 4), [H("我们先看一下这个季度的数据。", 0, 2), H("收入增长了百分之十二,主要来自新的市场。", 2.2, 5)]), "cut differently");
+ Check(!EchoMatch.IsEcho(H("can everyone hear me okay", 20, 22), [H("Can everyone hear me okay?", 0, 2)]), "the same words long after");
+ Check(EchoMatch.IsEcho(H("ok", 5.2, 5.6), [H("OK.", 5, 5.5)]) && !EchoMatch.IsEcho(H("no", 5.2, 5.6), [H("OK.", 5, 5.5)]), "short lines only exactly");
+ }
+
+ public static void EchoGateClosesForTheHang()
+ {
+ double now = 100;
+ var g = new EchoGate(() => now);
+ Check(!g.Closed, "open");
+ g.Hold();
+ now = 100.3; Check(g.Closed, "closed just after loud audio");
+ now = 100 + EchoGate.Hang + 0.01; Check(!g.Closed, "open after the hang");
+ var echo = new EchoFilter(g);
+ Check(echo.Quiet(H("x", 104, 105)), "nothing played around a later line");
+ Check(!echo.Quiet(H("x", 101, 102)), "the computer played just before");
+ var pump = new Pump();
+ var room = new GatedSource(pump) { Silenced = () => g.Closed };
+ short[]? got = null;
+ room.Samples += b => got = b;
+ pump.Push([100, -100]);
+ Check(got is [100, -100], "the room passes while the computer is quiet");
+ g.Hold();
+ pump.Push([100, -100]);
+ Check(got is [0, 0], "silence while the gate is closed");
+ now += 1; room.Muted = true;
+ pump.Push([100, -100]);
+ Check(got is [0, 0], "silence while you hold the talk key");
+ }
+
+ sealed class Pump : IAudioSource
+ {
+ public event Action<short[]>? Samples;
+ public event Action<string?>? Ended { add { } remove { } }
+ public void Push(short[] b) => Samples?.Invoke(b);
+ public void Start() { }
+ public void Stop() { }
+ }
+
+ public static void PlacesShowOnlyWhenBothWereHeard()
+ {
+ TranscriptLine L(string id, string speaker = "them", string? via = null) => new() { Id = id, Speaker = speaker, Via = via };
+ Check(!Places.HeardBoth([L("a"), L("b")]), "the computer alone");
+ Check(!Places.HeardBoth([L("a", via: "room"), L("b", "me")]), "my own lines aren't the computer's");
+ Check(Places.HeardBoth([L("a", via: "room"), L("b")]), "both");
+ var starts = Places.Starts([L("a"), L("b"), L("c", via: "room"), L("d", "me"), L("e", via: "room"), L("f")]);
+ Check(starts.SetEquals(["a", "c", "e", "f"]), "a change of place starts a run: " + string.Join(",", starts));
+ Check(RoomPrompt.AsksOnline(true, false, true) && !RoomPrompt.AsksOnline(true, true, true) && !RoomPrompt.AsksOnline(false, false, true) && !RoomPrompt.AsksOnline(true, false, false), "线上也有人? once, in a call, in the room");
+ }
+
+ public static async Task TheRoomSideDropsTheSpeakersAndKeepsTheTable()
+ {
+ // The computer plays one sentence; the room mic hears it again from the speakers, then
+ // someone at the table says something else.
+ const string remote = "LANG: en\nORIGINAL: Revenue grew by 12%, mostly from the new region.\nTRANSLATION: 收入增长了 12%,主要来自新区域。";
+ const string table = "LANG: en\nORIGINAL: I think we should check the numbers for Europe first\nTRANSLATION: 我觉得应该先看欧洲的数字";
+ var fake = new Fake(body =>
+ {
+ if (!body.Contains("Ming-3.0-audio-flash")) return Reply("{}");
+ var url = JsonNode.Parse(body)!["messages"]![1]!["content"]![0]!["audio_url"]!["url"]!.GetValue<string>();
+ return Reply(url.Length < 140_000 ? remote : table);
+ });
+ var old = LingClient.Spacing; LingClient.Spacing = 0.05;
+ try
+ {
+ var ling = Client(fake);
+ var store = new SessionStore();
+ var settings = new AppSettings { Target = "zh-CN", SpeakerVoices = false };
+ var notes = new NotesEngine(ling, store);
+ var main = new ListenEngine(ling, new Translator(ling), store, notes, settings);
+ var room = new ListenEngine(ling, new Translator(ling), store, notes, settings, roomSide: true);
+ var echo = new EchoFilter(new EchoGate());
+ main.Echo = echo; room.Echo = echo;
+ string Wave(string name, short[] pcm)
+ {
+ var path = Path.Combine(Path.GetTempPath(), $"cicada-{name}-{Environment.ProcessId}.wav");
+ File.WriteAllBytes(path, Wav.Bytes(pcm));
+ return path;
+ }
+ var computer = new FileAudioSource(Wave("computer", [.. Tone(2), .. Silence(1)]), speed: 0);
+ var mic = new FileAudioSource(Wave("mic", [.. Tone(2, 0.05), .. Silence(1), .. Tone(4, 0.05), .. Silence(1)]), speed: 0);
+ var done = new TaskCompletionSource[] { new(), new() };
+ computer.Ended += _ => done[0].TrySetResult();
+ mic.Ended += _ => done[1].TrySetResult();
+ main.Start(computer);
+ var started = store.Get(main.SessionId!)!.StartedAt;
+ room.Join(mic, main.SessionId!, started);
+ await Task.WhenAll(done[0].Task, done[1].Task);
+ await Task.Delay(TimeSpan.FromSeconds(EchoMatch.Hold + 1.5));
+ await room.Stop();
+ await main.Stop();
+ var s = store.Get(main.SessionId!)!;
+ var theirs = s.Lines.Where(l => l.Via == "room").ToList();
+ Equal(1, s.Lines.Count(l => l.Via is null), "the computer's line");
+ Equal(1, theirs.Count, "the speakers' copy dropped, the table kept: " + string.Join(" | ", s.Lines.Select(l => $"{l.Via}:{l.Src}")));
+ Check(theirs[0].Src.Contains("Europe") && theirs[0].Id.StartsWith("h1000001-100000"), "the table's line, in the room's ids: " + theirs[0].Id);
+ Equal(true, s.Room, "a room meeting");
+ Check(Places.HeardBoth(s.Lines), "heard both");
+ }
+ finally { LingClient.Spacing = old; }
+ }
+
public static async Task NeverJoinsTwoVoices()
{
// Two halves of one "sentence" (no full stop, 0.4 s apart) in two different voices.