Post

Replies

Boosts

Views

Activity

Reply to SpeechTranscriber supported Devices
This class below is my first attempt at determining if a device supports speech transcription. Any feedback on devices it works or doesn't work on would be appreciated! import Foundation import UIKit final class SpeechTranscriberSupportChecker { static let shared = SpeechTranscriberSupportChecker() private var cachedSupportsSpeechTranscriber: Bool? private init() {} func supportsSpeechTranscriber() -> Bool { if let cached = cachedSupportsSpeechTranscriber { return cached } let result: Bool if !isRealDevice() { result = false } else if !isRunningOS26orLater() { result = false } else { result = !isOnUnsupportedHardware() } cachedSupportsSpeechTranscriber = result return result } // MARK: - Checks private func isRealDevice() -> Bool { #if targetEnvironment(simulator) return false #else return true #endif } private func isRunningOS26orLater() -> Bool { let major = ProcessInfo.processInfo.operatingSystemVersion.majorVersion return major >= 26 } /// Devices that CAN run iOS/iPadOS 26 but DO NOT support Speech Transcriber private func isOnUnsupportedHardware() -> Bool { let model = deviceModelIdentifier() let unsupportedModels: Set<String> = [ // MARK: - iPhone (A13 – Not Supported) "iPhone12,1", // iPhone 11 "iPhone12,3", // iPhone 11 Pro "iPhone12,5", // iPhone 11 Pro Max "iPhone12,8", // iPhone SE 2nd Gen // MARK: - iPad (A12/A13/A14 Devices) "iPad11,6", "iPad11,7", // iPad 8th Gen (A12) "iPad12,1", "iPad12,2", // iPad 9th Gen (A13) "iPad11,3", "iPad11,4", // iPad Air 3rd Gen (A12) "iPad11,1", "iPad11,2" // iPad mini 5th Gen (A12) ] return unsupportedModels.contains(model) } private func deviceModelIdentifier() -> String { var systemInfo = utsname() uname(&systemInfo) return withUnsafeBytes(of: systemInfo.machine) { rawPtr in rawPtr.compactMap { c in c != 0 ? String(UnicodeScalar(UInt8(c))) : nil }.joined() } } } // To use: //if SpeechTranscriberSupportChecker.shared.supportsSpeechTranscriber() { // print("Speech Transcriber supported.") //} else { // print("Speech Transcriber NOT supported.") //}
Topic: Media Technologies SubTopic: Audio Tags:
3w