gpt4 book ai didi

swift - AKAudioFile 导出异步路径错误

转载 作者:行者123 更新时间:2023-11-28 13:36:38 24 4
gpt4 key购买 nike

我正在尝试使用 AKAudioFile.exportAsynchronously 将 wav 转换为 m4a(基于此处的示例代码:https://audiokit.io/playgrounds/Playback/Exporting%20Files/)。我选择了.documents作为我的 BaseDirectory,但我不断收到 directory <my_dir> isn't valid错误——例如:

AKAudioFile+ProcessingAsynchronously.swift:exportAsynchronously(name:baseDir:exportFormat:fromSample:toSample:callback:):379:ERROR AKAudioFile export: directory "/var/mobile/Containers/Data/Application/20C913AD-B2F4-4F26-AAD2-0DFA0C65A886/Documents/All Of Me.mp4" isn't valid

在我看来,该 URL 看起来完全合理,怎么回事?

最佳答案

好的,按照@jake 的提示,解决方案是在传入 AKAudioFile 的 exportAsynchronously(name:baseDir:exportFormat:callback:) 之前显式处理空格。我刚刚做了:

var name = String(cafURL.lastPathComponent.split(separator: ".")[0])
name = name.replacingOccurrences(of: " ", with: "%20")
let exportFile = try AKAudioFile(readFileName: "\(name).wav", baseDir: .documents)
exportFile.exportAsynchronously(name: name, baseDir: .documents, exportFormat: .m4a, callback: self.callback)

关于swift - AKAudioFile 导出异步路径错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56535409/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com