feat: add vocabulary-aware Transcriber and shared correction/result types

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 14:52:33 +02:00
co-authored by Claude Sonnet 5.5
parent c815e07b25
commit aec4aa7a5b
2 changed files with 78 additions and 0 deletions
@@ -0,0 +1,21 @@
import Foundation
import Testing
@testable import SstCore
private struct PlainTranscriber: Transcriber {
func transcribe(_ samples: [Float]) async throws -> String { "plain \(samples.count)" }
}
struct TranscriberVocabularyTests {
@Test func vocabularyVariantFallsBackToPlainTranscribe() async throws {
let result = try await PlainTranscriber().transcribe([0, 0, 0], vocabulary: ["Anthropic"])
#expect(result == "plain 3")
}
@Test func appliedCorrectionRoundTripsThroughJSON() throws {
let original = AppliedCorrection(heard: "cloud code", wrote: "Claude Code", rule: "cloud code", start: 12, length: 11)
let data = try JSONEncoder().encode(original)
let decoded = try JSONDecoder().decode(AppliedCorrection.self, from: data)
#expect(decoded == original)
}
}