praat

load text from .txt into praat info window


I would like to read the information from a text file in the praat window. I can "echo" text to the window with:

writeInfoLine: "Hello World"
appendInfoLine: "Goodbye"

But what I don't know how to do is to do the same thing if I have

"Hello World"
"Goodbye"

saved to a simple .txt file

I want to load the content of this file into the Praat Info window and save it to another .txt


Solution

  • You can read plain text into a Strings object and then manipulate the strings depending on your needs.

    Read Strings from raw text file: "text.txt"
    numberOfStrings = Get number of strings
    
    for stringNumber from 1 to numberOfStrings
         string$ = Get string: stringNumber
         appendInfoLine: string$
    endfor
    

    You can use appenFileLine: "output.txt", string$ to write to a text file.