[英]How to apply Praat script to an audio file?
I'm trying to change formants of the audio file with praat
in Colab.我正在尝试在 Colab 中使用praat
更改音频文件的共振峰。 I found the script that does that, it's code and the code for calculating formants .我找到了执行此操作的脚本,它是代码和计算共振峰的代码。 I installed praat
:我安装了praat
:
!sudo apt-get update -y -qqq --fix-missing && apt-get install -y -qqq praat > /dev/null
!wget -qqq http://www.praatvocaltoolkit.com/downloads/plugin_VocalToolkit.zip
!unzip -qqq /content/plugin_VocalToolkit.zip > /dev/null
with open('/content/script.praat', 'w') as f:
f.write(r"""writeInfoLine: preferencesDirectory$""")
!praat /content/script.praat
/root/.praat-dir
!mv /content/plugin_VocalToolkit/* /root/.praat-dir
!praat --version
Praat 6.0.37 (February 3 2018)
How can I apply this script to multiple wav
files without UI, using linux command line or python?如何使用 linux 命令行或 python 将此脚本应用于没有 UI 的多个wav
文件?
You don't.你没有。 You run a script, and it's entirely up to the script how it works, what objects it works on, where those objects are fetched, how they are fetched, etc.你运行一个脚本,它完全取决于脚本它是如何工作的,它在什么对象上工作,这些对象在哪里被提取,它们是如何被提取的,等等。
So you always have to look at how to apply a specific script, and that always entails figuring out how that script wants its input, and how to get to that point.因此,您始终必须查看如何应用特定脚本,而这始终需要弄清楚该脚本希望其输入的方式,以及如何达到这一点。
The page for the script you want says你想要的脚本页面说
This command [does something on] each selected Sound这个命令[做某事]每个选定的声音
so the first thing will be to open the files you want and select them.所以第一件事就是打开你想要的文件和 select 它们。
Let's assume you'll be working with a small enough number of sounds to open them all in one go.假设您将使用足够少的声音来在一个 go 中打开它们。 If you are working on a lot of sound files, or files that are too large to hold in memory, you'll have to batch the job into smaller chunks.如果您正在处理大量声音文件,或者文件太大而无法保存在 memory 中,则您必须将作业分批成更小的块。
One way to do this would be with a wrapper script that opened your files, selected them, and executed the other script you want:一种方法是使用包装脚本打开文件,选择它们并执行您想要的其他脚本:
# Get a list of all your files
files = Create Strings as file list: "list", "/some/path/*.wav"
total_files = Get number of strings
# Open each of them
for i to total_files
selectObject: files
filename$ = Get string: i
sounds[i] = Read from file: "/some/path/" + filename$
endfor
# Clear the selection
nocheck selectObject(undefined)
# Add each sound to your selection
for i to total_files
plusObject: sounds[i]
endfor
# Run your script
runScript: path_to_script$, ...
# where the ... is the list of arguments your script expects
# In your specific case, it would be something like
runScript: preferencesDirectory$ + "/plugin_VocalToolkit/changeformants.praat",
... 500, 1500, 2500, 0, 0, 5500, "yes", "yes"
# ,-´ ,-´ ,--´ ,--´ ,-´ ^ ^ ^
# New F1, F2, F3, F4, and F5 means | | |
# Max formant | |
# Process only voiced parts |
# Retrieve intensity contour
# Do something with whatever the script gives you
My Praat is pretty rusty, but this should at least give you an idea of what to do (disclaimer: I haven't run any of the above, but the concepts should be fine).我的 Praat 相当生疏,但这至少应该让你知道该怎么做(免责声明:我没有运行上述任何一个,但这些概念应该没问题)。
With that "wrapper" script stored somewhere, you can then execute it from the command line:将该“包装器”脚本存储在某处,然后您可以从命令行执行它:
$ praat /path/to/wrapper.praat
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.