Skip to content

Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more

feat: include timestamps in labeled text

postoso9ea59419f71b
diff --git a/Sources/Fluid/Services/MeetingTranscriptionService.swift b/Sources/Fluid/Services/MeetingTranscriptionService.swift
index 8d046460..905af5fd 100644
--- a/Sources/Fluid/Services/MeetingTranscriptionService.swift
+++ b/Sources/Fluid/Services/MeetingTranscriptionService.swift
@@ -15,6 +15,21 @@ struct SpeakerTranscriptSegment: Identifiable, Sendable, Codable, Equatable {
"\(self.speaker)-\(self.startSeconds)"
}
+ var timestampText: String {
+ let total = Int(self.startSeconds.rounded(.down))
+ let hours = total / 3600
+ let minutes = (total % 3600) / 60
+ let seconds = total % 60
+ if hours > 0 {
+ return String(format: "%d:%02d:%02d", hours, minutes, seconds)
+ }
+ return String(format: "%d:%02d", minutes, seconds)
+ }
+
+ var plainText: String {
+ "[\(self.timestampText)] \(self.speaker): \(self.text)"
+ }
+
enum CodingKeys: String, CodingKey {
case speaker, startSeconds, endSeconds, text
}
@@ -587,7 +602,7 @@ final class MeetingTranscriptionService: ObservableObject {
}
let labeledText = segments
- .map { "\($0.speaker): \($0.text)" }
+ .map(\.plainText)
.joined(separator: "\n\n")
let avgConfidence = totalConfidence / Float(segments.count)
let processingTime = Date().timeIntervalSince(startTime)
diff --git a/Sources/Fluid/UI/MeetingTranscriptionView.swift b/Sources/Fluid/UI/MeetingTranscriptionView.swift
index 82254046..129889b1 100644
--- a/Sources/Fluid/UI/MeetingTranscriptionView.swift
+++ b/Sources/Fluid/UI/MeetingTranscriptionView.swift
@@ -382,7 +382,7 @@ struct MeetingTranscriptionView: View {
.fontWeight(.semibold)
.foregroundColor(Color.fluidGreen)
- Text(Self.timestampString(segment.startSeconds))
+ Text(segment.timestampText)
.font(.caption2)
.foregroundColor(.secondary)
}
@@ -672,18 +672,6 @@ struct MeetingTranscriptionView: View {
return formatter.string(fromByteCount: fileSize)
}
- /// Format seconds as m:ss (or h:mm:ss for long files) for speaker segment timestamps.
- private static func timestampString(_ seconds: Double) -> String {
- let total = Int(seconds.rounded(.down))
- let hours = total / 3600
- let minutes = (total % 3600) / 60
- let secs = total % 60
- if hours > 0 {
- return String(format: "%d:%02d:%02d", hours, minutes, secs)
- }
- return String(format: "%d:%02d", minutes, secs)
- }
-
private func copyToClipboard(_ text: String) {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(text, forType: .string)
diff --git a/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift b/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift
index 8c663cf4..77f00d22 100644
--- a/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift
+++ b/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift
@@ -93,4 +93,28 @@ final class SpeakerTurnMergingTests: XCTestCase {
}
}
+final class SpeakerTranscriptSegmentTests: XCTestCase {
+ func testPlainTextIncludesMinuteTimestamp() {
+ let segment = SpeakerTranscriptSegment(
+ speaker: "Speaker 1",
+ startSeconds: 65.9,
+ endSeconds: 70,
+ text: "Hello"
+ )
+
+ XCTAssertEqual(segment.plainText, "[1:05] Speaker 1: Hello")
+ }
+
+ func testPlainTextIncludesHourTimestamp() {
+ let segment = SpeakerTranscriptSegment(
+ speaker: "Speaker 2",
+ startSeconds: 3_661,
+ endSeconds: 3_670,
+ text: "Still here"
+ )
+
+ XCTAssertEqual(segment.plainText, "[1:01:01] Speaker 2: Still here")
+ }
+}
+
#endif