Computers

 

Tip: When interacting with lab computers, you will use a lot of commands that are likely to be hard to remember at first. Keep a text file on your computer to keep records of commands so you can copy and paste them and learn them. You want to be able to replicate all the steps of things you’ve done once, while you’re still learning what all the steps mean. Using a text editor like TextEdit or Notepad can be better than Word because they are less likely to do things like replace quotation marks with fancy quotes. Fancier text editors exist, such as Kate (free) and Sublime Text ($99).

Connecting to a phonetics lab computer

If you are on campus with a wired connection or connected to the wireless network ncsu or eduroam (not ncsu-guest), connecting should work as described here. If you are off campus, you will need to connect to the VPN first. In all examples, replace “phon” in phon.chass.ncsu.edu with the name of a specific lab computer (ask Jeff for names).

Open a terminal window (in Mac, look for Terminal in /Applications/Utilities or search for “Terminal”; in Windows 10 and up type “cmd” in the search field and click on “Command Prompt”; for older Windows versions, you’ll need to download a program called PuTTY: see the lab computers page for that)

To open the connection enter this command (remembering to replace yourunityid and phon) and then enter your unity id password:

ssh yourunityid@phon.chass.ncsu.edu

You will be connected to a lab computer running the linux operating system and you interact with it by entering linux commands. You should see a command prompt that looks sort of like this: yourunityid@phon:~$

You will start out in your own home directory on the specific computer you connected to. all of these computers are connected to a shared hard drive called “phon”, which is full of data and scripts for working with data, and we will spend most of our time working on phon. It has an “ENG536” directory for us to put files for ENG 536/494. Change to that directory using the change directory (cd) command like this:

cd /phon/ENG536

You can always get back to your home directory on the computer you’re connected to like this (if you try this, change back to ENG536 before you do the next steps):

cd ~/

From the directory /phon/ENG536, create a directory for yourself like this using the mkdir (make directory) command (use your actual unity id) and then cd into it. Note that when you are already in /phon/ENG536, you can just type “cd yourunityid” but the following cd command will work from anywhere:

mkdir yourunityid
cd /phon/ENG536/yourunityid

Some useful linux commands

These instruction were prepared by Elias Robertson for the spring 2020 ENG 536 class.

Canceling things: CTRL+C

CTRL+C cancels any command you run on the command line. Use it to cancel accidental commands if needed.

Moving and renaming files: mv

mv moves a file to another place. You can also use it to rename files, which is more common. This is how to rename a file:

mv oldfile.csv movedfile.csv

This is how to move a file to the ENG536 directory:

mv oldfile.csv /phon/ENG536

This is how to move a file to the directory above the directory it’s in:

mv oldfile.csv ..

This is how to move a file to another directory AND rename it:

mv oldfile.csv ../movedfile.csv

Copying files: cp

cp copies a file to another file. You can also use it to rename files in the process. This is how to copy a file within the same directory:

cp oldfile.csv newfile.csv

This is how to copy a file to another directory:

cp oldfile.csv /phon/ENG536/username/newfile.csv

Present working directory: pwd

pwd prints out the “present/current working directory”, or where you are in the computer. To print out the working directory:

pwd

List directory contents: ls

ls lists out the files in the working directory, with colors denoting what type of file they are. -l is a way to specify to give the “long” version of a file description. Also, -a says to list hidden files as well, if you accidentally name a file with a . at the start, which hides it. To list the files in the directory:

ls

To list the files in the directory, with information about what size they are, who owns them, and permissions:

ls -l

To list everything including hidden files:

ls -a

To list all information including for hidden files:

ls -la

Display file contents: cat

cat displays the contents of a file to the console. You can also use it to write contents of file to another file (copy a file to a new directory or name) with a special character, >.

To see the contents of a file with cat:

cat filename.csv

To copy the contents of a file to a new file:

cat filename.csv > copied.csv

To copy the contents of a file to a new file in your home directory (~):

cat filename.csv > ~/copied.csv

Find a file: find

find is a tool that is used to search, much like grep. To make it find each file with a part of a name in the directory:

find . -name "*partofname*"

To make it find each file with a part of the name in a different directory:

find differentdirectory/ -name "*partofname*"

Search: grep

grep searches through files for what you tell it to search for. You can use it to search for everything, or to search for certain things like “Feb” or “F1”. It’s much slower than cat because it prints bit by bit, so it’s best to use it only to search for parts of a file rather than tell it to print out the whole thing.

