知了 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
import Foundation
import Testing
@testable import Cicada
@MainActor @Suite struct SessionStoreTests {
func store() -> SessionStore {
let root = FileManager.default.temporaryDirectory.appendingPathComponent("cicada-store-\(UUID().uuidString)")
return SessionStore(root: root)
}
func record(_ store: SessionStore, _ id: String) {
FileManager.default.createFile(atPath: AudioFileWriter.partial(store.systemAudioURL(id)).path, contents: Data(count: 1024))
}
@Test func aMeetingWithNothingSaidIsDropped() {
let s = store()
let id = s.begin().id
record(s, id)
s.end()
#expect(s.session(id) == nil)
#expect(!FileManager.default.fileExists(atPath: s.folder(id).path))
}
@Test func aRecordingWithSpeechIsKeptWithoutLines() {
let s = store()
let id = s.begin().id
record(s, id)
s.end(heardSpeech: true)
#expect(s.session(id)?.hasAudio == true)
#expect(FileManager.default.fileExists(atPath: AudioFileWriter.partial(s.systemAudioURL(id)).path))
}
@Test func speechWithoutARecordingLeavesNothingToKeep() {
let s = store()
let id = s.begin().id
s.end(heardSpeech: true)
#expect(s.session(id) == nil)
}
}