Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions speaktype/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let eventSource = CGEventSource(stateID: .hidSystemState)

if let keyDown = CGEvent(
keyboardEventSource: eventSource, virtualKey: dummyKeyCode, keyDown: true)
{
keyboardEventSource: eventSource, virtualKey: dummyKeyCode, keyDown: true) {
keyDown.post(tap: .cghidEventTap)
}

if let keyUp = CGEvent(
keyboardEventSource: eventSource, virtualKey: dummyKeyCode, keyDown: false)
{
keyboardEventSource: eventSource, virtualKey: dummyKeyCode, keyDown: false) {
keyUp.post(tap: .cghidEventTap)
}
}
Expand Down Expand Up @@ -225,8 +223,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

if let rawValue = UserDefaults.standard.string(forKey: "selectedHotkey"),
let option = HotkeyOption(rawValue: rawValue)
{
let option = HotkeyOption(rawValue: rawValue) {
return option
}

Expand Down
2 changes: 1 addition & 1 deletion speaktype/Constants/Shortcuts+Extensions.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AppKit
import Foundation
import KeyboardShortcuts
import AppKit

extension KeyboardShortcuts.Name {
static let toggleRecord = Self("toggleRecord", default: .init(.space, modifiers: [.control, .option]))
Expand Down
3 changes: 1 addition & 2 deletions speaktype/Controllers/MiniRecorderWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ class MiniRecorderWindowController: NSObject {
if response == .alertFirstButtonReturn {
if let url = URL(
string:
"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility")
{
"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility") {
NSWorkspace.shared.open(url)
}
}
Expand Down
2 changes: 1 addition & 1 deletion speaktype/Models/AIModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct AIModel: Identifiable, Equatable {
accuracy: 6.0, // ~12% WER
expectedSizeBytes: 30_000_000,
minimumRAMGB: 2
),
)
]

/// Returns the expected minimum size for a given model variant
Expand Down
1 change: 0 additions & 1 deletion speaktype/Models/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,3 @@ enum WhisperModel: String, Codable, CaseIterable, Identifiable {
self == .base || self == .small
}
}

2 changes: 1 addition & 1 deletion speaktype/Models/AppVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extension AppVersion {
"GPT-5.2 model support",
"Configurable audio resume delay for Bluetooth headphones",
"Redesigned Power Mode & Enhancement UI",
"Minor bug fixes and improvements",
"Minor bug fixes and improvements"
],
downloadURL: "https://speaktype.app/download/latest",
isRequired: false,
Expand Down
4 changes: 1 addition & 3 deletions speaktype/Models/AudioDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created on 2026-01-07.
//

import Foundation
import AVFoundation
import Foundation

/// Represents an audio input device
struct AudioDevice: Identifiable, Codable, Equatable {
Expand Down Expand Up @@ -122,7 +122,6 @@ enum AudioDeviceType: String, Codable, Equatable {
extension AudioDevice {
// Factory method removed as AVAudioSessionPortDescription is unavailable on macOS


/// System default device
static var systemDefault: AudioDevice {
AudioDevice(
Expand Down Expand Up @@ -192,4 +191,3 @@ enum InputMode: String, Codable, CaseIterable, Identifiable {
}
}
}

5 changes: 2 additions & 3 deletions speaktype/Models/HotkeyConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created on 2026-01-07.
//

import Foundation
import Carbon.HIToolbox
import Foundation

/// Configuration for global keyboard shortcuts
struct HotkeyConfiguration: Codable, Equatable, Identifiable {
Expand Down Expand Up @@ -92,7 +92,7 @@ struct HotkeyConfiguration: Codable, Equatable, Identifiable {
(UInt32(kVK_ANSI_Q), [.command]), // Quit
(UInt32(kVK_ANSI_W), [.command]), // Close
(UInt32(kVK_Tab), [.command]), // Switch apps
(UInt32(kVK_Space), [.command]), // Spotlight
(UInt32(kVK_Space), [.command]) // Spotlight
]

return commonConflicts.contains { code, flags in
Expand Down Expand Up @@ -211,4 +211,3 @@ private func keyCodeToString(_ keyCode: UInt32) -> String {
return String(format: "Key%02X", keyCode)
}
}

2 changes: 1 addition & 1 deletion speaktype/Models/HotkeyOption.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import AppKit
import Foundation

/// Hotkey options for triggering SpeakType recording
enum HotkeyOption: String, Codable, CaseIterable, Identifiable {
Expand Down
3 changes: 1 addition & 2 deletions speaktype/Models/RecordingSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created on 2026-01-07.
//

import Foundation
import AVFoundation
import Foundation

/// Represents an active or completed audio recording session
struct RecordingSession: Identifiable, Equatable {
Expand Down Expand Up @@ -199,4 +199,3 @@ extension RecordingSession {
)
}
}

1 change: 0 additions & 1 deletion speaktype/Models/TranscriptionResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,3 @@ extension TranscriptionResult {
)
}
}

1 change: 0 additions & 1 deletion speaktype/Models/TranscriptionState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ enum TranscriptionState: String, Codable, Equatable {
}
}
}

