From f8f94e2e707503df15926e253b8ab5b998d97ed5 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Wed, 3 Aug 2022 21:44:57 -0700 Subject: [PATCH] add text to speech play button on web links --- .../Views/WebReader/WebReaderContainer.swift | 18 ++++++++++++++++++ .../Sources/Utils/FeatureFlags.swift | 1 + 2 files changed, 19 insertions(+) diff --git a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift index e12ba8b07..103c18056 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WebReader/WebReaderContainer.swift @@ -1,6 +1,8 @@ +import AVFoundation import Models import Services import SwiftUI +import Utils import Views import WebKit @@ -68,6 +70,22 @@ struct WebReaderContainerView: View { .scaleEffect(navBarVisibilityRatio) Spacer() #endif + if FeatureFlag.enableTextToSpeechButton { + Button( + action: { + guard let htmlContent = item.htmlContent else { return } + let synthesizer = AVSpeechSynthesizer() + synthesizer.speak(AVSpeechUtterance(string: htmlContent)) + AVSpeechUtterance(ss,) + }, + label: { + Image(systemName: "play") + .font(.appTitleTwo) + } + ) + .padding(.horizontal) + .scaleEffect(navBarVisibilityRatio) + } Button( action: { showPreferencesPopover.toggle() }, label: { diff --git a/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift b/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift index 5c0aab9af..5ace227a6 100644 --- a/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift +++ b/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift @@ -14,4 +14,5 @@ public enum FeatureFlag { public static let enableShareButton = false public static let enableSnooze = false public static let enableGridCardsOnPhone = false + public static let enableTextToSpeechButton = true }