-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/GetStream/stream-video-swift …
…into latest-protobuf-end-event
- Loading branch information
Showing
18 changed files
with
487 additions
and
91 deletions.
There are no files selected for viewing
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
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
63 changes: 63 additions & 0 deletions
63
...ntationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/18-transcriptions.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import StreamVideo | ||
import StreamVideoSwiftUI | ||
import SwiftUI | ||
import Combine | ||
import AVFoundation | ||
|
||
@MainActor | ||
fileprivate func content() { | ||
container { | ||
struct TranscriptionButtonView: View { | ||
|
||
@ObservedObject var viewModel: CallViewModel | ||
@State private var isTranscriptionAvailable = false | ||
@State private var isTranscribing = false | ||
|
||
init(viewModel: CallViewModel) { | ||
self.viewModel = viewModel | ||
self.isTranscriptionAvailable = (viewModel.call?.state.settings?.transcription.mode ?? .disabled) != .disabled | ||
self.isTranscribing = viewModel.call?.state.transcribing == true | ||
} | ||
|
||
var body: some View { | ||
if let call = viewModel.call { | ||
Group { | ||
if isTranscriptionAvailable { | ||
Button { | ||
Task { | ||
do { | ||
if isTranscribing { | ||
try await viewModel.call?.stopTranscription() | ||
} else { | ||
try await viewModel.call?.startTranscription() | ||
} | ||
} catch { | ||
log.error(error) | ||
} | ||
} | ||
} label: { | ||
Label { | ||
Text(isTranscribing ? "Disable Transcription" : "Transcription") | ||
} icon: { | ||
Image( | ||
systemName: isTranscribing | ||
? "captions.bubble.fill" | ||
: "captions.bubble" | ||
) | ||
} | ||
} | ||
.onReceive(call.state.$transcribing) { isTranscribing = $0 } | ||
} | ||
} | ||
.onReceive(call.state.$settings) { | ||
guard let mode = $0?.transcription.mode else { | ||
isTranscriptionAvailable = false | ||
return | ||
} | ||
isTranscriptionAvailable = mode != .disabled | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// | ||
// Copyright © 2024 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension StartTranscriptionResponse: @unchecked Sendable {} | ||
extension StopTranscriptionResponse: @unchecked Sendable {} | ||
extension TranscriptionSettings: @unchecked Sendable {} |
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
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
Oops, something went wrong.