2 changes: 1 addition & 1 deletion speaktype/Services/AudioPlayerService.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation
import AVFoundation
import Combine
import Foundation

/// Service for playing back audio recordings
class AudioPlayerService: NSObject, ObservableObject, AVAudioPlayerDelegate {
Expand Down
12 changes: 5 additions & 7 deletions speaktype/Services/AudioRecordingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class AudioRecordingService: NSObject, ObservableObject {
AVLinearPCMBitDepthKey: 16,
AVLinearPCMIsFloatKey: false,
AVLinearPCMIsBigEndianKey: false,
AVLinearPCMIsNonInterleaved: false,
AVLinearPCMIsNonInterleaved: false
]

assetWriterInput = AVAssetWriterInput(mediaType: .audio, outputSettings: settings)
Expand Down Expand Up @@ -271,8 +271,7 @@ class AudioRecordingService: NSObject, ObservableObject {
// Ensure minimum recording duration to prevent empty/corrupted WAV files
if let startTime = currentFileURL?.path.components(separatedBy: "-").last?
.replacingOccurrences(of: ".wav", with: ""),
let startTimestamp = Double(startTime)
{
let startTimestamp = Double(startTime) {
let duration = Date().timeIntervalSince1970 - startTimestamp
if duration < 0.5 {
try? await Task.sleep(nanoseconds: UInt64((0.5 - duration) * 1_000_000_000))
Expand All @@ -297,8 +296,7 @@ class AudioRecordingService: NSObject, ObservableObject {
if let lastChunkInput = self.chunkAssetWriterInput,
let lastChunkWriter = self.chunkAssetWriter,
let lastChunkURL = self.chunkFileURL,
self.chunkIsSessionStarted
{
self.chunkIsSessionStarted {
self.resetChunkWriterState()

finishGroup.enter()
Expand Down Expand Up @@ -494,7 +492,7 @@ extension AudioRecordingService: AVCaptureAudioDataOutputSampleBufferDelegate {
AVLinearPCMBitDepthKey: 16,
AVLinearPCMIsFloatKey: false,
AVLinearPCMIsBigEndianKey: false,
AVLinearPCMIsNonInterleaved: false,
AVLinearPCMIsNonInterleaved: false
]
let ci = AVAssetWriterInput(mediaType: .audio, outputSettings: settings)
ci.expectsMediaDataInRealTime = true
Expand Down Expand Up @@ -651,7 +649,7 @@ extension AudioRecordingService: AVCaptureAudioDataOutputSampleBufferDelegate {
// Frequency = (Zero Crossings * Sample Rate) / (2 * N)
// Note: 'stride' reduces effective sample rate for this calculation, so we adjust
let effectiveSampleRate = Float(asbd.mSampleRate) / Float(stride)
let _ = (Float(zeroCrossings) * effectiveSampleRate) / (2.0 * Float(samplesToRead))
_ = (Float(zeroCrossings) * effectiveSampleRate) / (2.0 * Float(samplesToRead))

// Normalize Frequency for UI (0...1)
// Human voice fundamental freq is roughly 85Hz - 255Hz, harmonics go higher.
Expand Down
5 changes: 2 additions & 3 deletions speaktype/Services/HistoryService.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import Combine
import Foundation
import SwiftUI // For IndexSet operations if needed, though Foundation usually covers it, but error says missing import.

struct HistoryStatsEntry: Identifiable, Codable, Hashable {
Expand Down Expand Up @@ -153,8 +153,7 @@ class HistoryService: ObservableObject {
items = normalizedItems

if normalizedItems.count != decoded.count
|| zip(decoded, normalizedItems).contains(where: { $0.transcript != $1.transcript })
{
|| zip(decoded, normalizedItems).contains(where: { $0.transcript != $1.transcript }) {
saveHistory()
}

Expand Down
1 change: 0 additions & 1 deletion speaktype/Services/KeychainHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,3 @@ class KeychainHelper {
}
}
}

1 change: 0 additions & 1 deletion speaktype/Services/LicenseManager+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,3 @@ enum ProFeature {
}
}
}

3 changes: 1 addition & 2 deletions speaktype/Services/LicenseManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// License management and validation for Polar.sh integration
//

import Foundation
import Combine
import Foundation

enum LicenseError: LocalizedError {
case invalidKey
Expand Down Expand Up @@ -316,4 +316,3 @@ class LicenseManager: ObservableObject {
print("ℹ️ License deactivated locally. Key removed from Keychain.")
}
}

Loading