Centralize hallucination filter

This commit is contained in:
Beingpax 2025-09-16 17:30:46 +05:45
parent 011b310823
commit 2b787e8e64
4 changed files with 3 additions and 5 deletions

View File

@ -60,6 +60,7 @@ class AudioTranscriptionService: ObservableObject {
}
let transcriptionDuration = Date().timeIntervalSince(transcriptionStart)
text = WhisperHallucinationFilter.filter(text)
text = text.trimmingCharacters(in: .whitespacesAndNewlines)
// Apply word replacements if enabled

View File

@ -144,9 +144,6 @@ class ParakeetTranscriptionService: TranscriptionService {
text = WhisperTextFormatter.format(text)
}
// Apply hallucination and filler word filtering
text = WhisperHallucinationFilter.filter(text)
return text
}

View File

@ -107,8 +107,7 @@ actor WhisperContext {
for i in 0..<whisper_full_n_segments(context) {
transcription += String(cString: whisper_full_get_segment_text(context, i))
}
let filteredTranscription = WhisperHallucinationFilter.filter(transcription)
return filteredTranscription
return transcription
}
static func createContext(path: String) async throws -> WhisperContext {

View File

@ -268,6 +268,7 @@ class WhisperState: NSObject, ObservableObject {
let transcriptionStart = Date()
var text = try await transcriptionService.transcribe(audioURL: url, model: model)
text = WhisperHallucinationFilter.filter(text)
let transcriptionDuration = Date().timeIntervalSince(transcriptionStart)
if await checkCancellationAndCleanup() { return }