Remove ultra realistic voices
This commit is contained in:
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user