Added auto-text formatting toggle
This commit is contained in:
parent
030bda07da
commit
0faffa0155
@ -41,21 +41,29 @@ class CloudTranscriptionService: TranscriptionService {
|
|||||||
private lazy var openAICompatibleService = OpenAICompatibleTranscriptionService()
|
private lazy var openAICompatibleService = OpenAICompatibleTranscriptionService()
|
||||||
|
|
||||||
func transcribe(audioURL: URL, model: any TranscriptionModel) async throws -> String {
|
func transcribe(audioURL: URL, model: any TranscriptionModel) async throws -> String {
|
||||||
|
var text: String
|
||||||
|
|
||||||
switch model.provider {
|
switch model.provider {
|
||||||
case .groq:
|
case .groq:
|
||||||
return try await groqService.transcribe(audioURL: audioURL, model: model)
|
text = try await groqService.transcribe(audioURL: audioURL, model: model)
|
||||||
case .elevenLabs:
|
case .elevenLabs:
|
||||||
return try await elevenLabsService.transcribe(audioURL: audioURL, model: model)
|
text = try await elevenLabsService.transcribe(audioURL: audioURL, model: model)
|
||||||
case .deepgram:
|
case .deepgram:
|
||||||
return try await deepgramService.transcribe(audioURL: audioURL, model: model)
|
text = try await deepgramService.transcribe(audioURL: audioURL, model: model)
|
||||||
case .custom:
|
case .custom:
|
||||||
guard let customModel = model as? CustomCloudModel else {
|
guard let customModel = model as? CustomCloudModel else {
|
||||||
throw CloudTranscriptionError.unsupportedProvider
|
throw CloudTranscriptionError.unsupportedProvider
|
||||||
}
|
}
|
||||||
return try await openAICompatibleService.transcribe(audioURL: audioURL, model: customModel)
|
text = try await openAICompatibleService.transcribe(audioURL: audioURL, model: customModel)
|
||||||
default:
|
default:
|
||||||
throw CloudTranscriptionError.unsupportedProvider
|
throw CloudTranscriptionError.unsupportedProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if UserDefaults.standard.object(forKey: "IsTextFormattingEnabled") as? Bool ?? true {
|
||||||
|
text = WhisperTextFormatter.format(text)
|
||||||
|
}
|
||||||
|
|
||||||
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@ struct GeneralSettings: Codable {
|
|||||||
let isSoundFeedbackEnabled: Bool?
|
let isSoundFeedbackEnabled: Bool?
|
||||||
let isSystemMuteEnabled: Bool?
|
let isSystemMuteEnabled: Bool?
|
||||||
let isFallbackWindowEnabled: Bool?
|
let isFallbackWindowEnabled: Bool?
|
||||||
|
let isTextFormattingEnabled: Bool?
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VoiceInkExportedSettings: Codable {
|
struct VoiceInkExportedSettings: Codable {
|
||||||
@ -48,6 +49,7 @@ class ImportExportService {
|
|||||||
private let keyIsAutoCopyEnabled = "IsAutoCopyEnabled"
|
private let keyIsAutoCopyEnabled = "IsAutoCopyEnabled"
|
||||||
private let keyIsSoundFeedbackEnabled = "isSoundFeedbackEnabled"
|
private let keyIsSoundFeedbackEnabled = "isSoundFeedbackEnabled"
|
||||||
private let keyIsSystemMuteEnabled = "isSystemMuteEnabled"
|
private let keyIsSystemMuteEnabled = "isSystemMuteEnabled"
|
||||||
|
private let keyIsTextFormattingEnabled = "IsTextFormattingEnabled"
|
||||||
|
|
||||||
private init() {
|
private init() {
|
||||||
if let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String {
|
if let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String {
|
||||||
@ -92,7 +94,8 @@ class ImportExportService {
|
|||||||
isAutoCopyEnabled: whisperState.isAutoCopyEnabled,
|
isAutoCopyEnabled: whisperState.isAutoCopyEnabled,
|
||||||
isSoundFeedbackEnabled: soundManager.isEnabled,
|
isSoundFeedbackEnabled: soundManager.isEnabled,
|
||||||
isSystemMuteEnabled: mediaController.isSystemMuteEnabled,
|
isSystemMuteEnabled: mediaController.isSystemMuteEnabled,
|
||||||
isFallbackWindowEnabled: UserDefaults.standard.object(forKey: "isFallbackWindowEnabled") == nil ? true : UserDefaults.standard.bool(forKey: "isFallbackWindowEnabled")
|
isFallbackWindowEnabled: UserDefaults.standard.object(forKey: "isFallbackWindowEnabled") == nil ? true : UserDefaults.standard.bool(forKey: "isFallbackWindowEnabled"),
|
||||||
|
isTextFormattingEnabled: UserDefaults.standard.object(forKey: keyIsTextFormattingEnabled) as? Bool ?? true
|
||||||
)
|
)
|
||||||
|
|
||||||
let exportedSettings = VoiceInkExportedSettings(
|
let exportedSettings = VoiceInkExportedSettings(
|
||||||
@ -250,6 +253,9 @@ class ImportExportService {
|
|||||||
if let fallbackEnabled = general.isFallbackWindowEnabled {
|
if let fallbackEnabled = general.isFallbackWindowEnabled {
|
||||||
UserDefaults.standard.set(fallbackEnabled, forKey: "isFallbackWindowEnabled")
|
UserDefaults.standard.set(fallbackEnabled, forKey: "isFallbackWindowEnabled")
|
||||||
}
|
}
|
||||||
|
if let textFormattingEnabled = general.isTextFormattingEnabled {
|
||||||
|
UserDefaults.standard.set(textFormattingEnabled, forKey: self.keyIsTextFormattingEnabled)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.showRestartAlert(message: "Settings imported successfully from \(url.lastPathComponent). All settings (including general app settings) have been applied.")
|
self.showRestartAlert(message: "Settings imported successfully from \(url.lastPathComponent). All settings (including general app settings) have been applied.")
|
||||||
|
|||||||
@ -65,7 +65,9 @@ class LocalTranscriptionService: TranscriptionService {
|
|||||||
await whisperContext.fullTranscribe(samples: data)
|
await whisperContext.fullTranscribe(samples: data)
|
||||||
var text = await whisperContext.getTranscription()
|
var text = await whisperContext.getTranscription()
|
||||||
|
|
||||||
text = WhisperTextFormatter.format(text)
|
if UserDefaults.standard.object(forKey: "IsTextFormattingEnabled") as? Bool ?? true {
|
||||||
|
text = WhisperTextFormatter.format(text)
|
||||||
|
}
|
||||||
|
|
||||||
logger.notice("✅ Local transcription completed successfully.")
|
logger.notice("✅ Local transcription completed successfully.")
|
||||||
|
|
||||||
|
|||||||
@ -134,7 +134,10 @@ class NativeAppleTranscriptionService: TranscriptionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var finalTranscription = String(transcript.characters).trimmingCharacters(in: .whitespacesAndNewlines)
|
var finalTranscription = String(transcript.characters).trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
finalTranscription = WhisperTextFormatter.format(finalTranscription)
|
|
||||||
|
if UserDefaults.standard.object(forKey: "IsTextFormattingEnabled") as? Bool ?? true {
|
||||||
|
finalTranscription = WhisperTextFormatter.format(finalTranscription)
|
||||||
|
}
|
||||||
|
|
||||||
logger.notice("Native transcription successful. Length: \(finalTranscription.count) characters.")
|
logger.notice("Native transcription successful. Length: \(finalTranscription.count) characters.")
|
||||||
return finalTranscription
|
return finalTranscription
|
||||||
|
|||||||
@ -15,6 +15,7 @@ struct SettingsView: View {
|
|||||||
@ObservedObject private var mediaController = MediaController.shared
|
@ObservedObject private var mediaController = MediaController.shared
|
||||||
@AppStorage("hasCompletedOnboarding") private var hasCompletedOnboarding = true
|
@AppStorage("hasCompletedOnboarding") private var hasCompletedOnboarding = true
|
||||||
@AppStorage("isFallbackWindowEnabled") private var isFallbackWindowEnabled = true
|
@AppStorage("isFallbackWindowEnabled") private var isFallbackWindowEnabled = true
|
||||||
|
@AppStorage("IsTextFormattingEnabled") private var isTextFormattingEnabled = true
|
||||||
@State private var showResetOnboardingAlert = false
|
@State private var showResetOnboardingAlert = false
|
||||||
@State private var currentShortcut = KeyboardShortcuts.getShortcut(for: .toggleMiniRecorder)
|
@State private var currentShortcut = KeyboardShortcuts.getShortcut(for: .toggleMiniRecorder)
|
||||||
|
|
||||||
@ -101,6 +102,12 @@ struct SettingsView: View {
|
|||||||
}
|
}
|
||||||
.toggleStyle(.switch)
|
.toggleStyle(.switch)
|
||||||
.help("Display a fallback window with the transcribed text when automatic pasting is not possible")
|
.help("Display a fallback window with the transcribed text when automatic pasting is not possible")
|
||||||
|
|
||||||
|
Toggle(isOn: $isTextFormattingEnabled) {
|
||||||
|
Text("Automatic text formatting")
|
||||||
|
}
|
||||||
|
.toggleStyle(.switch)
|
||||||
|
.help("Apply intelligent text formatting with proper paragraphs and sentence structure to transcribed text")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user