This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
@State var showOverlay = false | |
@State var curColor = Color.blue | |
var body: some View { | |
Text("Hello World") | |
.frame(width: 100, height: 100) | |
.background(curColor) | |
.cornerRadius(20) | |
.onTapGesture { self.showOverlay.toggle() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
@State var textColor = Color.blue | |
@State var showOverlay = false | |
var body: some View { | |
Text("Hello World") | |
.frame(width: 100, height: 100) | |
.background(textColor) | |
.onTapGesture { self.showOverlay.toggle() } | |
.overlay( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private let speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))! | |
private var recognitionRequest: SFSpeechAudioBufferRecognitionRequest? | |
private var recognitionTask: SFSpeechRecognitionTask? | |
private func setupRecognition() { | |
let recognitionRequest = SFSpeechAudioBufferRecognitionRequest() | |
recognitionRequest.shouldReportPartialResults = true | |
recognitionTask = speechRecognizer.recognitionTask(with: recognitionRequest) { [weak self] result, error in | |
result!.bestTranscription.formattedString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//*********went from this********* | |
let asset = AVURLAsset(url: url) | |
guard let audioTrack = asset.tracks(withMediaType: AVMediaType.audio).first else { | |
print("can't get audioTrack") | |
return | |
} | |
playerItem = AVPlayerItem(asset: asset) | |
tap = MYAudioTapProcessor(audioAssetTrack: audioTrack) | |
tap.delegate = self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CaptionCollector: ObservableObject { | |
@Published var caption: String = "" | |
} | |
@ObservedObject var capCollect = CaptionCollector() | |
//... | |
Text(self.capCollect.caption) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CaptionCollector: ObservableObject { | |
@Published var caption: String = "" | |
} | |
@ObservedObject var capCollect = CaptionCollector() | |
//protocol function | |
func captioningUpdated(caption: String) { | |
self.capCollect.caption = caption | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Thanks to https://developer.apple.com/documentation/speech/recognizing_speech_in_live_audio | |
func startRecording() throws { | |
// Cancel the previous task if it's running. | |
recognitionTask?.cancel() | |
self.recognitionTask = nil | |
// Configure the audio session for the app. | |
let audioSession = AVAudioSession.sharedInstance() | |
try audioSession.setCategory(.record, mode: .measurement, options: .duckOthers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vapor | |
import Transform | |
import SwiftKotlinFramework | |
import Cocoa | |
/// Here we have a controller that helps facilitate | |
/// creating typical REST patterns | |
final class TranslateKotlinController { | |
/// POST /translate | |
func store(_ req: Request) throws -> Future<View> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set("title") { Translate Kotlin } | |
#set("body") { | |
<textarea id="constantsText" rows="4" cols="50"> | |
Please put swift code here... | |
</textarea> | |
<button onclick="post()">Click me</button> | |
<script> | |
function post() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
var body: some View { | |
VStack { | |
URLPreview(previewURL: URL(string: "https://medium.com")!) | |
.aspectRatio(contentMode: .fit) | |
.padding() | |
} | |
} | |
} |
OlderNewer