Skip to content

Commit

Permalink
Handle watchos case
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachNagengast committed Mar 2, 2024
1 parent 17f85d0 commit ad623d3
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Sources/WhisperKit/Core/AudioProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,23 +305,28 @@ public class AudioProcessor: NSObject, AudioProcessing {
if #available(macOS 14.0, *) {
return await AVAudioApplication.requestRecordPermission()
} else {
#if os(watchOS)
// watchOS does not support AVCaptureDevice
return true
#else
let microphoneStatus = AVCaptureDevice.authorizationStatus(for: .audio)
switch microphoneStatus {
case .notDetermined:
return await withCheckedContinuation { continuation in
AVCaptureDevice.requestAccess(for: .audio) { granted in
continuation.resume(returning: granted)
}
return await withCheckedContinuation { continuation in
AVCaptureDevice.requestAccess(for: .audio) { granted in
continuation.resume(returning: granted)
}
}
case .restricted, .denied:
Logging.error("Microphone access denied")
return false
Logging.error("Microphone access denied")
return false
case .authorized:
return true
return true
@unknown default:
Logging.error("Unknown authorization status")
return false
Logging.error("Unknown authorization status")
return false
}
#endif
}
}

Expand Down

0 comments on commit ad623d3

Please sign in to comment.