Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about running Praat scripts using speakr #12

Open
JackGuo15 opened this issue Jul 19, 2024 · 6 comments
Open

Question about running Praat scripts using speakr #12

JackGuo15 opened this issue Jul 19, 2024 · 6 comments

Comments

@JackGuo15
Copy link

Hi Stefano,

I hope this message finds you well. My name is Ruohan, and I am a second-year PhD student at UCL.

I am using speakr to run Praat scripts and extract data from the outcomes. Your tutorial on passing arguments to Praat forms (https://cran.r-project.org/web/packages/speakr/vignettes/run-praat.html) has been incredibly helpful, and I have successfully set most field types in Praat forms, such as option and boolean.

However, I encountered an issue when trying to run a specific Praat script using speakr. The script (https://sites.google.com/view/uhm-o-meter/scripts/syllablenuclei_v3?authuser=0) measures speech rate and requires 11 arguments. The first argument needs a directory path to the audio files (please see the attached snapshots), and I haven't been able to get this right in R.

Could you please advise me on how to pass this type of argument to Praat scripts from R? I can provide the code I used if that would help with the diagnosis.

Thank you in advance for your assistance.

Best wishes,
Ruohan

Praat_script Praat_window
@stefanocoretta
Copy link
Owner

Hi Ruohan! Glad to hear you find speakr helpful. :)

A file path should be a simple string, which shouldn't create issues. Can I see the R code where you call praat_run() and the error message?

@JackGuo15
Copy link
Author

Hi Ruohan! Glad to hear you find speakr helpful. :)

A file path should be a simple string, which shouldn't create issues. Can I see the R code where you call praat_run() and the error message?

Hi Stefano,

Good afternoon! Thank you so much for your response, and I'm so sorry for my late reply.

Please see attached a snapshot of the code I used and the warning I got from R. It seems that R detected 15 arguments although I only specified 11 (which is the number of arguments required for the script).

Run_Script_Snapshot

Thank you so much!

Best wishes,
Ruohan

@stefanocoretta
Copy link
Owner

Can you post the Praat code of the form in your script?

@JackGuo15
Copy link
Author

JackGuo15 commented Jul 29, 2024

Can you post the Praat code of the form in your script?

Hi Stefano,

Hope you had a nice weekend! Thank you so much for your reply.

The Praat code I used can be accessed here (https://sites.google.com/view/uhm-o-meter/scripts/syllablenuclei_v3?authuser=0). I apologize that I could not attach the code to this post because it is soooo long and the markdown is a bit annoying.

Last week, I attempted to debug the script and discovered a major issue. When passing the file directory to R, the audio files in the directory were each treated as individual arguments. For example, the directory I specified (shown in Snapshot 1) contains two audio files. This directory worked fine when I used Praat directly (please see Snapshot 2, which features the arguments I used to run the Praat script). However, when I tried to pass the same arguments to the Praat script via R, I received the warning: "Error: Found 12 arguments but expected only 11." After several test runs where I manipulated the number of audio files in the folder, I realized that R, for some reason, treated each individual file in the directory as an argument.

This issue also occurs with other types of arguments. For example, the argument "Pre processing" requires one of three options: "None," "Reduce noise," or "Band pass (300..3000 Hz)." If I pass the "Reduce noise" argument from R to Praat, it is treated as two arguments instead of one.

I have modified the Praat script (mainly the directory part) so it is now compatible with R. However, I am still curious as to why the issues described above occurred. I look forward to your advice.

Thank you so much for your time and patience.

Best wishes,
Ruohan

snapshot1

snapshot2

@stefanocoretta
Copy link
Owner

Hi! Sorry for the massive delay, I am happy that you find a solution in the meantime.

I wonder if R is interpreting the blob in the file name. Have you tried escaping \*? Anyway, I will investigate time allowing next semester. :)

@JackGuo15
Copy link
Author

Hi Stefano,
No worries at all about the delay!

Thank you for the suggestion about escaping the "/*", I ended up modifying how the script (from: https://sites.google.com/view/uhm-o-meter/scripts/syllablenuclei_v3?authuser=0) handles directory paths and file extensions. I've updated the input directory handling portion below, though this might differ from your suggested approach:

procedure processArgs
nrObjects = numberOfSelected("Sound")
nrStr = numberOfSelected("Strings")

if nrObjects and nrStr == 0
idSnd# = selected#("Sound")
idTG# = zero#(nrObjects)
idTbl# = zero#(nrObjects)
nrFiles = 0
elif nrStr and nrObjects == 0
for str to nrStr
idStr[str] = selected("Strings", str)
endfor
idStr = Append
nrFiles = Get number of strings
directory$ = ""
elif nrStr == 0 and fileSpec$ <> ""
directory$ = fileSpec$
idStr = Create Strings as file list: "fileList", directory$ + "*.wav" # Here is the major change
nrFiles = Get number of strings
nrObjects = 0
else
exit Unsupported Input Selection
endif

if nrFiles
idSnd# = zero#(nrFiles)
idTG# = zero#(nrFiles)
idTbl# = zero#(nrFiles)
endif
for file to nrFiles
filename$[file] = Get string: file
endfor

Looking forward to hearing your insights next semester when you have time to investigate. I sincerely appreciate your patience and time on this issue.

Best wishes,
Ruohan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants