Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot...

121
Cédric Gendrot - TAL SLOW 5 - 2003-2004 - I PROGRAMMER AVEC PRAAT Cédric Gendrot [email protected]

Transcript of Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot...

Page 1: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

PROGRAMMER AVEC

PRAAT

Cédric [email protected]

Page 2: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Plan

1- Introduction au langage de Praat 2- Votre premier script 3- L'analyse acoustique : le son 4- Ecrire dans un fichier 5- L'analyse acoustique : la "TextGrid"

Page 3: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Plan

1- Introduction au langage de Praat 2- Votre premier script 3- L'analyse acoustique 4- Ecrire dans un fichier 5- L'analyse acoustique : la "TextGrid"

Page 4: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Programmer???

C’est un langage de « scripts »…

– 1- un langage interprété

– 2- d'accès plus abordable (pas du C)…mais...

– 3- proche du Visual Basic de Microsoft (suite de Macros améliorées)

Page 5: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Un exemple concret

Réaliser une analyse acoustique grâce à un script!

Prenez votre fichier "Praat Demo" étiqueté…

...(étiqueté : c’est indispensable si l’on veut connaître les caractéristiques de certains phonèmes)

Page 6: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Objectif final !

Analyser tous les [a] de cet extrait– Fo– valeurs des 3ers formants– intensité globale– durée

Page 7: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Notez ces commandes

- qui peuvent sembler inutiles manuellement

- …mais qui seront reproduites par le script

Page 8: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

point important

Il s’agit de comprendre la logique

Les opérations se dérouleront dans la fenêtre « Praat objects », c’est + rapide, et les mêmes commandes sont disponibles

Page 9: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Ces commandes se retrouveront dans la fenêtre"Praat Objects"

Ces commandes se retrouveront dans la fenêtre"Praat Objects"

Page 10: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Plan

1- Introduction au langage de Praat 2- Votre premier script 3- L'analyse acoustique 4- Ecrire dans un fichier 5- L'analyse acoustique : la "TextGrid"

Page 11: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Votre 1er script! voici les étapes….pour se mettre dans le bain

– 1- ouvrir un script vierge– 2- ouvrir un fichier et sa grille d’étiquetage...– 3- …puis les insérer dans le script!– 4- sauver le script, puis l'exécuter– 5- ré-utiliser le script plus tard– 6- La notion de chemin– 7- La notion de variable– 8- Nommer les fichiers… pour les (r)appeler

Page 12: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

1- ouvrir un script vierge

Donc désormais, tout se passe dans la fenêtre « Praat Objects »

« Control > New Praat script

Page 13: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 14: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

2- ouvrir un fichier et sa grille d’étiquetage...

On va pouvoir écrire dans ce script

Comment ouvrir un fichier par un script ?

Peu de syntaxe à apprendre, il s’agit de Macros

Page 15: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

En fait...

Toutes les actions réalisées après ouverture de Praat sont enregistrées dans un historique

Il est sage de commencer par "formater cet historique"

Page 16: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 17: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

3- …puis les insérer dans le script! Ouvrons donc un fichier et puis copions la

syntaxe de l’action dans le script…

…avec la commande "Paste History" (ou

Ctrl+H) qui se trouve juste sous la commande que l'on vient de voir

Page 18: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 19: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Votre 1er script! voici les étapes….pour se mettre dans le bain

– 1- ouvrir un script vierge– 2- ouvrir un fichier et sa grille d’étiquetage...– 3- …puis les insérer dans le script!– 4- sauver le script, puis l'exécuter– 5- ré-utiliser le script plus tard– 6- La notion de chemin– 7- La notion de variable– 8- Nommer les fichiers… pour les (r)appeler– 9- mettre des commentaires

Page 20: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Il suffira ensuite de...

Sauvegarder le script ( File > Save ou Ctrl+s )

… Puis le lancer ( Run > Run ou Ctrl + r )

…pour répéter la manœuvre !

