如何将Praat脚本应用于音频文件? [英] How to apply Praat script to an audio file?

查看:395
本文介绍了如何将Praat脚本应用于音频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Colab中使用praat更改音频文件的共振峰 .我发现脚本可以做到,

I'm trying to change formants of the audio file with praat in Colab. I found the script that does that, it's code and the code for calculating formants. I installed 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)

如何使用Linux命令行或python将此脚本应用于没有UI的多个wav文件?

How can I apply this script to multiple wav files without UI, using linux command line or python?

推荐答案

一般答案

你不知道.您运行了一个脚本,这完全取决于脚本的工作方式,工作的对象,获取这些对象的位置,获取它们的方式,等等.

The general answer

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.

您想要的脚本页面显示

此命令对每个选定的声音[执行某些操作]

This command [does something on] each selected Sound

所以第一件事就是打开您想要的文件并选择它们.

so the first thing will be to open the files you want and select them.

让我们假设您将使用少量声音来一次打开所有声音.如果您正在处理大量声音文件,或者文件太大而无法保存在内存中,则必须将作业分成较小的块.

Let's assume you'll be working with a small enough number of sounds to open them all in one 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.

一种方法是使用包装器脚本来打开文件,选择文件并执行所需的其他脚本:

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

我的Praat非常生锈,但这至少应该让您知道该怎么做(免责声明:我没有执行上述任何操作,但是概念应该不错).

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).

将包装器"脚本存储在某处,然后可以从命令行执行它:

With that "wrapper" script stored somewhere, you can then execute it from the command line:

$ praat /path/to/wrapper.praat

这篇关于如何将Praat脚本应用于音频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