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: a meeting whose language was never recognized keeps its recording, and you pick the language to transcribe it

wqugurue31191e8e34c
diff --git a/Sources/LiveSubs/AppModel.swift b/Sources/LiveSubs/AppModel.swift
index 13e9552..907f4c4 100644
--- a/Sources/LiveSubs/AppModel.swift
+++ b/Sources/LiveSubs/AppModel.swift
@@ -1597,7 +1597,10 @@ final class AppModel: ObservableObject {
debugLog("overlay frame=\(overlay.barFrame) font=\(overlay.currentFontSize)")
case "import": importFiles(arg.split(separator: ",").map { URL(fileURLWithPath: String($0)) })
case "importCancel": importer.cancelAll()
- case "importRetry": importer.retry(arg)
+ case "importRetry":
+ // `<id>=<locale>`: as if that language was picked in 这场会议只留下了录音.
+ let parts = arg.split(separator: "=", maxSplits: 1).map(String.init)
+ importer.retry(parts[0], lang: parts.count > 1 ? sourceLanguages.first { $0.locale == parts[1] } : nil)
case "importNotify":
UNUserNotificationCenter.current().getNotificationSettings { s in debugLog("import: notifications \(s.authorizationStatus.rawValue) alert=\(s.alertSetting.rawValue)") }
case "importState":
diff --git a/Sources/LiveSubs/FileImport.swift b/Sources/LiveSubs/FileImport.swift
index 48d84d8..0eb6c8e 100644
--- a/Sources/LiveSubs/FileImport.swift
+++ b/Sources/LiveSubs/FileImport.swift
@@ -13,6 +13,8 @@ final class FileImporter: ObservableObject {
struct Job: Equatable {
let id: String
let url: URL
+ /// The language the user said it is in; nil detects it.
+ var lang: Lang? = nil
}
enum Phase: Equatable {
@@ -76,11 +78,12 @@ final class FileImporter: ObservableObject {
return ids
}
- /// Transcribe a record again from the start (one that stopped halfway, or by request).
- func retry(_ id: String) {
+ /// Transcribe a record again from the start (one that stopped halfway, or by request), in
+ /// `lang` when the user picked it.
+ func retry(_ id: String, lang: Lang? = nil) {
guard let path = store.session(id)?.sourcePath, current?.id != id, !queue.contains(where: { $0.id == id }) else { return }
store.restartImport(id)
- queue.append(Job(id: id, url: URL(fileURLWithPath: path)))
+ queue.append(Job(id: id, url: URL(fileURLWithPath: path), lang: lang))
next()
}
@@ -149,7 +152,8 @@ final class FileImporter: ObservableObject {
}
guard !Task.isCancelled, store.session(job.id) != nil else { return }
- let lang = await language(of: pcm)
+ var lang = job.lang ?? sourceLanguages[0]
+ if job.lang == nil { lang = await language(of: pcm) }
guard !Task.isCancelled else { return }
let target = settings.resolvedTarget(source: lang.code)
debugLog("import: \(job.id) \(lang.locale) → \(target)")
diff --git a/Sources/LiveSubs/ImportViews.swift b/Sources/LiveSubs/ImportViews.swift
index 1f068a7..2bf32b0 100644
--- a/Sources/LiveSubs/ImportViews.swift
+++ b/Sources/LiveSubs/ImportViews.swift
@@ -138,6 +138,73 @@ struct ImportStatusStrip: View {
}
}
+/// A meeting kept for its recording alone (the language was never settled while it ran): the
+/// user says which language was spoken, and it is transcribed like an imported file.
+struct RecordingLanguageStrip: View {
+ @ObservedObject var importer: FileImporter
+ let session: Session
+ @State private var picked: Lang?
+
+ /// The Mac's languages first, as chips; the rest under 其他语言.
+ private var likely: [Lang] {
+ var out = likelySourceLanguages(last: nil, systemLanguages: Locale.preferredLanguages)
+ for l in sourceLanguages where !out.contains(l) { out.append(l) }
+ return out
+ }
+
+ var body: some View {
+ let langs = likely
+ let chips = Array(langs.prefix(4))
+ let rest = Array(langs.dropFirst(4))
+ let lang = picked ?? langs[0]
+ VStack(alignment: .leading, spacing: 12) {
+ HStack(alignment: .top, spacing: 16) {
+ VStack(alignment: .leading, spacing: 3) {
+ Text("这场会议只留下了录音").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink)
+ Text("当时没听出是哪种语言。选一下,就按它转成文字")
+ .font(.system(size: 12)).foregroundStyle(Palette.secondary)
+ }
+ Spacer(minLength: 8)
+ SoftButton(L("重新转写"), dark: true) { importer.retry(session.id, lang: lang) }
+ }
+ HStack(spacing: 6) {
+ ForEach(chips, id: \.locale) { l in chip(l.name, on: l == lang) { picked = l } }
+ if !rest.isEmpty {
+ let other = rest.contains(lang)
+ Menu {
+ ForEach(rest, id: \.locale) { l in Button(l.name) { picked = l } }
+ } label: {
+ Text(other ? lang.name : L("其他语言…"))
+ .font(.system(size: 12, weight: other ? .semibold : .regular))
+ .foregroundStyle(other ? Palette.ink : Palette.secondary)
+ .padding(.horizontal, 12).frame(height: 26)
+ .background(Capsule().fill(Color.white))
+ .overlay(Capsule().strokeBorder(other ? Palette.ink : Palette.line, lineWidth: 1))
+ .contentShape(Capsule())
+ }
+ .menuStyle(.button).buttonStyle(.plain).menuIndicator(.hidden).fixedSize()
+ }
+ }
+ }
+ .padding(.leading, 16).padding(.trailing, 14).padding(.vertical, 14)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(RoundedRectangle(cornerRadius: 10).fill(Palette.fill))
+ }
+
+ private func chip(_ name: String, on: Bool, _ action: @escaping () -> Void) -> some View {
+ Button(action: action) {
+ Text(name).font(.system(size: 12, weight: on ? .semibold : .regular))
+ .foregroundStyle(on ? Palette.ink : Palette.secondary)
+ .padding(.horizontal, 12).frame(height: 26)
+ .background(Capsule().fill(Color.white))
+ .overlay(Capsule().strokeBorder(on ? Palette.ink : Palette.line, lineWidth: 1))
+ .contentShape(Capsule())
+ }
+ .buttonStyle(.plain)
+ .accessibilityAddTraits(on ? .isSelected : [])
+ }
+}
+
/// Play / pause, where in the file, and the speed, for an imported record.
struct RecordingPlayerBar: View {
@ObservedObject var player: RecordingPlayer
diff --git a/Sources/LiveSubs/SessionStore.swift b/Sources/LiveSubs/SessionStore.swift
index f3dcd18..1c3458d 100644
--- a/Sources/LiveSubs/SessionStore.swift
+++ b/Sources/LiveSubs/SessionStore.swift
@@ -42,6 +42,9 @@ struct Session: Codable, Identifiable, Equatable {
var sourceFile: String? = nil
var sourcePath: String? = nil
var importing: Bool? = nil
+ /// A meeting kept for its recording alone: transcribed like an imported file (its
+ /// `sourcePath` is its own recording), in a language the user picks.
+ var fromRecording: Bool { sourceFile == nil && sourcePath != nil }
/// Heard through the microphone in the room (会议室) for some or all of it.
var room: Bool? = nil
@@ -139,11 +142,17 @@ final class SessionStore: ObservableObject {
sessions[i].hasAudio = [systemAudioURL(id), micAudioURL(id)].contains {
FileManager.default.fileExists(atPath: $0.path) || FileManager.default.fileExists(atPath: AudioFileWriter.partial($0).path)
}
- if sessions[i].lines.isEmpty, !(heardSpeech && sessions[i].hasAudio) {
- // Nothing was said: don't keep an empty meeting around.
- try? FileManager.default.removeItem(at: folder(id))
- sessions.remove(at: i)
- return
+ if sessions[i].lines.isEmpty {
+ guard heardSpeech, sessions[i].hasAudio else {
+ // Nothing was said: don't keep an empty meeting around.
+ try? FileManager.default.removeItem(at: folder(id))
+ sessions.remove(at: i)
+ return
+ }
+ // Only the recording: it plays, and is transcribed again, like an imported file.
+ let system = systemAudioURL(id)
+ let heard = [system, AudioFileWriter.partial(system)].contains { FileManager.default.fileExists(atPath: $0.path) }
+ sessions[i].sourcePath = (heard ? system : micAudioURL(id)).path
}
saveNow(id)
finishAudio(id, until: at == nil ? nil : sessions[i].duration)
diff --git a/Sources/LiveSubs/Views.swift b/Sources/LiveSubs/Views.swift
index 6907472..c32880f 100644
--- a/Sources/LiveSubs/Views.swift
+++ b/Sources/LiveSubs/Views.swift
@@ -837,6 +837,9 @@ struct MainWindowView: View {
if live { BreathingDot(size: 6) }
if s.sourceFile != nil {
Image(systemName: "doc").font(.system(size: 11)).foregroundStyle(Palette.secondary)
+ } else if s.fromRecording, s.lines.isEmpty {
+ Image(systemName: "waveform").font(.system(size: 11)).foregroundStyle(Palette.secondary)
+ .help(L("只有录音"))
} else if s.room == true {
Image(systemName: "mic").font(.system(size: 11)).foregroundStyle(Palette.secondary)
.help(L("会议室"))
@@ -953,7 +956,8 @@ struct MainWindowView: View {
}
.overlay {
Text(s.id == store.liveID ? L("正在听,说话的内容会出现在这里")
- : working(s) ? L("转出的文字会陆续出现在这里") : L("这场会议没有记录到内容"))
+ : working(s) ? L("转出的文字会陆续出现在这里")
+ : s.fromRecording ? L("还没有文字记录") : L("这场会议没有记录到内容"))
.font(.system(size: 13)).foregroundStyle(Palette.secondary)
}
} else if tab == "notes", importer.status(of: s) == nil {
@@ -1117,9 +1121,13 @@ struct MainWindowView: View {
if !titleDraft.isEmpty { store.rename(s.id, to: titleDraft) }
titleDraft = ""
}
- if s.sourceFile != nil {
+ if s.sourcePath != nil {
VStack(alignment: .leading, spacing: 12) {
- ImportStatusStrip(model: model, importer: importer, session: s)
+ if s.fromRecording, s.lines.isEmpty || s.importing == true, !working(s) {
+ RecordingLanguageStrip(importer: importer, session: s)
+ } else {
+ ImportStatusStrip(model: model, importer: importer, session: s)
+ }
if player.sessionID == s.id { RecordingPlayerBar(player: player) }
}
.padding(.top, 16)
diff --git a/tools/README.md b/tools/README.md
index 7d2a331..f036a1f 100644
--- a/tools/README.md
+++ b/tools/README.md
@@ -19,7 +19,7 @@
- 识别引擎:`recognizer:legacy` 在 macOS 26 上改用 14 / 15 的识别(`SFSpeechRecognizer`,第一次会要“语音识别”权限),`recognizer:auto` 换回;下一次开始听起生效(或启动时 `open --env CICADA_RECOGNIZER=legacy`),日志里 `transcriber started recognizer=…`
- 多开:两边都设 `CICADA_DEBUG_CHANNEL=x`(`open -n --env CICADA_DEBUG_CHANNEL=x build/Cicada.app`),命令只发给这一份,日志在 `/tmp/livesubs-dev-debug-x.log`
- 导出:`export:<目录>`
- - 导入录音或视频:`import:<路径>[,<路径>…]`(等于拖进会议记录窗口),`importState` 把进度写进日志,`importCancel` 停止转写,`importRetry:<会议 id>` 重新转写,`importNotify` 把通知权限写进日志
+ - 导入录音或视频:`import:<路径>[,<路径>…]`(等于拖进会议记录窗口),`importState` 把进度写进日志,`importCancel` 停止转写,`importRetry:<会议 id>[=<locale>]` 重新转写(带 locale 等于在“这场会议只留下了录音”里选了这种语言),`importNotify` 把通知权限写进日志
- 新手引导与窗口:`onboarding:<步骤>[,skip|ask|setup]`(1–5,5 是收尾页;skip 是第 3 步点了“先不接”,ask / setup 是第 4 步的二选一 / 清单)、`samplePlay`、`speakers:<on|off>`(“说话人识别”)、`speakerGuess:<会议 id>`(马上让 Ling 认一遍名字)、`speakersRender:<会议 id>=<png>`、`voiceprintFile:<音频>=<json>`(用 app 里的声纹模型算整个文件的声纹,和参考模型对比)、`closeWindow:<main|settings|onboarding>`、`settings:<overlay|language|speak|records|ai|diagnostics>`、`about`
- 显示与字幕:`display:<notes|bar|none>`、`subtitles:<both|translation|original>`、`meetingSubtitles:<…>`、`overlayState`、`overlayToggle`、`pillClick`(等于点主窗口顶部的“正在听”)、`overlayAuto[:off]`、`hideAfter:<秒>`
- 纪要:`notesLang:<mine|source>`、`meetingNotesLang:<…>`、`notesRegenerate:<id>=<mine|source>`、`notesWindow[:x,y,w,h]`、`notesClose`、`notesMinimize`、`notesFrame`、`notesNow`、`notesState`、`notesShow:<id>`、`notesReplay:<id>`、`notesCapturable[:off]`(只改窗口能否被截屏)、`notesShare:<on|off>`(改“共享屏幕时让对方看到”这个设置,等于点图标或开关)