Topics

difficulty of selection

veikko.hari@...
 

Hi!

Could someone be so kind to advise me about selections in TextGrid
editor window? I'm writing a script, which ought to extract every
segment labeled "e"from a sound file. It works fine with the first
one of such segments, but on the second one it includes also the
previous segment to the selection to be extracted. The problem seems
to be that "starting point" does not mean the starting point of the
"interval" on the previous row in the script, but I don't understand
what else could it mean. Below is a part of the script I'm writing.

Veikko

# A part of the sript:
getidofselected s1 Sound
getidofselected tg1 TextGrid
select 'tg1'
getnumber ivals = Get number of intervals... 1

for i from 1 to 'ivals'
select 'tg1'
lab$ = Get label of interval... 1 i # this is the
sta = Get starting point... 1 i # hard part
end = Get end point... 1 i
if lab$ = "e"
plus 's1'
Edit
editor TextGrid story1
Move B to... sta
Move E to... end
Extract sound selection (preserve times)
endeditor

To Formant (burg)... 0.01 5 5500 0.025 50
getidofselected for1 Formant
Scatter plot (reversed axes)... 0 0 2 500 2500 1 0 1000 10 no 'i'

endif
endfor
#

Geoff Morrison <gsm@...>
 

At 08:29 AM 26/05/2001 -0000, you wrote:
Hi!

Could someone be so kind to advise me about selections in TextGrid
editor window? I'm writing a script, which ought to extract every
segment labeled "e"from a sound file. It works fine with the first
one of such segments, but on the second one it includes also the
previous segment to the selection to be extracted. The problem seems
to be that "starting point" does not mean the starting point of the
"interval" on the previous row in the script, but I don't understand
what else could it mean. Below is a part of the script I'm writing.

Veikko

# A part of the sript:
getidofselected s1 Sound
getidofselected tg1 TextGrid
select 'tg1'
getnumber ivals = Get number of intervals... 1

for i from 1 to 'ivals'
select 'tg1'
lab$ = Get label of interval... 1 i # this is the
sta = Get starting point... 1 i # hard part
end = Get end point... 1 i
if lab$ = "e"
plus 's1'
Edit
editor TextGrid story1
Move B to... sta
Move E to... end
Extract sound selection (preserve times)
endeditor

To Formant (burg)... 0.01 5 5500 0.025 50
getidofselected for1 Formant
Scatter plot (reversed axes)... 0 0 2 500 2500 1 0 1000 10 no 'i'

endif
endfor
#

It isn't obvious to me why your script isn't working but I can offer a
solution that works in one of my scripts. You have suggested that it is the
acquisition of the time of the starting point that is a problem rather than
the actual selection process. Below is a section from one of my scripts
where the times are acquired from the IntervalTier rather than the
TextGrid. I hope this helps.

The user is cued for the segment to search for. The start, centre, and end
times of all occurrences of this segment are then stored in matrix variables.

# Ask the user which segment name to measure.

form What is the label for the segment(s) you wish to measure?
word segment_name
endform

# Get the centre, starting, and end times of the chosen segment.

select TextGrid 'textgrid_name$'
Extract tier... 1
intervaltier_name$ = selected$ ("IntervalTier")
Get centre points... 'segment_name$'
# will need the ID of the centre PointProcess later
centre_ID = selected ("PointProcess")
number_of_segments = Get number of points
for i from 1 to number_of_segments
centre'i' = Get time from index... i
endfor
select IntervalTier 'intervaltier_name$'
Get starting points... 'segment_name$'
for i from 1 to number_of_segments
start'i' = Get time from index... i
endfor
select IntervalTier 'intervaltier_name$'
Get end points... 'segment_name$'
for i from 1 to number_of_segments
end'i' = Get time from index... i
endfor


The whole script returns a list of F1 and F2 values for the centre points
of each occurrence of the user requested segment and displays spectrograms
and formant tracking for user verification of the values. It is available
at http://www.sfu.ca/~phonetic/18May2001
_______________________________________________________
Geoff Morrison
Researcher in Phonetics

Graduate Student, Simon Fraser University, BC, Canada

http://japan.co.jp/~geoff
mailto:gsm@... or mailto:geoff@...
GeoffMorrison@...

Paul Boersma <paul.boersma@...>
 

Dear Veikko,

the thing that goes wrong is exemplified by the following sequence:

Move B to... 1.0
Move E to... 2.0
Move B to... 3.0
Move E to... 4.0

you would think that after this, the selection would be from 3.0 to 4.0 seconds?
Wrong! In the third line, you move B to 3.0 seconds. However, E was already
at 2.0 seconds, so the roles of B and E now have to interchange, i.e. the selection
runs from 2.0 to 3.0 seconds. With the fourth line, this is extended and
becomes 2.0 to 4.0 seconds.

You can prevent this by adding the line

Move B to... 3.0

again at the end, i.e.

Move B to... sta
Move E to... end
Move B to... sta

does the trick.

However, your script contains several problems. First, it is not necessary
to enter the editor at all: you can just select the Sound and do
"Extract part... sta end".
More seriously, large parts of the vowel will not be analysed
because of the windowing. You might like to use "Extract part... sta-0.01 end+0.01"
or so, depending on the length of your required unanalysed margins.
Finally, your script mixes modern Praat-script syntax with the syntax
of Praat scripts before June 1998, now undocumented. This makes the script less
readable. Try:

s1 = selected ("Sound")
tg1 = selected ("TextGrid")
select 'tg1'
ivals = Get number of intervals... 1
for i from 1 to ivals

and so on.

Best wishes,
Paul
--

Paul Boersma
Institute of Phonetic Sciences, University of Amsterdam
Herengracht 338, 1016CG Amsterdam, The Netherlands
http://www.fon.hum.uva.nl/paul/
phone +31-20-5252385