Page 21: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 22: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 23: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

5- ré-utiliser le script plus tard

Pour exécuter ce script un autre jour :

– il faudra l'appeler depuis la fenêtre "Praat Objects"

– ...puis l'exécuter comme d'habitude...

Page 24: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 25: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 26: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Exercice1 1- Effacez l'historique… (Clear History)

2-Ouvrez le fichier son "Track01.wav"et sa grille d'étiquetage "Track01.TextGrid"

2- Inscrivez l'opération dans un script, sauvegardez le dans le dossier "cours_slow5" (script1 par ex)

3- Fermez Praat, ouvrez le à nouveau, ouvrez le script et exécutez le

Page 27: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

En fait….

En programmation, les puristes disent :« pas de nom de fichier dans un script »

… et c’est bien vrai, mais pour l’instant c’est plus simple!

Ces notions sont indispensables si l’on veut:– lire des fichiers puis écrire les résultats ailleurs– faire des scripts «autonomes »

Page 28: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Votre 1er script! voici les étapes….pour se mettre dans le bain

– 1- ouvrir un script vierge– 2- ouvrir un fichier et sa grille d’étiquetage...– 3- …puis les insérer dans le script!– 4- sauver le script, puis l'exécuter– 5- ré-utiliser le script plus tard– 6- La notion de chemin– 7- La notion de variable– 8- nommer les fichiers… pour les (r)appeler– 9- mettre des commentaires

Page 29: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

6- La notion de chemin

Allons y progressivement Il faut connaître la notion de chemin relatif

Admettons que l’on donne un chemin unique vers un dossier qui contiendra tout notre travail…– C:\WINDOWS\Bureau\cours_prog_praat\

Page 30: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

7- La notion de variable

Nommons le dans le script :

path$ = "C:\WINDOWS\Bureau\cours_prog_praat\"

nom de variable :on peut mettre n’importe quoi

toto$ bloublou$

ici c’est le chemin donné parWindows !

Page 31: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Point essentiel!!!!!!!! Voilà le plus grand principe de la

programmation : mettre les informations dans des "variables"…

Puisqu'on peut les ré-utiliser ensuite…par exemple l'afficher avec la commande

print 'path$'

Page 32: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Quelques « détails »...

Ce qui peut paraître compliqué également:– les signes de ponctuation: "   $ ' 

En fait Praat est assez permissif…

Page 33: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

…ce qu'il faut savoir tout de même

la variable 'toto$' sera mémorisée comme un nom la variable 'toto' sera mémorisée comme un chiffre

les "..." (ou rien) ne sont pas interprétées les '….' seront interprétées

Page 34: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Maintenant...

Pour ouvrir les fichiers dans ce dossier…– path$ = "C:\WINDOWS\Bureau\cours_prog_praat\" – file$ = path$ + "track01.wav"– file2$= path$ + "track01.TextGrid"– Read from file... 'file$'– Read from file... 'file2$'

Pour l’instant ça paraît plus compliqué… mais il faut s’y habituer… l’utilité deviendra évidente bientôt!

Page 35: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

8- Nommer les fichiers

Un des rares exemples sans macro…une fois que vous avez ouvert un nouvel élément dans la fenêtre "Praat Objects" (que ce soit un son, une grille, une analyse de Fo, formants…)

– Read from file... 'file$'– son = selected ( "Sound")– Read from file... 'file2$'– grille = selected ("TextGrid ")

nom de variable :on peut mettre n’importe quoi

à droite de = c’est très strict!

Page 36: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

8 - … pour les rappeler

Sélectionner un son revient à cliquer dessus…voici comment faire "par écrit"

– select 'son'– select 'grille'

Glissez une pause entre chaque pour observer les étapes...

select 'son'pauseselect 'grille'pauseselect 'son'

pratique ces pauses!quand le script "plante"

toujours au même endroit

Page 37: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

9- mettre des commentaires

Un grand classique !!!

Pour progresser, c’est vraiment indispensable…mais aussi pour se souvenir de ce qu’on a fait 4 mois + tôt !

Il suffit de commencer une ligne par #

Page 38: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 39: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

exercice2 1- Indiquez le chemin et ouvrez les 2 mêmes fichiers avec la

méthode suivante

path$ = "C:\WINDOWS\Bureau\cours_prog_praat\"file$ = path$ + "track01.wav"file2$= path$ + "track01.TextGrid"Read from file... 'file$'Read from file... 'file2$'

2- Nommez les … "son" et "grille", puis sélectionnez les tour à tour 2 fois, utilisez les pauses pour vérifier que ça fonctionne!

3- N'hésitez à décrire le tout par des commentaires.

4 - Utilisez la fonction print pour afficher 'path$', 'file$' et 'son'

Page 40: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

exercice2 : solution Voici une des possibilités

# chemin et nom des fichiers à ouvrirpath$ = "C:\WINDOWS\Bureau\cours_prog_praat\" file$ = path$ + "track01.wav"file2$= path$ + "track01.TextGrid"

# ouverture des fichiers nommés 'son' et 'grille' Read from file... 'file$'son = selected ("Sound")Read from file... 'file2$'grille = selected ("TextGrid")

# sélection des sons avec pause pour voir si ça marche!select 'son'pauseselect 'grille'pause

# Affichage dans la fenêtre Info.. 'newline$' permet de passer à la ligne

print 'path$' 'newline$' 'file$' 'newline$' 'son'

Page 41: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Plan

1- Introduction au langage de Praat 2- Votre premier script 3- L'analyse acoustique 4- Ecrire dans un fichier 5- L'analyse acoustique : la "TextGrid"

Page 42: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Commençons……le principe !

Comment obtenir nos premières valeurs….?

Comment fait on manuellement????

Il suffit d'utiliser le menu "Query" qui apparaît lorsqu'un élément est sélectionné...

Page 43: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Les commandes possibleslorsqu'un son

est sélectionné !!

"Query > …. "

Page 44: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Les commandes possibleslorsqu'une grille d'étiquetage

est sélectionné !!

"Query > …. "

Page 45: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

On a vu... Pour les analyses manuelles…

… il était essentiel de montrer les analyses de Fo (et autres) sur l'écran… pour prendre des mesures !

Pour les scripts……il est essentiel d'avoir les analyses sur le "plan de travail" !

Page 46: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Sélectionnez le son en cliquant dessus

cliquez sur "Periodicity"pour obtenir un

"Pitch Tier"

Page 47: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 48: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Query...

Le principe est le même pour…..

la Fo

Rappel:

Sound > Periodicity > To Pitch pour obtenir le "Pitch"

Page 49: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Query...

Le principe est le même pour…..

l'analyse formantique

Rappel:

Sound >Formants & LPC > To Formant(burg)

pour obtenir le "Formant"

Page 50: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Query...

Le principe est le même pour…..

l'analyse d'intensité

Rappel:

Sound > To Intensity pour obtenir l'intensité

Page 51: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

La difficulté est la suivante !!

Toutes ces commandes requièrent des informations temporelles…

Or ces informations temporelles sont contenues dans la grille d'étiquetage ("TextGrid").

Page 52: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Allons y progressivement !

Il va falloir mélanger :– 1- les informations prises sur le son– 2- les informations fournies par la "TextGrid"

Commençons par nous familiariser avec la première partie… dans l'exercice 3 !

Page 53: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Utilisons un indice temporel fixe

à 1.08s du début du fichier se trouve...

un [a] dans "Paris" (au milieu du [a])

Prenons la valeur de Fo à cet instant!

Page 54: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Sélectionnez le son en cliquant dessus

cliquez sur "Periodicity"pour obtenir un

"Pitch Tier"

Page 55: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 56: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 57: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 58: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Il faut maintenant ...

