簡體   English   中英

如何將 Praat 腳本應用於音頻文件?

[英]How to apply Praat script to an audio file?

我正在嘗試在 Colab 中使用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)

如何使用 linux 命令行或 python 將此腳本應用於沒有 UI 的多個wav文件?

一般答案

你沒有。 你運行一個腳本,它完全取決於腳本它是如何工作的,它在什么對象上工作,這些對象在哪里被提取,它們是如何被提取的,等等。

因此,您始終必須查看如何應用特定腳本,而這始終需要弄清楚該腳本希望其輸入的方式,以及如何達到這一點。

具體答案

你想要的腳本頁面說

這個命令[做某事]每個選定的聲音

所以第一件事就是打開你想要的文件和 select 它們。

假設您將使用足夠少的聲音來在一個 go 中打開它們。 如果您正在處理大量聲音文件,或者文件太大而無法保存在 memory 中,則您必須將作業分批成更小的塊。

一種方法是使用包裝腳本打開文件,選擇它們並執行您想要的其他腳本:

# 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 相當生疏,但這至少應該讓你知道該怎么做(免責聲明:我沒有運行上述任何一個,但這些概念應該沒問題)。

將該“包裝器”腳本存儲在某處,然后您可以從命令行執行它:

$ praat /path/to/wrapper.praat

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM