summaryrefslogtreecommitdiff
path: root/DayByDay/DayByDayApp.swift
blob: 860d74725face1ee3d785fe7653e8ea7a124f6cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
//  DayByDayApp.swift
//  DayByDay
//
//  Created by cmc on 2026-03-09.
//

import AVFoundation
import SwiftUI

@main
struct DayByDayApp: App {
    init() {
        Task.detached(priority: .background) {
            // Activate the audio session early so the first real tap doesn't block.
            try? AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
            try? AVAudioSession.sharedInstance().setActive(true)

            // Force singleton init (voice selection) and prime the TTS engine
            // with a silent utterance so subsequent speaks are instant.
            await MainActor.run {
                let warmup = AVSpeechUtterance(string: "")
                warmup.volume = 0
                SpeechSynthesizer.shared.speakUtterance(warmup)
            }
        }
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}