Skip to content
Merged
Changes from 1 commit
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
6 changes: 2 additions & 4 deletions Examples/SyncUps/SyncUps/Dependencies/SpeechRecognizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ extension SpeechClient: DependencyKey {
}

static var previewValue: SpeechClient {
let isRecording = LockIsolated(false)
return Self(
Self(
authorizationStatus: { .authorized },
requestAuthorization: { .authorized },
startTask: { _ in
AsyncThrowingStream { continuation in
Task { @MainActor in
isRecording.setValue(true)
var finalText = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor \
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \
Expand All @@ -50,7 +48,7 @@ extension SpeechClient: DependencyKey {
officia deserunt mollit anim id est laborum.
"""
var text = ""
while isRecording.value {
while true {
let word = finalText.prefix { $0 != " " }
try await Task.sleep(for: .milliseconds(word.count * 50 + .random(in: 0...200)))
finalText.removeFirst(word.count)
Expand Down