gpt4 book ai didi

audio - Applescript:导出 QuickTime 录音

转载 作者:行者123 更新时间:2023-12-02 14:04:20 26 4
gpt4 key购买 nike

使用以下苹果脚本,我尝试

  1. 使用“QuickTime Player”录制音频几秒钟

  2. 导出轨道并将其保存到桌面

    tell application "QuickTime Player"
    launch

    set doku to new audio recording
    start doku
    delay 4
    stop doku
    set savePath to "~/Desktop/record.mp3"
    set newDoc to last item of (documents whose name contains "Untitled")
    export newDoc in file savePath using settings preset "Audio Only"

    end tell

创建新的录音似乎很容易,但由于某种原因导出命令不起作用。错误消息显示,我没有导出它的权限。

最佳答案

这似乎确实是一个沙箱问题,但如果您将文件路径引用从 QuickTime Player block 移到 Finder block 中,它就会起作用。另外,您的文件名应以“.m4a”而不是“.mp3”结尾,因为 QuickTime Player 创建 MP4 音频文件(文件扩展名“.m4a”)而不是 MP3 音频文件(文件扩展名“.mp3”)。

所以这个版本的脚本可以工作:

tell application "Finder"
set savePath to (the path to the desktop folder as text) & "record.m4a"
tell application "QuickTime Player"
activate
set doku to new audio recording
start doku
delay 4
stop doku
set newDoc to last item of (documents whose name contains "Untitled")
export newDoc in file savePath using settings preset "Audio Only"
end tell
end tell

关于audio - Applescript:导出 QuickTime 录音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23709421/

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