To make it print out a whole file:

grep . filename.csv

To make it print out only lines that match a specific part, like F1_25, on it:

grep F1_25 filename.csv

To make it print out the lines that match to a file:

grep F1_25 filename.csv > output.txt

To search for a word but ignore the case, use -i

grep -i f1_25 filename.csv

Open a new terminal that remains when you log out: screen

screen opens up a new “window” in the terminal, which can be escaped from with CTRL+A and CTRL+D. How to open a new window:

screen [-D -R name, or nothing if you don't care]
[do everything you want to do]
CTRL+A
CTRL+D
[do what you want to do]

How to reopen a window you left behind:

screen -r [name if you specified one]
[do everything you wanted to do]
CTRL+A
CTRL+D
[do what you want to do]

How to clean up all windows you have opened, which may require reconnecting:

screen -wipe

Print the start of a file: head

head prints out the first 10 lines of a file to the console. To print out the first 10 lines of a file:

head filename.csv

To print out the first 20 lines of a file:

head -20 filename.csv

Print the end of a file: tail

tail prints out the last 10 lines of a file to the console. To print out the last 10 lines of a file

tail filename.csv

To print out the last 20 lines of a file:

tail -20 filename.csv

Read a file page by page: more

more reads a file page by page. To read a file:

more filename.csv

To scroll down a page, press “Enter”

To exit reading the file, press “q”

Text editor: nano

nano is used to view and edit files. the ^ character is used to mean CTRL. To leave the editor, use CTRL+X.

To create a file (or open a file that already exists with this name:

nano filename.txt

To save a file and exit when it’s open: CTRL+X and then Y

Compress files: zip

zip combines all files into a common file to transfer between directories or computers. To add all files with a common name such as “common_name” to a zip file called filename.zip:

zip -r filename 'common_name'

To add files manually you can do this with ‘filename’ added for each file:

zip filename 'common_name1.txt' 'common_name2.csv'

Read the manual: man

man lets you look up information about any command present on the machine. It gives a lot more information than anyone ever should need about it, but it is useful when something is missing. Alternatively, use -help or –help after most commands to get arguments you can use for the command.

To look up a command called cat:

man cat

To exit the man screen, press q

A fun thing to do on lab computers: query word count information

On the phonetics lab computers, there are some files listing all the words in various speech corpora by frequency. You can explore lexical frequency in order to see how many tokens are available for you to measure and to gain familiarity with some useful linux commands. For example, /phon/ENG523/files/raleigh_freq.txt has the frequency of words in the transcribed part of the Raleigh corpus, and /phon/ENG523/files/raleigh_freq2.txt has those words with their pronunciations (with separate entries for words transcribed with different phonemes).

Use cat to view the entire contents of raleigh_freq.txt:

cat /phon/ENG523/files/raleigh_freq.txt

Use head to just see the 20 most frequent words in raleigh_freq.txt:

head -20 /phon/ENG523/files/raleigh_freq.txt

Use grep to search for words with “Q” in them:

grep 'Q' /phon/ENG523/files/raleigh_freq.txt

Use grep, head, and “pipe” to see the top 15 words with “Q” in them:

grep 'Q' /phon/ENG523/files/raleigh_freq.txt | head -15

Switch to the freq2 files to search for the 20 most frequent words pronounced with /s t ɹ/:

grep 'S T R' /phon/ENG523/files/raleigh_freq2.txt | head -10

What freq2 files are present:

ls /phon/ENG523/files/*freq2.txt

The Raleigh corpus was aligned with P2FA, and its words are in all caps. The other SLAAP corpora were aligned with MFA, and their words are in all lowercase. Since the Buckeye corpus was aligned in the early 2000s and it has a different phone set. These things need to be taken into account when searching. Use head and cat if your grep command output doesn’t make sense to you. Use the grep option -i to ignore case. Both of these will work for searching the NC corpus frequency file:

grep 'raleigh' /phon/ENG523/files/nc_freq2.txt
grep -i 'RALEIGH' /phon/ENG523/files/nc_freq2.txt

Using screen to run big queries

Some one_script queries take a long time to complete. Creating the one_script formant files listed above took 25 minutes for the smallest corpus and three days for the largest corpus. To keep them running after you log out, use the command screen to open up a new terminal session that persists after you log out:

screen

You will probably see some messages that you need to press Enter to clear. Then you can enter whatever commands you want to run on their own for a while. Then press Ctrl-A followed by Ctrl-D to disconnect from the session.

Later you can ssh to the same computer and resume your session like this:

screen -r

If you have multiple active sessions, you will see a list, and then you can try again specifying one of the numbers, like this:

screen -r 67910

If you want to clean up all the sessions you opened, you can do this:

screen -wipe

 

 

 

Transfer files between a phonetics lab computer and your computer

When you create files remotely on the phonetics lab computer, you are limited in how you can interact with them. After you make measurements, you will probably want to download your files. To copy files between local and remote computers, open a NEW terminal window on your computer (the same way you did above). Importantly, do NOT use ssh to connect to the remote (phonetics lab) computer. You will be issuing these commands to YOUR OWN computer.

The command scp (secure copy) takes two arguments: where to find the file you want to copy and where to put. For downloads, we have to specify the remote computer and username in the first argument. To download the textgrid you created by aligning with P2FA, do this (with the usual changes):

scp yourunityid@phon.chass.ncsu.edu:/phon/ENG536/yourunityid/jeffmielke2017.TextGrid ./

To download the textgrid you created by aligning with MFA, do the same thing but specify a different file location and filename:

scp yourunityid@phon.chass.ncsu.edu:/phon/ENG536/yourunityid/jeff_vowelplot_output/jeff.TextGrid ./

The “./” at the end tells it to put the file in your current directory. If you wanted to specify a different directory you can change “./” to something like “/Users/jimielke/Documents” “C:\Users\jimielke\Documents”.

Uploading works similarly.

The scp command for uploading specifies the remote computer and username for the destination. This will work if a file called myfile.wav is in your current directory in the terminal:

scp myfile.wav yourunityid@phon.chass.ncsu.edu:/phon/ENG523/yourunityid/

If myfile.wav is not found but you think it should be, you can do things like change the source file from myfile.wav to “/Users/jimielke/Documents/myfile.wav” “C:\Users\jimielke\Documents\myfile.wav” or else use the cd command to get into /Users/jimielke/Documents or C:\Users\jimielke\Documents.

 

 

Workstations in the lab

The phonetics lab is equipped with three computer workstations and three sound attenuated booths for making recordings, running perceptual experiments, etc.

WORKSTATION ONE

Workstation one houses the main Windows computer which is connected to the other computers in booths 2 and 3. Perceptual experiments can be run from workstation one through all three sound booths or in any other combination. The USBPre pre-amplifier rests on the stool with the monitor facing booth 1. There are labeled cords which will help you identify what needs to be plugged into where for your particular needs. This computer as well as the other two Windows PCs are able to run perception experiments using the software Presentation.

Figure 1. Workstation 1

WORKSTATIONS TWO AND THREE

Workstations 2 and 3 are available for everyday tasks including designing experiments in Praat, interacting with the server, writing materials and stimuli, analyzing data using R, tracing tongue and palate images uses Palataglossotron, etc. The computers at these two workstations are Linux machines. If you need to run a Windows application on one of these machines, for example Palataglosstron, use wine via the terminal. For other instructions on how to interact with the server, see that section of this manual: interacting with the server. You will also find the trace pads and headphones at each of these workstations. Please remember to log out of these machines when you have finished your session; they will lock anyone else out if you forget.

workstation2_NCSU

Figure 2. Workstations 1 (top) and 2 (bottom).

Moving files to/from the server

You copy files to the Phonetics Lab server using the terminal in Mac OS or Linux, or using a program like WinSCP in Windows.

To copy “yourfile.zip” to your home directory on the server, type this at the terminal prompt (“$” indicates what to type into the server, you don’t need to include it, but any spaces are important):

scp yourfile.zip yourunityid@phon.chass.ncsu.edu:

You should then be prompted for your password. There will not be dummy characters like on a web page so just type and hit enter.

To download “yourfile.zip” from your home directory on the server, type this at the terminal prompt:

scp yourunityid@phon.chass.ncsu.edu:yourfile.zip ./

If you use WinSCP, run the program and open a connection to phon.chass.ncsu.edu. You should be able to drag files back and forth.

Working with files that are on the server

In addition to moving files to and from the server, you can use various tools available on there, such as the forced aligner.

You can log in to the Phonetics Lab server using the terminal in Mac OS or Linux, or using a program like PuTTY in Windows.

From the terminal, type this to open an interactive session:

ssh yourunityid@phon.chass.ncsu.edu

Once you have accessed your directory personal directory on the server you can do things like view a list of your files by typing this:

ls