Praat scripting notes: Difference between revisions

From Helpful
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
{{#addbodyclass:tag_ling}}
{{#addbodyclass:tag_ling}}
{{ling}}
{{ling}}
https://www.fon.hum.uva.nl/praat/manual/Scripting.html
==Data types and structures==


<!--
<!--
Line 7: Line 12:




Form types [https://www.fon.hum.uva.nl/praat/manual/Scripting_6_1__Arguments_to_the_script.html] represent types and some GUI filtering of their values
 
 
In forms, [https://www.fon.hum.uva.nl/praat/manual/Scripting_6_1__Arguments_to_the_script.html] represent types and some GUI filtering of their values
  word - string without spaces
  word - string without spaces
  sentence - string with spaces
  sentence - string with spaces
Line 32: Line 39:




-->
===String operations===
<!--
noext$ = filename$ - ".wav"
Read from file: noext$ + ".wav"
writeInfoLine: “The value is ”, b, “.”
# comment (beginning of line only)
not whitespace sensitive (anymore), and people like indenting to suggest structure
-->
===Structures===
<!--
https://www.fon.hum.uva.nl/praat/manual/Scripting_5_6__Arrays_and_dictionaries.html
https://www.fon.hum.uva.nl/praat/manual/Scripting_5_7__Vectors_and_matrices.html
-->
==Objects and selections==
<!--
For anything more complex, you will be working with '''the list and selections within it'''
* [https://www.fon.hum.uva.nl/praat/manual/_selectObject_.html selectObject] change selection, by ID or name
* [https://www.fon.hum.uva.nl/praat/manual/_plusObject_.html plusObject] add to current selection, by ID or name
* [https://www.fon.hum.uva.nl/praat/manual/_minusObject_.html minusOject] removes from current selection, by ID or name
* [https://www.fon.hum.uva.nl/praat/manual/_removeObject_.html removeObject] removes objects from list
:: if in the selection, removes that; does not otherwise affect the selection
* selected$() is a function that returns the '''name''' of objects within the selection
** selected$()
** selected$(num)
** selected$(type$)
** selected$(type$, num)
* selected() is a function that returns the '''ID''' of objects within the selection
** selected() - return ID of the topmost selected object
** selected(number) - return ID of so-manieth item (from the bottom if negative)
** selected (type$) - return ID of first selected object of the type
** selected (type$, i) - return ID of so-manieth selected object of the type
-->
==Files and commands==


<!--


Praat info window
Praat info window
Line 64: Line 129:
  pauseScript [https://www.fon.hum.uva.nl/praat/manual/_pauseScript_.html]
  pauseScript [https://www.fon.hum.uva.nl/praat/manual/_pauseScript_.html]


  sendsocket fonsg19.hum.uva.nl:6667 display hallo.wav
  https://www.fon.hum.uva.nl/praat/manual/Scripting_5_8__Including_other_scripts.html
 




sendsocket fonsg19.hum.uva.nl:6667 display hallo.wav


https://www.fon.hum.uva.nl/praat/manual/Scripting_6_9__Calling_from_the_command_line.html








https://www.fon.hum.uva.nl/praat/manual/Scripting_6_9__Calling_from_the_command_line.html


For anything more complex, you will be working with '''the list and selections within it'''
* [https://www.fon.hum.uva.nl/praat/manual/_selectObject_.html selectObject] change selection, by ID or name
* [https://www.fon.hum.uva.nl/praat/manual/_plusObject_.html plusObject] add to current selection, by ID or name
* [https://www.fon.hum.uva.nl/praat/manual/_minusObject_.html minusOject] removes from current selection, by ID or name
* [https://www.fon.hum.uva.nl/praat/manual/_removeObject_.html removeObject] removes objects from list
:: if in the selection, removes that; does not otherwise affect the selection




* selected$() is a function that returns the '''name''' of objects within the selection
** selected$()
** selected$(num)
** selected$(type$)
** selected$(type$, num)
* selected() is a function that returns the '''ID''' of objects within the selection
** selected() - return ID of the topmost selected object
** selected(number) - return ID of so-manieth item (from the bottom if negative)
** selected (type$) - return ID of first selected object of the type
** selected (type$, i) - return ID of so-manieth selected object of the type




Line 116: Line 162:
  untitled
  untitled


-->


== ==


 
<!--
 
String operations
noext$ = filename$ - ".wav"
Read from file: noext$ + ".wav"
 
writeInfoLine: “The value is ”, b, “.”
 
 
# comment (beginning of line only)
 
not whitespace sensitive (anymore), and people like indenting to suggest structure
 


  for i from 1 to nFiles
  for i from 1 to nFiles
Line 166: Line 202:




 
==Forms==
 
<!--
 
 
 
 
 
 
'''scripts look like wording, but you won't understand why it works until you figure out the predefined things it's referencing'''
 
Consider:
Create Strings as file list: "*.wav"
num_files = Get number of strings
for i from 1 to num_files
  selectObject: "Strings files"
  filename$ = Get string: i
  basename$ = filename$ - ".wav"
  Read from file: dir$ + basename$ + ".wav"
endfor
 
Why does "Get number of files" or "Get String" work?
 
'''Get is a little magical'''
 
* Get mean...
 
 
 
 
 
Create Strings as file list... list 'source_directory$'/'file_name_or_initial_substring$'*'file_extension$'
head_words = selected("Strings")
 
 
 
Drawing
 
Erase all
Draw inner box
Erase all
 
 


form presens a form
form presens a form
Line 222: Line 218:
endform
endform


-->




Write to WAV file... 'save_as$'


==Drawing==


<!--


Add menu command...
Erase all
 
Draw inner box
Add action command...
Erase all


-->






https://www.fon.hum.uva.nl/praat/manual/Scripting.html
-->


==External scripting==
==External scripting==
Line 252: Line 249:


-->
-->
==Extending praat==
<!--
Add menu command...
Add action command...
-->
==Unsorted==
'''scripts look like wording, but you won't understand why it works until you figure out the predefined things it's referencing'''
Consider:
Create Strings as file list: "*.wav"
num_files = Get number of strings
for i from 1 to num_files
  selectObject: "Strings files"
  filename$ = Get string: i
  basename$ = filename$ - ".wav"
  Read from file: dir$ + basename$ + ".wav"
endfor
Why does "Get number of files" or "Get String" work?
'''Get is a little magical'''
* Get mean...
Create Strings as file list... list 'source_directory$'/'file_name_or_initial_substring$'*'file_extension$'
head_words = selected("Strings")

Revision as of 13:16, 20 June 2024

Language units large and small

Marked forms of words - Inflection, Derivation, Declension, Conjugation · Diminutive, Augmentative

Groups and categories and properties of words - Syntactic and lexical categories · Grammatical cases · Correlatives · Expletives · Adjuncts

Words and meaning - Morphology · Lexicology · Semiotics · Onomasiology · Figures of speech, expressions, phraseology, etc. · Word similarity · Ambiguity · Modality ·

Segment function, interaction, reference - Clitics · Apposition· Parataxis, Hypotaxis· Attributive· Binding · Coordinations · Word and concept reference

Sentence structure and style - Agreement · Ellipsis· Hedging

Phonology - Articulation · Formants· Prosody · Sound change · Intonation, stress, focus · Diphones · Intervocalic · Glottal stop · Vowel_diagrams · Elision · Ablaut_and_umlaut · Phonics

Speech processing · Praat notes · Praat plugins and toolkit notes · Praat scripting notes

Analyses, models, software - Minimal pairs · Concordances · Linguistics software · Some_relatively_basic_text_processing · Word embeddings · Semantic similarity

Unsorted - Contextualism · · Text summarization · Accent, Dialect, Language · Pidgin, Creole · Natural language typology · Writing_systems · Typography, orthography · Digraphs, ligatures, dipthongs · More linguistic terms and descriptions · Phonetic scripts

https://www.fon.hum.uva.nl/praat/manual/Scripting.html


Data types and structures

String operations

Structures

Objects and selections

Files and commands

Drawing

External scripting

Extending praat

Unsorted

scripts look like wording, but you won't understand why it works until you figure out the predefined things it's referencing

Consider:

Create Strings as file list: "*.wav"
num_files = Get number of strings
for i from 1 to num_files
  selectObject: "Strings files"
  filename$ = Get string: i
  basename$ = filename$ - ".wav"
  Read from file: dir$ + basename$ + ".wav"
endfor

Why does "Get number of files" or "Get String" work?

Get is a little magical

  • Get mean...



Create Strings as file list... list 'source_directory$'/'file_name_or_initial_substring$'*'file_extension$' head_words = selected("Strings")