let base64String: String = "некоторый пример base64" let audioData = Data (base64Encoded: base64String, параметры: .ignoreUnknownCharacters) если audioData! = Nil {если let audData = audioData {self.playAudio (audioData: audData)}}
func playAudio(audioData : Data){
let filename = documentsDirectory.appendingPathComponent("output.mp3")
do {
try audioData.write(to: filename, options: .atomicWrite)
do {
audioPlayer = try AVAudioPlayer(contentsOf: filename)
guard let player = audioPlayer else { return }
player.prepareToPlay()
player.play()
} catch let error {
print(error.localizedDescription)
}
} catch {
}
}