-
Notifications
You must be signed in to change notification settings - Fork 24
/
save_selection_to_sound_and_textgrid.praat
executable file
·48 lines (37 loc) · 1.3 KB
/
save_selection_to_sound_and_textgrid.praat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# This script saves the selected portion of a LongSound file to a separate
# Sound file (WAV), and the corresponding part of the TextGrid file to an
# independent TextGrid file. The TextGrid will be "genericized" before saving.
# You have to open the script from within a TextGrid editor window. You can also
# add a new menu command for this script, e.g., in the File menu of the TextGrid editor.
#
# This script is distributed under the GNU General Public License.
# Copyright 9.10.2001 Mietta Lennes
#
form Where do you want to save the files?
comment Folder:
text Folder /home/lennes/tmp
sentence Save_sound_to_subfolder
sentence Save_TextGrid_to_subfolder
sentence Filename utterance1
endform
soundpath$ = folder$ + save_sound_to_subfolder$ + "/" + filename$ + ".wav"
gridpath$ = folder$ + save_TextGrid_to_subfolder$ + "/" + filename$ + ".TextGrid"
filedelete 'soundpath$'
filedelete 'gridpath$'
start = Get begin of selection
end = Get end of selection
endeditor
gridname$ = selected$ ("TextGrid", 1)
soundname$ = selected$ ("LongSound", 1)
select TextGrid 'gridname$'
Extract part... start end no
Genericize
Write to text file... 'gridpath$'
Remove
select LongSound 'soundname$'
Extract part... start end no
Write to WAV file... 'soundpath$'
Remove
select LongSound 'soundname$'
plus TextGrid 'gridname$'
editor