简体   繁体   中英

Praat and sox information script

How can I do the following?

  1. Sound object is selected
  2. save sound object as wav (as a temporary filename)
  3. run sox -i adsda.wav or soxi adsda.wav
  4. output to the display the result of sox -i
  5. delete temporary file

You can execute sox by calling the system directive, and then capture the output in a temporary file. You can then read this temporary file into Praat with readFile$() . Here's an example:

infile$ = "sound.wav"
outfile$ = "soxi.out"
sound = Create Sound as pure tone: "tone",
  ... 1, 0, 0.4, 44100, 440, 0.2, 0.01, 0.01
Save as WAV file: infile$

system soxi 'infile$' > 'outfile$'
soxi$ = readFile$(outfile$)
appendInfo: soxi$

deleteFile: infile$
deleteFile: outfile$
removeObject: sound

I'm not sure what changes (if any) this would need in Windows, but considering you are using sox , that probably is not a problem.

Please note that currently (Praat v.5.4) the system directive still uses the old syntax, which uses variable substitution. This will probably change in the future. But this script should remain usable even then.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM