Files
Termind/Frameworks/TermindInfrastructure/Speech/SpeechAudioInput.swift
T
2026-09-12 23:57:33 +08:00

17 lines
589 B
Swift

@preconcurrency import AVFoundation
public typealias SpeechAudioBufferHandler = @Sendable (AVAudioPCMBuffer) -> Void
public typealias SpeechAudioLevelHandler = @Sendable (Float) -> Void
/// Apple Speech consumes PCM buffers, while each supported OS owns the
/// permission and audio-device lifecycle used to produce them.
@MainActor
public protocol SpeechAudioInput: AnyObject {
func requestAuthorization() async -> Bool
func start(
bufferHandler: @escaping SpeechAudioBufferHandler,
levelHandler: @escaping SpeechAudioLevelHandler
) throws
func stop()
}