patrickreidy / textgrid Goto Github PK
View Code? Open in Web Editor NEWPraat TextGrid Objects in R
Praat TextGrid Objects in R
We're having trouble opening TextGrid files using textgRid
. Here is the output we get with two different approaches:
> library(textgRid)
> textgrid <- TextGrid(system.file('data', 'TatarKQ', 'File001.TextGrid'))
Error in mapply(FUN = f, ..., SIMPLIFY = FALSE) :
zero-length inputs cannot be mixed with those of non-zero length
In addition: Warning message:
In file(con, "r") :
file("") only supports open = "w+" and open = "w+b": using the former
> textgrid <- TextGrid('./data/TatarKQ/File001.TextGrid')
Error in mapply(FUN = f, ..., SIMPLIFY = FALSE) :
zero-length inputs cannot be mixed with those of non-zero length
This is using R 3.6.3. Is there something we're doing wrong?
The functions drop all annotations (intervals and points) with NA
labels because the default for the pattern
argument (used by grep) is "*"
.
Instead the functions should by default match all intervals and points. Otherwise it will not return (arguably very common) unlabeled points (these may be used e.g. when there is only one type of event in a tier, let's say "conversational turns". The label can then be specified in the tier name, so an additional label for each point is unnecessary). It also does not find unlabeled intervals (which e.g. may be a way to code silence).
This behavior also creates problems further down the line with as.data.frame()
so that the NA
labeled intervals and points are not present in the data frame. This essentially is a loss of information, because the gaps (at least the gaps at the beginning and end of the tiers) cannot be reliably reconstructed from the data frame. This also means that a TextGrid constructor for data frames will not be able to reconstruct the original TextGrid, i.e. for a textgrid object x it will not be possible to guarantee that TextGrid(as.data.frame(x)) == x
It is always easy for the user to filter NA
elements later, but it shouldn't be a default that cannot be circumvented.
Grep will never match NA
, regardless of the pattern, so the default has to be pattern = NULL
or the like, so that grep can be done conditional on whether a pattern is supplied (e.g. if(is.null(pattern))
) or not.
Example of behavior:
textgrid <- TextGrid(system.file('extdata', 'myExample.TextGrid',
package = 'textgRid'))
findPoints(textgrid@.Data[[3]])
# Index Time Label
# 1 1 6.75 voicingOn
# 2 2 8.25 voicingOff
textgrid@.Data[[3]]@labels[1] <- NA # set 1st label to NA
findPoints(textgrid@.Data[[3]])
# Index Time Label
# 1 2 8.25 voicingOff
When trying to open the attached TextGrid using:
tg = TextGrid("ipiapacs_speaker0006_0005_speech_E.TextGrid")
I get the following error:
Error in mapply(FUN = f, ..., SIMPLIFY = FALSE) :
zero-length inputs cannot be mixed with those of non-zero length
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Warning messages:
1: In readLines(file) : line 1 appears to contain an embedded nul
2: In readLines(file) : line 2 appears to contain an embedded nul
[...]
Both with version textgRid_1.0.1 and also with the latest development version (textgRid_1.0.2)
If I try to open a TextGrid file which containts tabulars instead of 4 spaces, there is an error message:
Error in mapply(FUN = f, ..., SIMPLIFY = FALSE) :
zero-length inputs cannot be mixed with those of non-zero length
If I replace the tabs with 4 spaces (in a text editor), opening the TextGrid file is OK.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.