Post

Replies

Boosts

Views

Activity

Starting/restarting SFSpeechRecognizer?
Hello all, I'm working on a project that involves listening to a person speak off of a script and I want to stop then restart the recognitionTask between sections so I don't run afoul of keeping the recognitionTask running for longer than it needs to. Also, I'd like to be able to flush the current input between sections so the input from the previous section doesn't roll over into the next one. This is based on the sample code for SFSpeechRecognizer so there's a chance I might be misunderstanding something. private func restartRecording() { let inputNode = audioEngine.inputNode audioEngine.stop() inputNode.removeTap(onBus: 0) recognitionRequest?.endAudio() recordingStarted = false recognitionTask?.cancel() do { try startRecording() } catch { print("Oopsie.") } } Here's my code. When I run it, the recognition task doesn't restart. Any ideas?
0
0
159
2w
How to generate CoreData objects when pushing a button?
I have a simple app that generates a record based on some user input. I'd like to take it to a summary of that record after taking in the input and generating a report from that input. The way I've rigged it so far is that the button fires off actions that generate the record also fires off the following code that redirects the UI to the record view. if let window = windowScene?.windows.first { window.rootViewController = UIHostingController(rootView: ReadingSpreadView(history: historyEntry, spread: spread, spreadTitles: spreadTitles)) window.makeKeyAndVisible() } However, when I hit my custom back button my MOC context is being lost somewhere as I'm getting: Context in environment is not connected to a persistent store coordinator: <NSManagedObjectContext: 0x30398c4e0> When I try to browse the history view. I suspect the reason why I need the custom back button and that I'm losing the MOC context is that I'm doing something wrong with CoreData, or SwiftUI or something. What's the appropriate way of doing this? Most of my experience has been in MVC frameworks on the Web with JavaScript frontend if that helps.
0
0
249
Aug ’24