Post

Replies

Boosts

Views

Activity

Cannot find Interface Builder Preview in Xcode 15
According to Apple's official documentation titled "Previewing localizations" https://developer.apple.com/documentation/xcode/previewing-localizations/# "For Interface Builder, you can preview localizations any time during development by choosing localizations including pseudolanguages in the preview. You don’t need to build and run your app to see the preview." However, this functionality seems to have been removed in Xcode 15. "Preview" is not available in the Editor option menu in Interface Builder. Compared to what's available before:
1
0
732
Oct ’23
Issue with recognitionTask(with:resultHandler:) and SFSpeechURLRecognitionRequest
Xcode Version 15.0 beta 4 (15A5195m) or Version 14.3.1 (14E300c) same issue when running iOS Simulator iPhone 14 Pro (iOS 17 or iOS 16.4) or iPhone 12 (iOS 17.0 build 21A5277j) just started to play around with SFSpeechRecognition. Ran into the issue with SFSpeechURLRecognitionRequest. the simple project is just a ContentView with 2 buttons ( one for selecting audio file, one for starting transcribing ), a SpeechRecognizer ( from Apple sample code "Transcribing speech to text" with minor additions ) After selecting an audio file, tap the transcribe button, the following error logs appear in the debugger console after the execution of recognitionTask(with:resultHandler:). 2023-07-18 13:58:16.562706-0400 TranscriberMobile[6818:475161] [] <<<< AVAsset >>>> +[AVURLAsset _getFigAssetCreationOptionsFromURLAssetInitializationOptions:assetLoggingIdentifier:figAssetCreationFlags:error:]: AVURLAssetHTTPHeaderFieldsKey must be a dictionary 2023-07-18 13:58:16.792219-0400 TranscriberMobile[6818:475166] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x60000023dd00> F8BB1C28-BAE8-11D6-9C31-00039315CD46 2023-07-18 13:58:16.824333-0400 TranscriberMobile[6818:475166] HALC_ProxyObjectMap.cpp:153 HALC_ProxyObjectMap::_CopyObjectByObjectID: failed to create the local object 2023-07-18 13:58:16.824524-0400 TranscriberMobile[6818:475166] HALC_ShellDevice.cpp:2609 HALC_ShellDevice::RebuildControlList: couldn't find the control object 2023-07-18 13:58:16.872935-0400 TranscriberMobile[6818:475165] [] <<<< FAQ Offline Mixer >>>> FigAudioQueueOfflineMixerCreate: [0x10744b8d0] failed to query kAudioConverterPrimeInfo err=561211770, assuming zero priming 2023-07-18 13:58:16.890002-0400 TranscriberMobile[6818:474951] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "originator doesn't have entitlement com.apple.runningboard.mediaexperience" UserInfo={NSLocalizedFailureReason=originator doesn't have entitlement com.apple.runningboard.mediaexperience}> 2023-07-18 13:58:16.890319-0400 TranscriberMobile[6818:474951] [AMCP] 259 HALRBSAssertionGlue.mm:98 Failed to acquire the AudioRecording RBSAssertion for pid: 6818 with code: 1 - RBSServiceErrorDomain 2023-07-18 13:58:16.893137-0400 TranscriberMobile[6818:474951] [assertion] Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "originator doesn't have entitlement com.apple.runningboard.mediaexperience" UserInfo={NSLocalizedFailureReason=originator doesn't have entitlement com.apple.runningboard.mediaexperience}> 2023-07-18 13:58:16.893652-0400 TranscriberMobile[6818:474951] [AMCP] 259 HALRBSAssertionGlue.mm:98 Failed to acquire the MediaPlayback RBSAssertion for pid: 6818 with code: 1 - RBSServiceErrorDomain Since the AVURLAsset is not created manually, how to get around the initial error "AVURLAssetHTTPHeaderFieldsKey must be a dictionary"? SpeechRecognizer.swift import Foundation import AVFoundation import Speech import SwiftUI /// A helper for transcribing speech to text using SFSpeechRecognizer and AVAudioEngine. actor SpeechRecognizer: ObservableObject { // ... @MainActor func startTranscribingAudioFile(_ audioURL: URL?) { Task { await transcribeAudioFile(audioURL) } } // ... private func transcribeAudioFile(_ audioURL: URL?) { guard let recognizer, recognizer.isAvailable else { self.transcribe(RecognizerError.recognizerIsUnavailable) return } guard let audioURL else { self.transcribe(RecognizerError.nilAudioFileURL) return } let request = SFSpeechURLRecognitionRequest(url: audioURL) request.shouldReportPartialResults = true self.audioURLRequest = request self.task = recognizer.recognitionTask(with: request, resultHandler: { [weak self] result, error in self?.audioFileRecognitionHandler(result: result, error: error) }) } // ... nonisolated private func audioFileRecognitionHandler(result: SFSpeechRecognitionResult?, error: Error?) { if let result { transcribe(result.bestTranscription.formattedString) } if let error { Task { @MainActor in await reset() transcribe(error) } } } } ContentView.swift import SwiftUI struct ContentView: View { @State var showFileBrowser = false @State var audioFileURL: URL? = nil @StateObject var speechRecognizer = SpeechRecognizer() var body: some View { VStack(spacing: 24) { Button { self.showFileBrowser.toggle() } label: { Text("Select an audio file to transcribe") } Text(audioFileURL != nil ? audioFileURL!.absoluteString : "No audio file selected") .multilineTextAlignment(.center) Button { speechRecognizer.startTranscribingAudioFile(audioFileURL) } label: { Text("Transcribe") } Text(speechRecognizer.transcript == "" ? "No transcript yet" : speechRecognizer.transcript) .multilineTextAlignment(.leading) } .padding() .fileImporter(isPresented: $showFileBrowser, allowedContentTypes: [.audio]) { result in switch result { case .success(let fileURL): fileURL.startAccessingSecurityScopedResource() audioFileURL = fileURL print(fileURL) case .failure(let error): NSLog("%s", error.localizedDescription) } } } }
2
1
1.1k
Jul ’23