Feat: Respect VAD user setting in ParakeetTranscriptionService
This commit is contained in:
parent
c0ed2dc78a
commit
5eacee467a
@ -79,6 +79,9 @@ class ParakeetTranscriptionService: TranscriptionService {
|
|||||||
|
|
||||||
// Use VAD to get speech segments
|
// Use VAD to get speech segments
|
||||||
var speechAudio: [Float] = []
|
var speechAudio: [Float] = []
|
||||||
|
let isVADEnabled = UserDefaults.standard.object(forKey: "IsVADEnabled") as? Bool ?? true
|
||||||
|
|
||||||
|
if isVADEnabled {
|
||||||
if let modelPath = await VADModelManager.shared.getModelPath() {
|
if let modelPath = await VADModelManager.shared.getModelPath() {
|
||||||
if let vad = VoiceActivityDetector(modelPath: modelPath) {
|
if let vad = VoiceActivityDetector(modelPath: modelPath) {
|
||||||
let speechSegments = vad.process(audioSamples: audioSamples)
|
let speechSegments = vad.process(audioSamples: audioSamples)
|
||||||
@ -109,6 +112,10 @@ class ParakeetTranscriptionService: TranscriptionService {
|
|||||||
logger.warning("🦜 VAD model path not found. Transcribing original audio.")
|
logger.warning("🦜 VAD model path not found. Transcribing original audio.")
|
||||||
speechAudio = audioSamples
|
speechAudio = audioSamples
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.notice("🦜 VAD is disabled by user setting. Transcribing original audio.")
|
||||||
|
speechAudio = audioSamples
|
||||||
|
}
|
||||||
|
|
||||||
// Validate audio data after VAD
|
// Validate audio data after VAD
|
||||||
guard speechAudio.count >= 16000 else {
|
guard speechAudio.count >= 16000 else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user