… coller ces actions dans le script.– "Edit > Paste History" (ou Ctrl+H)

attention ! si vous n'avez pas pris

soin de formater l'historique avant les commandes…

il peut y avoir beaucoup de lignes!!!

Page 59: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Voici ce qu'on obtient...

Un langage à scripts : "des macros améliorées"… ça veut dire quoi?

select Sound track01To Pitch... 0.01 75 600Get value at time... 1.08 Hertz Linear

Page 60: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Il faudra changer (1)

– select Sound track01 en select 'son' pour rendre le script + autonome!

select Sound track01To Pitch... 0.01 75 600Get value at time... 1.08 Hertz Linear

select 'son'To Pitch... 0.01 75 600Get value at time... 1.08 Hertz Linear

Page 61: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Il faudra changer (2)

Nommez le "Pitch" si l'on doit s'en servir plus tard…. select 'pitch'

select Sound track01To Pitch... 0.01 75 600Get value at time... 1.08 Hertz Linear

select 'son'To Pitch... 0.01 75 600pitch = selected("Pitch")Get value at time... 1.08 Hertz Linear

Page 62: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Il faudra changer (3)

Il faut enregistrer le résultat…. dans une variable bien sûr! c'est un résultat chiffré…donc…pas de $!

select Sound track01To Pitch... 0.01 75 600Get value at time... 1.08 Hertz Linear

select 'son'To Pitch... 0.01 75 600pitch = selected("Pitch")toto = Get value at time... 1.08 Hertz Linear

Page 63: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 64: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

exercice3 Prenez la valeur de Fo à 1.08s, sauvez la dans

une variable, puis affichez la.

1- Reprenez votre script! 2- Ouvrez le si vous l'avez fermé 3- Re-formatez l'historique de Praat

(ça se passe toujours dans la fenêtre "...script")

4- exécutez les opérations (valeur de Fo à 1.08s + affichage)

5- collez l'action dans le script 6- améliorez les macros 7- enregistrez et re-faites tourner.

Page 65: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

# chemin et nom des fichiers à ouvrirpath$ = "C:\WINDOWS\Bureau\cours_prog_praat\" file$ = path$ + "track01.wav"file2$= path$ + "track01.TextGrid"

# ouverture des fichiers nommés son$ et grille$ Read from file... 'file$'son = selected ("Sound")Read from file... 'file2$'grille = selected ("TextGrid")

select 'son'To Pitch... 0.01 75 600pitch = selected("Pitch")toto = Get value at time... 1.08 Hertz Linear

# Affichage de la variable 'toto'…tt ce qui n'est pas entre '..' est affiché tel quel !print la valeur de Fo à 1.08 sec du début du fichier est égale à 'toto' Hertz

exercice3 : solution

Page 66: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Un détail important !

# Affichage de la variable 'toto'…tt ce qui n'est pas entre '..' #est affiché tel quel!

print la valeur de Fo à 1.08 sec du début du fichier est égale à 'toto' Hertz

permet d'obtenir …

Page 67: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Précision des valeurs !!!

# Affichage de la variable 'toto'…tt ce qui n'est pas entre '..' #est affiché tel quel!

print la valeur de Fo à 1.08 sec du début du fichier est égale à 'toto:2' Hertz

permet d'obtenir …

Page 68: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Un autre point!

Les infos affichées ne sont pas automatiquement effacées d'une exécution de script à l'autre

Votre fenêtre "info" commence à être chargée….

Placez clearinfo à n'importe quel endroit du script et elle sera nettoyée!

Page 69: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Continuons pour …..

- les formants

- l'intensité

Page 70: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

C'est la même démarche!!!

Nettoyons l'historique

Page 71: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 72: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 73: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Le principe est le même pour…..

l'analyse formantique

Rappel:

Sound >Formants & LPC > To Formant(burg)

pour obtenir le "Formant"

Page 74: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 75: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 76: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 77: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Il faut maintenant ...

