(for slot: SettingsStore.DictationShortcutSlot, mode: ActiveRecordingMode)
| 3747 | } |
| 3748 | |
| 3749 | private func beginDictationRecording(for slot: SettingsStore.DictationShortcutSlot, mode: ActiveRecordingMode) { |
| 3750 | DebugLogger.shared.debug("Begin dictation recording for slot \(slot.rawValue)", source: "ContentView") |
| 3751 | self.appBench("begin_recording slot=\(slot.rawValue) mode=\(mode.rawValue)") |
| 3752 | if self.isOnboardingVoicePlaygroundStepActive { |
| 3753 | self.asr.finalText = "" |
| 3754 | self.settings.onboardingPlaygroundValidated = false |
| 3755 | self.settings.onboardingPlaygroundSkipped = false |
| 3756 | self.settings.playgroundUsed = false |
| 3757 | self.playgroundUsed = false |
| 3758 | } |
| 3759 | self.applyDictationShortcutSelectionContext(for: slot) |
| 3760 | self.setActiveRecordingMode(mode) |
| 3761 | self.rewriteModeService.clearState() |
| 3762 | |
| 3763 | guard !self.asr.isRunningOrStarting else { |
| 3764 | self.appBench("asr_start_skipped reason=already_running_or_starting") |
| 3765 | return |
| 3766 | } |
| 3767 | self.advanceOverlayLifecycle() |
| 3768 | if self.asr.micStatus == .authorized { |
| 3769 | self.appBench("overlay_mode_request mode=Dictation") |
| 3770 | self.menuBarManager.setOverlayMode(.dictation) |
| 3771 | self.menuBarManager.showRecordingOverlayImmediately() |
| 3772 | self.appBench("overlay_mode_requested mode=Dictation") |
| 3773 | self.appBench("overlay_phase phase=connecting") |
| 3774 | } |
| 3775 | Task { |
| 3776 | let asrStartStartedAt = ProcessInfo.processInfo.systemUptime |
| 3777 | DebugLogger.shared.benchmark("APP_BENCH", message: "asr_start_call", source: "AppBenchmark") |
| 3778 | let startOutcome = await self.asr.start(onCaptureStarted: { |
| 3779 | if SettingsStore.shared.enableTranscriptionSounds { |
| 3780 | TranscriptionSoundPlayer.shared.playStartSound() |
| 3781 | } |
| 3782 | self.captureRecordingContext() |
| 3783 | self.prewarmPrivateAIDictationIfNeeded(for: slot) |
| 3784 | self.appBench("overlay_phase phase=recording trigger=first_pcm") |
| 3785 | }) |
| 3786 | if startOutcome == .failed { |
| 3787 | self.menuBarManager.hideRecordingOverlayImmediately(reason: "asr_start_failed") |
| 3788 | } |
| 3789 | DebugLogger.shared.benchmark( |
| 3790 | "APP_BENCH", |
| 3791 | message: "asr_start_return elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - asrStartStartedAt) * 1000).rounded()))", |
| 3792 | source: "AppBenchmark" |
| 3793 | ) |
| 3794 | } |
| 3795 | } |
| 3796 | |
| 3797 | private func beginDictationRecording(for selection: SettingsStore.DictationPromptSelection, mode: ActiveRecordingMode) { |
| 3798 | let settings = SettingsStore.shared |
no test coverage detected