知了 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(records): re-transcribe a saved meeting from its recording
clementchenfa85ed577864
diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.stringsindex fcab506..6ee937d 100644--- a/Resources/en.lproj/Localizable.strings+++ b/Resources/en.lproj/Localizable.strings@@ -1519,3 +1519,6 @@/* Microphone on start */"开始听时打开麦克风" = "Open the microphone when listening starts";"关掉后只听电脑声音;开会时再手动打开" = "Off: only the Mac's audio; open it by hand when a meeting starts";++/* Retranscribe help */+"用保存的录音重新识别,替换现在的文字记录和纪要;旧记录会先备份" = "Recognize the saved recording again and replace the transcript and notes; the old record is backed up first";diff --git a/Resources/ja.lproj/Localizable.strings b/Resources/ja.lproj/Localizable.stringsindex 66b5875..30d0649 100644--- a/Resources/ja.lproj/Localizable.strings+++ b/Resources/ja.lproj/Localizable.strings@@ -1519,3 +1519,6 @@/* Microphone on start */"开始听时打开麦克风" = "聞き始めるときにマイクを開く";"关掉后只听电脑声音;开会时再手动打开" = "オフ: Mac の音だけを聞き、会議のときに手動で開きます。";++/* Retranscribe help */+"用保存的录音重新识别,替换现在的文字记录和纪要;旧记录会先备份" = "保存した録音で認識し直し、文字起こしと議事録を置き換えます。古い記録は先にバックアップされます";diff --git a/Resources/ko.lproj/Localizable.strings b/Resources/ko.lproj/Localizable.stringsindex 1417a41..c8ef05c 100644--- a/Resources/ko.lproj/Localizable.strings+++ b/Resources/ko.lproj/Localizable.strings@@ -1519,3 +1519,6 @@/* Microphone on start */"开始听时打开麦克风" = "듣기 시작할 때 마이크 켜기";"关掉后只听电脑声音;开会时再手动打开" = "끄면 Mac 소리만 듣고, 회의할 때 직접 켭니다.";++/* Retranscribe help */+"用保存的录音重新识别,替换现在的文字记录和纪要;旧记录会先备份" = "저장된 녹음으로 다시 인식해 텍스트와 회의록을 교체합니다. 이전 기록은 먼저 백업됩니다";diff --git a/Resources/zh-Hans.lproj/Localizable.strings b/Resources/zh-Hans.lproj/Localizable.stringsindex a15b0c2..ba5c1b8 100644--- a/Resources/zh-Hans.lproj/Localizable.strings+++ b/Resources/zh-Hans.lproj/Localizable.strings@@ -1427,3 +1427,6 @@/* Microphone on start */"开始听时打开麦克风" = "开始听时打开麦克风";"关掉后只听电脑声音;开会时再手动打开" = "关掉后只听电脑声音;开会时再手动打开";++/* Retranscribe help */+"用保存的录音重新识别,替换现在的文字记录和纪要;旧记录会先备份" = "用保存的录音重新识别,替换现在的文字记录和纪要;旧记录会先备份";diff --git a/Sources/Cicada/FileImport.swift b/Sources/Cicada/FileImport.swiftindex 35dce7f..f1d728b 100644--- a/Sources/Cicada/FileImport.swift+++ b/Sources/Cicada/FileImport.swift@@ -84,11 +84,19 @@ final class FileImporter: ObservableObject {}/// Transcribe a record again from the start (one that stopped halfway, or by request), in- /// `lang` when the user picked it.+ /// `lang` when the user picked it. A live meeting has no `sourcePath`; its saved system.m4a+ /// (or mic/room file) is used instead, so a record with a bad transcript can be redone.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 }+ guard let s = store.session(id), current?.id != id, !queue.contains(where: { $0.id == id }) else { return }+ let candidates = [s.sourcePath.map { URL(fileURLWithPath: $0) },+ store.systemAudioURL(id), store.micAudioURL(id), store.roomAudioURL(id)].compactMap { $0 }+ guard let url = candidates.first(where: { FileManager.default.isReadableFile(atPath: $0.path) }) else {+ debugLog("retry: \(id) has no readable recording")+ return+ }+ if !s.lines.isEmpty || s.notes != nil { store.backupTranscript(id) }store.restartImport(id)- queue.append(Job(id: id, url: URL(fileURLWithPath: path), lang: lang))+ queue.append(Job(id: id, url: url, lang: lang))next()}diff --git a/Sources/Cicada/ImportViews.swift b/Sources/Cicada/ImportViews.swiftindex 292caa4..ea713f5 100644--- a/Sources/Cicada/ImportViews.swift+++ b/Sources/Cicada/ImportViews.swift@@ -152,7 +152,11 @@ struct ImportStatusStrip: View {}}- private var fileExists: Bool { session.sourcePath.map { FileManager.default.fileExists(atPath: $0) } ?? false }+ private var fileExists: Bool {+ if let path = session.sourcePath, FileManager.default.fileExists(atPath: path) { return true }+ return [model.store.systemAudioURL(session.id), model.store.micAudioURL(session.id),+ model.store.roomAudioURL(session.id)].contains { FileManager.default.fileExists(atPath: $0.path) }+ }private func title(_ status: FileImporter.Status) -> String {switch status {diff --git a/Sources/Cicada/SessionStore.swift b/Sources/Cicada/SessionStore.swiftindex 8864043..f9c5b32 100644--- a/Sources/Cicada/SessionStore.swift+++ b/Sources/Cicada/SessionStore.swift@@ -405,6 +405,27 @@ final class SessionStore: ObservableObject {saveNow(id)}+ /// Keep the old transcript and notes beside the recording, before a re-transcribe replaces+ /// them. Returns the backup's URL, or nil when there is nothing to keep.+ @discardableResult+ func backupTranscript(_ id: String) -> URL? {+ guard let i = index(id), !sessions[i].lines.isEmpty || sessions[i].notes != nil else { return nil }+ saveNow(id)+ let dir = folder(id)+ let src = dir.appendingPathComponent("session.json")+ guard FileManager.default.fileExists(atPath: src.path) else { return nil }+ let stamp = ISO8601DateFormatter().string(from: Date())+ .replacingOccurrences(of: ":", with: "-")+ let dst = dir.appendingPathComponent("session.before-retranscribe-\(stamp).json")+ do {+ try FileManager.default.copyItem(at: src, to: dst)+ return dst+ } catch {+ debugLog("backup transcript failed: \(error)")+ return nil+ }+ }+func append(_ line: TranscriptLine, to id: String) {guard let i = index(id) else { return }sessions[i].lines.append(line)diff --git a/Sources/Cicada/Views.swift b/Sources/Cicada/Views.swiftindex 8c03de0..cddfa13 100644--- a/Sources/Cicada/Views.swift+++ b/Sources/Cicada/Views.swift@@ -1020,8 +1020,12 @@ struct MainWindowView: View {Button("显示原文件") { NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: path)]) }}Button("在 Finder 中显示") { NSWorkspace.shared.activateFileViewerSelecting([store.folder(s.id)]) }- if s.sourcePath != nil, !working(s) {- Button("重新转写") { importer.retry(s.id) }+ if s.hasAudio, !live, !working(s) {+ Menu("重新转写") {+ ForEach(sourceLanguages, id: \.locale) { lang in+ Button(lang.name) { importer.retry(s.id, lang: lang) }+ }+ }}if s.renamed ?? !s.title.hasPrefix("会议 "), s.notes?.title != nil {Button("恢复自动标题") { store.rename(s.id, to: "") }@@ -1204,6 +1208,17 @@ struct MainWindowView: View {.buttonStyle(.plain).disabled((s.lines.isEmpty && (s.notes?.isEmpty ?? true)) || store.liveID == s.id || importer.status(of: s) != nil).sheet(item: $sharing) { shared in ShareSheet(session: shared) { sharing = nil } }+ if s.hasAudio, store.liveID != s.id, importer.status(of: s) == nil {+ Menu {+ ForEach(sourceLanguages, id: \.locale) { lang in+ Button(lang.name) { importer.retry(s.id, lang: lang) }+ }+ } label: {+ Text("重新转写").font(.system(size: 13)).foregroundStyle(Palette.secondary)+ }+ .menuStyle(.button).buttonStyle(.plain).menuIndicator(.hidden).fixedSize()+ .help(L("用保存的录音重新识别,替换现在的文字记录和纪要;旧记录会先备份"))+ }Menu {Button("复制为 Markdown") { model.export(s, kind: "copy") }Divider()