mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix build
This commit is contained in:
parent
614f33d041
commit
458f1ca584
15
submodules/Speak/BUILD
Normal file
15
submodules/Speak/BUILD
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||||
|
|
||||||
|
swift_library(
|
||||||
|
name = "Speak",
|
||||||
|
module_name = "Speak",
|
||||||
|
srcs = glob([
|
||||||
|
"Sources/**/*.swift",
|
||||||
|
]),
|
||||||
|
deps = [
|
||||||
|
"//submodules/Display:Display",
|
||||||
|
],
|
||||||
|
visibility = [
|
||||||
|
"//visibility:public",
|
||||||
|
],
|
||||||
|
)
|
18
submodules/Speak/Sources/Speak.swift
Normal file
18
submodules/Speak/Sources/Speak.swift
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import Foundation
|
||||||
|
import AVFoundation
|
||||||
|
|
||||||
|
// Incuding at least one Objective-C class in a swift file ensures that it doesn't get stripped by the linker
|
||||||
|
private final class LinkHelperClass: NSObject {
|
||||||
|
}
|
||||||
|
|
||||||
|
public func speakText(_ text: String) {
|
||||||
|
guard !text.isEmpty else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let speechSynthesizer = AVSpeechSynthesizer()
|
||||||
|
let utterance = AVSpeechUtterance(string: text)
|
||||||
|
if #available(iOS 11.0, *), let language = NSLinguisticTagger.dominantLanguage(for: text) {
|
||||||
|
utterance.voice = AVSpeechSynthesisVoice(language: language)
|
||||||
|
}
|
||||||
|
speechSynthesizer.speak(utterance)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user