|
|
|
|
|
library("tuneR")
|
|
|
|
|
|
wv=readWave("six16000.wav")
|
|
sig = wv@left / 2^(wv@bit -1)
|
|
tim = (1:length(sig))/wv@samp.rate
|
|
|
|
|
|
df=read.csv("six16000.csv",check.names = FALSE)
|
|
print(summary(df))
|
|
|
|
|
|
transcript=""
|
|
lastmax=0;
|
|
for (i in 1:nrow(df)) {
|
|
|
|
jmax=0;
|
|
vmax=-100;
|
|
for (j in 2:ncol(df)) {
|
|
if (df[i,j]>vmax) {
|
|
vmax=df[i,j];
|
|
jmax=j;
|
|
}
|
|
}
|
|
|
|
if (colnames(df)[jmax]=="blk") {
|
|
tmp=df[i,lastmax];
|
|
df[i,lastmax]=df[i,jmax];
|
|
df[i,jmax]=tmp;
|
|
}
|
|
else {
|
|
if ((jmax!=lastmax)&&(colnames(df)[jmax]!='unk')) transcript=paste(transcript,colnames(df)[jmax]);
|
|
lastmax=jmax;
|
|
}
|
|
}
|
|
|
|
|
|
tab=as.matrix(df[,1:46])
|
|
tab[which(tab < 0)] = 0
|
|
|
|
|
|
layout(matrix(c(1,2,2,2),nrow=4,ncol=1, byrow = TRUE))
|
|
par(cex=1,mar=c(0,4,2,2));
|
|
plot(tim, sig, type="l", col="darkblue", xlab="", ylab="Amp",xaxt="n")
|
|
par(cex=1,mar=c(5,4,2,2));
|
|
image(tab[,1],1:46,tab[,-1],xlab="Time (s)", ylab="Phone",col=gray.colors(256,start=0,end=1,rev=T),cex=1,main=transcript)
|
|
box()
|
|
|