From 2b137c7706707418ab74711d59e924d069965248 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 11 Jul 2024 17:17:24 +0800 Subject: [PATCH] Remove ultra realistic voices --- .../TextToSpeechVoiceSelectionView.swift | 66 ++----------------- .../TextToSpeechVoiceSelectionViewModel.swift | 39 ----------- 2 files changed, 6 insertions(+), 99 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/TextToSpeechVoiceSelectionView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/TextToSpeechVoiceSelectionView.swift index 4b6fd3fdd..845db8f8e 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/TextToSpeechVoiceSelectionView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/TextToSpeechVoiceSelectionView.swift @@ -23,72 +23,18 @@ var body: some View { Group { Form { - if language.key == "en" { - if viewModel.waitingForRealisticVoices { - HStack { - Text(LocalText.texttospeechBetaSignupInProcess) - Spacer() - ProgressView() + if showLanguageChanger { + Section("Language") { + NavigationLink(destination: TextToSpeechLanguageView().navigationTitle("Language")) { + Text(audioController.currentVoiceLanguage.name) } - } else { - Toggle("Use Ultra Realistic Voices", isOn: $viewModel.realisticVoicesToggle) - .accentColor(Color.green) - } - - if !viewModel.waitingForRealisticVoices, !audioController.ultraRealisticFeatureKey.isEmpty { - Text(LocalText.texttospeechBetaRealisticVoiceLimit) - .multilineTextAlignment(.leading) - } else if audioController.ultraRealisticFeatureRequested { - Text(LocalText.texttospeechBetaRequestReceived) - .multilineTextAlignment(.leading) - } else { - Text(LocalText.texttospeechBetaWaitlist) - .multilineTextAlignment(.leading) } } - - if viewModel.realisticVoicesToggle, !audioController.ultraRealisticFeatureKey.isEmpty { - if showLanguageChanger { - Section("Language") { - NavigationLink(destination: TextToSpeechLanguageView().navigationTitle("Language")) { - Text(audioController.currentVoiceLanguage.name) - } - } - } - ultraRealisticVoices - } else { - if showLanguageChanger { - Section("Language") { - NavigationLink(destination: TextToSpeechLanguageView().navigationTitle("Language")) { - Text(audioController.currentVoiceLanguage.name) - } - } - } - standardVoices - } + standardVoices } } .navigationTitle("Choose a Voice") - .onAppear { - // swiftlint:disable:next line_length - viewModel.realisticVoicesToggle = (audioController.useUltraRealisticVoices && !audioController.ultraRealisticFeatureKey.isEmpty) - } - .onChange(of: viewModel.realisticVoicesToggle) { value in - if value, audioController.ultraRealisticFeatureKey.isEmpty { - // User wants to sign up - viewModel.waitingForRealisticVoices = true - Task { - await viewModel.requestUltraRealisticFeatureAccess( - dataService: self.dataService, - audioController: audioController - ) - } - } else if value, !audioController.ultraRealisticFeatureKey.isEmpty { - audioController.useUltraRealisticVoices = true - } else if !value { - audioController.useUltraRealisticVoices = false - } - }.onReceive(NotificationCenter.default.publisher(for: Notification.Name("ScrollToTop"))) { _ in + .onReceive(NotificationCenter.default.publisher(for: Notification.Name("ScrollToTop"))) { _ in dismiss() } } diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/TextToSpeechVoiceSelectionViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/TextToSpeechVoiceSelectionViewModel.swift index 7595513bb..0e988d6a2 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/TextToSpeechVoiceSelectionViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/TextToSpeechVoiceSelectionViewModel.swift @@ -15,47 +15,8 @@ @MainActor final class TextToSpeechVoiceSelectionViewModel: ObservableObject { @Published var playbackSample: String? - @Published var realisticVoicesToggle: Bool = false - @Published var waitingForRealisticVoices: Bool = false @Published var showSnackbar: Bool = false var snackbarMessage: String? - - func requestUltraRealisticFeatureAccess( - dataService: DataService, - audioController: AudioController - ) async { - do { - let feature = try await dataService.optInFeature(name: "ultra-realistic-voice") - DispatchQueue.main.async { - if let feature = feature { - audioController.useUltraRealisticVoices = true - audioController.ultraRealisticFeatureRequested = true - audioController.ultraRealisticFeatureKey = feature.granted ? feature.token : "" - if feature.granted, !Voices.isUltraRealisticVoice(audioController.currentVoice) { - // Attempt to set to an ultra voice - if let voice = Voices.UltraPairs.first { - audioController.currentVoice = voice.firstKey - } - } - self.realisticVoicesToggle = true - } else { - audioController.useUltraRealisticVoices = false - audioController.ultraRealisticFeatureKey = "" - audioController.ultraRealisticFeatureRequested = false - self.realisticVoicesToggle = false - } - self.waitingForRealisticVoices = false - } - } catch { - print("ERROR OPTING INTO FEATURE", error) - audioController.useUltraRealisticVoices = false - realisticVoicesToggle = false - waitingForRealisticVoices = false - audioController.ultraRealisticFeatureRequested = false - snackbarMessage = "Error signing up for beta. Please try again." - showSnackbar = true - } - } } #endif