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.

chore(windows): play the onboarding sample aloud and scale the meter in dB

wquguruf9c767292c05
diff --git a/windows/scripts/build.sh b/windows/scripts/build.sh
index fe12f6f..775e346 100755
--- a/windows/scripts/build.sh
+++ b/windows/scripts/build.sh
@@ -20,7 +20,19 @@ open(os.path.join(d, "..", "..", "src", "Cicada", "Assets", "cicada.ico"), "wb")
PY
# The onboarding sample as 16 kHz WAV: SoundPlayer and the file source both read WAV only.
-afconvert -f WAVE -d LEI16@16000 -c 1 "$root/Resources/sample/sample.m4a" src/Cicada/Assets/sample.wav
+# afconvert writes WAVE_FORMAT_EXTENSIBLE plus a FLLR chunk, which SoundPlayer refuses
+# (InvalidOperationException), so rewrite it as a plain PCM WAV.
+afconvert -f WAVE -d LEI16@16000 -c 1 "$root/Resources/sample/sample.m4a" build/icon/sample.wav
+python3 - build/icon/sample.wav src/Cicada/Assets/sample.wav <<'PY'
+import struct, sys
+d = open(sys.argv[1], "rb").read(); i = 12; pcm = b""
+while i < len(d):
+ n = int.from_bytes(d[i+4:i+8], "little")
+ if d[i:i+4] == b"data": pcm = d[i+8:i+8+n]
+ i += 8 + n + (n & 1)
+fmt = struct.pack("<HHIIHH", 1, 1, 16000, 32000, 2, 16)
+open(sys.argv[2], "wb").write(b"RIFF" + struct.pack("<I", 4 + 8 + len(fmt) + 8 + len(pcm)) + b"WAVE" + b"fmt " + struct.pack("<I", len(fmt)) + fmt + b"data" + struct.pack("<I", len(pcm)) + pcm)
+PY
config=Debug; [ "${RELEASE:-}" = 1 ] && config=Release
for rid in win-x64 win-arm64; do
@@ -28,6 +40,10 @@ for rid in win-x64 win-arm64; do
rm -rf "$out"
scripts/dotnet.sh publish src/Cicada -c "$config" -r "$rid" -o "$out" -p:DebugType=embedded -v quiet -nologo 2>&1 | grep -E ' error |warning CS' | sort -u || true
[ -f "$out/Cicada.exe" ] || { echo "build failed for $rid" >&2; exit 1; }
+ # Strings.Load reads both tables from Resources/; a misplaced one silently leaves the UI in Chinese.
+ for f in Resources/en.lproj/Localizable.strings Resources/en.lproj/Windows.strings; do
+ [ -f "$out/$f" ] || { echo "missing $f in $out" >&2; exit 1; }
+ done
if [ "$config" = Debug ]; then
printf '@echo off\r\nstart "" "%%~dp0Cicada.exe" --dev\r\n' > "$out/Cicada Dev.cmd"
# Everything the VM test needs in the one folder: the capture probe, the control script and the clips.
diff --git a/windows/src/Cicada/Assets/sample.wav b/windows/src/Cicada/Assets/sample.wav
index 955877f..d3538ab 100644
Binary files a/windows/src/Cicada/Assets/sample.wav and b/windows/src/Cicada/Assets/sample.wav differ
diff --git a/windows/src/Cicada/Onboarding.cs b/windows/src/Cicada/Onboarding.cs
index e0d1801..6a2f1a2 100644
--- a/windows/src/Cicada/Onboarding.cs
+++ b/windows/src/Cicada/Onboarding.cs
@@ -89,13 +89,16 @@ sealed class Onboarding : Window
tap.Start();
meter.Start();
}
- var bar = new ProgressBar { Minimum = 0, Maximum = 1, Value = Math.Min(1, level * 8), Height = 8, Foreground = Palette.Accent, Background = Palette.Ground, BorderThickness = new Thickness(0) };
+ var bar = new ProgressBar { Minimum = 0, Maximum = 1, Value = Loudness(level), Height = 8, Foreground = Palette.Accent, Background = Palette.Ground, BorderThickness = new Thickness(0) };
var heard = peak >= 0.01;
var body = Ui.Stack(12, bar, Ui.Text(heard ? L("听到了") : L("放一段视频或音乐,看这条有没有跳动"), 13, heard ? Palette.Ink : Palette.Secondary));
return Frame(L("系统声音"), L("知了听的是电脑播放出来的声音,不用麦克风,也不用授权。"), body,
Ui.Row(8, Ui.Button(L("继续"), Next, heard ? "primary" : "quiet")));
}
+ /// -50 dBFS (a quiet room) to 0 dBFS on a log scale, so speech sits mid-bar instead of pinning it.
+ static double Loudness(double rms) => rms <= 0 ? 0 : Math.Clamp((20 * Math.Log10(rms) + 50) / 50, 0, 1);
+
FrameworkElement SampleStep()
{
var body = Ui.Stack(10, Ui.Text(L("播放一段约 9 秒的示例会议,看字幕和纪要怎么出现。"), 13, Palette.Secondary));