知了 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
fix(ios): an import cut off in the background says Unfinished and offers Transcribe Again, and any meeting with a recording can be transcribed again in a language you pick
wqugurub25828387fd7
diff --git a/ios/Sources/Cicada/Debug.swift b/ios/Sources/Cicada/Debug.swiftindex ae82b18..efd4714 100644--- a/ios/Sources/Cicada/Debug.swift+++ b/ios/Sources/Cicada/Debug.swift@@ -80,6 +80,13 @@ extension AppModel {})case "importStop":if let id = importer.current?.id { importer.cancel(id) }+ case "importRetry":+ // importRetry:<id>[=<locale>], as on the Mac: 重新转写 (in that language).+ let parts = arg.split(separator: "=", maxSplits: 1).map(String.init)+ retranscribe(parts[0], lang: parts.count > 1 ? sourceLanguages.first { $0.locale == parts[1] } : nil)+ case "importExpire":+ // What the system's expiration handler does when it takes the background time back.+ importer.cancelAll()case "hear":// hear:room|speaker, 声音来源UserDefaults.standard.set(arg == "speaker" ? "speaker" : "room", forKey: Pref.hear)diff --git a/ios/Sources/Cicada/Importing.swift b/ios/Sources/Cicada/Importing.swiftindex cb5d94a..6fcb4f4 100644--- a/ios/Sources/Cicada/Importing.swift+++ b/ios/Sources/Cicada/Importing.swift@@ -232,3 +232,115 @@ struct ImportCard: View {private extension String {var isVideo: Bool { UTType(filenameExtension: self)?.conforms(to: .movie) ?? false }}++extension AppModel {+ /// 重新转写: a record that stopped halfway (the system took the background time back, or 停止),+ /// or one heard badly, transcribed again from its file or recording; the old transcript is backed up.+ func retranscribe(_ id: String, lang: Lang? = nil) {+ importer.retry(id, lang: lang)+ guard importer.current?.id == id || importer.queue.contains(where: { $0.id == id }) else { return }+ ImportBackground.begin(store.session(id)?.displayTitle ?? "")+ }++ /// Whether 重新转写 has something to hear: the imported file's copy, or the meeting's recording.+ func canRetranscribe(_ s: Session) -> Bool {+ if let path = s.sourcePath, FileManager.default.fileExists(atPath: path) { return true }+ return [store.systemAudioURL(s.id), store.micAudioURL(s.id), store.roomAudioURL(s.id)]+ .contains { FileManager.default.fileExists(atPath: $0.path) }+ }+}++/// 重新转写 by language, for a record's menus: not while it is live or being transcribed.+struct RetranscribeMenu: View {+ @EnvironmentObject var model: AppModel+ @ObservedObject var importer: FileImporter+ let session: Session++ var body: some View {+ if session.id != model.store.liveID, importer.status(of: session) == nil || importer.status(of: session) == .unfinished,+ model.canRetranscribe(session) {+ Menu {+ ForEach(sourceLanguages, id: \.locale) { lang in+ Button(lang.name) { model.retranscribe(session.id, lang: lang) }+ }+ } label: { Label("重新转写", systemImage: "waveform.badge.magnifyingglass") }+ }+ }+}++/// Under an imported record's title, as on the Mac: queued, how far transcribing got, or that it+/// stopped, with 重新转写.+struct ImportStatusStrip: View {+ @EnvironmentObject var model: AppModel+ @ObservedObject var importer: FileImporter+ let session: Session++ var body: some View {+ if let status = importer.status(of: session) {+ VStack(alignment: .leading, spacing: 8) {+ HStack(spacing: 10) {+ Text(title(status)).font(.subheadline).foregroundStyle(Ink.ink)+ Spacer(minLength: 8)+ if status == .running, importer.phase == .transcribing || importer.phase == .translating {+ Text(verbatim: "\(Int(importer.progress * 100))%").font(.subheadline.monospacedDigit()).foregroundStyle(Ink.secondary)+ } else if status == .unfinished, model.canRetranscribe(session) {+ Button { model.retranscribe(session.id) } label: {+ Text("重新转写").font(.subheadline.weight(.semibold)).foregroundStyle(.white)+ .padding(.horizontal, 14).frame(minHeight: 32)+ .background(Ink.ink, in: Capsule())+ }+ .buttonStyle(.plain)+ .frame(minHeight: 44)+ }+ }+ if status == .running {+ ProgressView(value: importer.phase == .transcribing || importer.phase == .translating ? importer.progress : 0).tint(Ink.ink)+ }+ }+ .padding(.horizontal, 14).padding(.vertical, 8)+ .frame(maxWidth: .infinity, alignment: .leading)+ .background(Ink.ground, in: RoundedRectangle(cornerRadius: 14, style: .continuous))+ }+ }++ private func title(_ status: FileImporter.Status) -> String {+ switch status {+ case .queued(let ahead): ahead > 0 ? L("排队中,前面还有 \(ahead) 个文件") : L("排队中")+ case .unfinished: model.canRetranscribe(session) ? L("没转完") : L("没转完,原文件已不在原来的位置")+ case .running:+ switch importer.phase {+ case .preparing: L("正在读取文件…")+ case .detecting: L("正在听是哪种语言…")+ case .downloading(let name): L("正在下载 \(name) 语音模型…")+ case .transcribing: L("文字记录已转到 \(TranscriptExport.clock(importer.heard)) / \(TranscriptExport.clock(importer.duration))")+ case .translating: L("还有 \(importer.untranslated) 句在翻译")+ }+ }+ }+}++/// The list row's word for a record still being worked on, as on the Mac.+struct ImportRowTag: View {+ @ObservedObject var importer: FileImporter+ let session: Session++ var body: some View {+ if let status = importer.status(of: session) {+ Text(tag(status)).font(.footnote.weight(.semibold))+ .foregroundStyle(status == .unfinished ? Ink.accentText : Ink.secondary).lineLimit(1)+ }+ }++ private func tag(_ status: FileImporter.Status) -> String {+ switch status {+ case .queued: L("排队中")+ case .unfinished: L("没转完")+ case .running:+ switch importer.phase {+ case .transcribing: L("转写中 \(Int(importer.progress * 100))%")+ case .translating: L("翻译中")+ default: L("准备中")+ }+ }+ }+}diff --git a/ios/Sources/Cicada/RecordView.swift b/ios/Sources/Cicada/RecordView.swiftindex 737dfe5..ed68410 100644--- a/ios/Sources/Cicada/RecordView.swift+++ b/ios/Sources/Cicada/RecordView.swift@@ -42,6 +42,7 @@ struct RecordView: View {Text(Self.meta(session)).font(.footnote).foregroundStyle(Ink.secondary).padding(.top, 4)+ ImportStatusStrip(importer: model.importer, session: session).padding(.top, 12)let numbers = voicesOn ? TranscriptExport.speakerNumbers(session) : [:]let runs = SpeakerRail.runs(session, numbers: numbers)let focus = picked ?? playingNumber(numbers)diff --git a/ios/Sources/Cicada/RecordsView.swift b/ios/Sources/Cicada/RecordsView.swiftindex 034323d..c2744b1 100644--- a/ios/Sources/Cicada/RecordsView.swift+++ b/ios/Sources/Cicada/RecordsView.swift@@ -222,6 +222,7 @@ struct RecordGroups: View {if s.renamed ?? !s.title.hasPrefix("会议 "), s.notes?.title != nil {Button { model.rename(s.id, to: "") } label: { Label("恢复自动标题", systemImage: "arrow.uturn.backward") }}+ RetranscribeMenu(importer: model.importer, session: s)Button(role: .destructive) { model.deleteSession(s.id) } label: { Label("删除", systemImage: "trash") }.disabled(s.id == model.store.liveID)}@@ -235,6 +236,7 @@ struct RowPress: ButtonStyle {}struct RecordRow: View {+ @EnvironmentObject var model: AppModellet session: Sessionlet chevron: Bool/// Watched here so "3 人" comes and goes with 说话人识别 (a row's session doesn't change).@@ -252,10 +254,13 @@ struct RecordRow: View {.foregroundStyle(Ink.ink).lineLimit(2).multilineTextAlignment(.leading)- Text(Self.meta(session, voices: voices))- .font(.footnote)- .foregroundStyle(Ink.secondary)- .lineLimit(1)+ HStack(spacing: 6) {+ ImportRowTag(importer: model.importer, session: session)+ Text(Self.meta(session, voices: voices))+ .font(.footnote)+ .foregroundStyle(Ink.secondary)+ .lineLimit(1)+ }}.padding(.leading, runs.isEmpty ? 0 : 14)// Scheme A's upright strip: each person's turns in grey, a bookmark of the meeting.