… coller ces actions dans le script.– "Edit > Paste History" (ou Ctrl+H)

attention ! si vous n'avez pas pris

soin de formater l'historique avant les commandes…

il peut y avoir beaucoup de lignes!!!

Page 78: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Voici ce qu'on obtient...

Un langage à scripts : "des macros améliorées"… ça veut dire quoi?

select Sound track01To Formant (burg)... 0.01 5 5500 0.025 50Get value at time... 1 1.08 Hertz Linear

Page 79: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Il faudra changer (1)

– select Sound track01 en select 'son' pour rendre le script + autonome!

select Sound track01To Formant (burg)... 0.01 5 5500 0.025 50Get value at time... 1 1.08 Hertz Linear

select 'son'To Formant (burg)... 0.01 5 5500 0.025 50Get value at time... 1 1.08 Hertz Linear

Page 80: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Il faudra changer (2)

Nommez le "Formant" si l'on doit s'en servir plus tard…. select 'formant'

select Sound track01To Formant (burg)... 0.01 5 5500 0.025 50Get value at time... 1 1.08 Hertz Linear

select 'son'To Formant (burg)... 0.01 5 5500 0.025 50formant = selected("Formant")Get value at time... 1 1.08 Hertz Linear

Page 81: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Il faudra changer (3)

Il faut enregistrer le résultat…. dans une variable bien sûr! c'est un résultat chiffré…donc…pas de $!

select Sound track01To Formant (burg)... 0.01 5 5500 0.025 50Get value at time... 1 1.08 Hertz Linear

select 'son'To Formant (burg)... 0.01 5 5500 0.025 50formant = selected("Formant")f1 = Get value at time... 1 1.08 Hertz Linear

Page 82: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Pour les autres formants...

Il faudra changer ici ….

Page 83: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Le principe est le même pour…..

l'analyse d'intensité

Rappel:

Sound > To Intensity pour obtenir l'intensité

Page 84: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 85: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

valeur de Fo, intensité, 3 premiers formants ….

Page 86: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Plan

1- Introduction au langage de Praat 2- Votre premier script 3- L'analyse acoustique 4- Ecrire dans un fichier 5- L'analyse acoustique : la "TextGrid"

Page 87: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Écrire dans un fichier

La prochaine étape sera de mêler ces analyses aux informations fournies par la "TextGrid"…

