Skip to content

Commit

Permalink
feat: copy text with eager decoding, keyboard shortcut (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
iGerman00 authored Jul 1, 2024
1 parent 5e01675 commit e68951f
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions Examples/WhisperAX/WhisperAX/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,26 @@ struct ContentView: View {
.toolbar(content: {
ToolbarItem {
Button {
let fullTranscript = formatSegments(confirmedSegments + unconfirmedSegments, withTimestamps: enableTimestamps).joined(separator: "\n")
#if os(iOS)
UIPasteboard.general.string = fullTranscript
#elseif os(macOS)
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(fullTranscript, forType: .string)
#endif
if (!enableEagerDecoding) {
let fullTranscript = formatSegments(confirmedSegments + unconfirmedSegments, withTimestamps: enableTimestamps).joined(separator: "\n")
#if os(iOS)
UIPasteboard.general.string = fullTranscript
#elseif os(macOS)
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(fullTranscript, forType: .string)
#endif
} else {
#if os(iOS)
UIPasteboard.general.string = confirmedText + hypothesisText
#elseif os(macOS)
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(confirmedText + hypothesisText, forType: .string)
#endif
}
} label: {
Label("Copy Text", systemImage: "doc.on.doc")
}
.keyboardShortcut("c", modifiers: .command)
.foregroundColor(.primary)
.frame(minWidth: 0, maxWidth: .infinity)
}
Expand Down

0 comments on commit e68951f

Please sign in to comment.