Mais avant tout 1 conseil indispensable :– 1- afficher le résultat dans un fichier (et non

plus sur la fenêtre Info de Praat

Page 88: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Comment afficher le résultat…?

– 2 possibilités

– dans la fenêtre "Info" (+ simple)– dans un fichier résultat que l'on créé (+ complet)

Page 89: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Dans la fenêtre "Info"

La commande : print ….c'est vu !

Page 90: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Afficher le résultat dans un fichier que l'on créé...

la commande la plus simple : fileappendelle permet de créer un fichier de sortie pour enregistrer les résultats…

Pour indiquer où placer ce fichier … on va procéder comme avant...

Page 91: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

# chemin et nom des fichiers à ouvrir path$ = "C:\WINDOWS\Bureau\cours_prog_praat\" file$ = path$ + "track01.wav" file2$= path$ + "track01.TextGrid"

# ouverture des fichiers nommés son$ et grille$ Read from file... 'file$' son = selected ("Sound") Read from file... 'file2$' grille = selected ("TextGrid")

Page 92: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

# chemin et nom des fichiers à ouvrir path$ = "C:\WINDOWS\Bureau\cours_prog_praat\" file$ = path$ + "track01.wav" file2$= path$ + "track01.TextGrid"

# ouverture des fichiers nommés son$ et grille$ Read from file... 'file$' son = selected ("Sound") Read from file... 'file2$' grille = selected ("TextGrid")

Page 93: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

# chemin et nom des fichiers à ouvrir path$ = "C:\WINDOWS\Bureau\cours_prog_praat\" file$ = path$ + "track01.wav" file2$= path$ + "track01.TextGrid"

# ouverture des fichiers nommés son$ et grille$ Read from file... 'file$' son = selected ("Sound") Read from file... 'file2$' grille = selected ("TextGrid")

Page 94: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

# chemin et nom des fichiers à ouvrir path$ = "C:\WINDOWS\Bureau\cours_prog_praat\" file$ = path$ + "track01.wav" file2$= path$ + "track01.TextGrid"

# ouverture des fichiers nommés son$ et grille$ Read from file... 'file$' son = selected ("Sound") Read from file... 'file2$' grille = selected ("TextGrid")

Page 95: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

outputfile$= path$ + "resultats.xls"

fileappend 'outputfile$' Fo 'tab$' formant1 'tab$' formant2 'tab$' …

– sans '….' pour insérer des annotations (très utile!!!)

fileappend 'outputfile$' 'toto:2' 'tab$' 'f1:2' 'tab$' 'f2:2' 'tab$' …

– avec '….' pour écrire le contenu des variables

Page 96: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

soit ...

fileappend 'outputfile$' 'newline$' Fo 'tab$' formant1

'tab$' formant2 'tab$' formant3 'tab$' intensité 'tab$' 'newline$'

Notez qu'on peut/doit insérer...– 'tab$'– 'newline$'

...On pourra ainsi remplir les cases d'une feuille Excel!

Page 97: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 98: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

exercice5 1- à 1.08 secondes du début du fichier

– Reprenez le script de l'exercice 3– Écrivez les résultats dans un fichier "resultats.xls" que vous placerez

dans le dossier "cours_slow5" – ds ce fichier, inscrivez sur la 1ère ligne le nom du fichier et sur la

2ème : phonème | Fo | formant1 | …(passez d'une cellule à l'autre avec 'tab$' et d'une ligne à l'autre avec 'newline$')

– N'affichez dans la fenêtre "Info" aucun résultat mais affichez l'information suivante : Analyse terminée, les résultats se trouvent dans XXXXXX (dans XXX vous placerez le chemin menant à votre fichier résultat)

Page 99: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

# chemin et nom des fichiers à ouvrirpath$ = "C:\WINDOWS\Bureau\cours_prog_praat\" file$ = path$ + "track01.wav"file2$= path$ + "track01.TextGrid"outputfile$= path$ + "resultats.xls" fileappend 'outputfile$' 'newline$' Fo 'tab$' phonème 'tab$' fo 'tab$' formant1 'tab$' 'newline$'

# ouverture des fichiers nommés son$ et grille$ Read from file... 'file$'son = selected ("Sound")Read from file... 'file2$'grille = selected ("TextGrid")

select 'son'To Pitch... 0.01 75 600pitch = selected("Pitch")toto = Get value at time... 1.08 Hertz Linear

fileappend 'outputfile$' 'toto' 'newline$'

Exercice5 : solution

Page 100: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Plan

1- Introduction au langage de Praat 2- Votre premier script 3- L'analyse acoustique 4- Ecrire dans un fichier 5- L'analyse acoustique : la "TextGrid"

Page 101: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Revenons à nos moutons !

Il va falloir mélanger :– 1- les informations prises sur le son– 2- les informations fournies par la "TextGrid"

On peut passer à la 2ème partie

Page 102: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Mêler le fichier son aux informations de la grille d'étiquetage?

Par définition, la grille d'étiquetage connaît– le nombre total d'intervalles– le début et la fin de chaque intervalle – l'étiquette de chaque intervalle

Page 103: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Les seules fonctions qui vont

nous intéresserici

Page 104: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 105: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 106: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 107: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Si l'on colle ces actions

Get number of intervals... 1 Get starting point... 1 2 Get label of interval... 1 2

Comme vous l'avez sans doute déjà remarqué,

la moindre opération est enregistrée...

...Mais on ne prend que ce qui estintéressant!

Page 108: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Que modifier…?

Get number of intervals... 1Get starting point... 1 2Get ending point… 1 2Get label of interval... 1 2

nb_intervalles = Get number of intervals... 1beg_phoneme = Get starting point... 1 2fin_phoneme = Get ending point… 1 2phoneme = Get label of interval... 1 2

d'abord prévoir d'insérer les résultats dans des variables !

Page 109: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Le raisonnement !

Page 110: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

L’intervalle est il nommé « a » ?si oui, faire les calculs!

Page 111: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

2 notions indispensables !!!

les boucles de répétition– for ………….. endfor

Les structures de condition– if …………… endif

Page 112: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Littéralement…….répétition

Du 1er intervalle jusqu'au dernier ("for")

– prend l'étiquette (quel phonème?)

(fin des instructions) ("endfor ")

Page 113: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Littéralement….…condition

Si l'intervalle est nommé "a" "if"

– réalise les actions suivantes ...– Get starting point, Get ending point,– formants, Fo et intensité ...

(fin des instructions) "endif "

Page 114: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

nb_intervalles = Get number of intervals... 1

for i from 1 to nb_intervalles

phoneme$ = Get label of interval... 1 i if (phoneme$ = "a")

beg_phoneme = Get starting point... 1 current_syllable fin_phoneme = Get end point... 1 current_syllable phoneme_dur = fin_phoneme - beg_phoneme fileappend 'outputfile1$' 'phoneme$' 'tab$' 'phoneme_dur' 'newline$'

endif endfor

… du 1er au dernier intervalle

… prend l'étiquette du ième intervalle

… si l'étiquette est un "a"

… du 1er au dernier intervalle …. fin

… si l'étiquette est un "a" …… fin

Page 115: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

nb_intervalles = Get number of intervals... 1

for i from 1 to nb_intervalles

phoneme$ = Get label of interval... 1 iif (phoneme$ = "a")

beg_phoneme = Get starting point... 1 current_syllablefin_phoneme = Get end point... 1 current_syllablephoneme_dur = fin_phoneme - beg_phonemefileappend 'outputfile1$' 'phoneme$' 'tab$' 'phoneme_dur' 'newline$'

endifendfor

Page 116: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Notez bien !

On peut soustraire la valeur d'une variable à celle d'une autre en enregistrant la valeur dans une 3ème variable– phoneme_dur = fin_phoneme - beg_phoneme

pas d'espace dans les noms de variables

Page 117: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Notez bien !

On peut soustraire la valeur d'une variable à celle d'une autre en enregistrant la valeur dans une 3ème variable– phoneme_dur = fin_phoneme - beg_phoneme

pas de majuscule non plus

Page 118: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Notez bien !

ça marche aussi pour les variables contenant des mots et non des chiffres ( toto$ || toto )

path$ = "C:\WINDOWS\Bureau\cours_prog_praat\" file$ = path$ + "track01.wav"

… comme dans l'exemple que l'on utilisedans notre script

Page 119: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Page 120: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

exercice 6 Terminez l'exercice ….

analysez la Fo, la durée, l’intensité et les valeurs des 3 premiers formants de tous les [a] de ce fichier et affichez le résultat dans un fichier Excel (présentation libre… mais soignée!).

consignes : prenez deux types de valeurs– une au milieu de chaque [a] …il faudra déterminer ce milieu grâce aux

valeurs de début et de fin des différents [a].– l ’autre sera une valeur moyenne calculée sur toute la durée de chaque [a]

Page 121: Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA PROGRAMMER AVEC PRAAT Cédric Gendrot cgendrot@univ-paris3.fr.

Cédric Gendrot - TAL SLOW 5 - 2003-2004 - ILPGA

Les bonnes habitudes de programmation Le script ici fonctionne ! …

… mais n'est pas très "efficace" en termes de programmation

– perte de temps ( :-) ! )– peu évolutif