#You need an internet connection to...^ ^ 

install.packages("emuR")
install.packages("dplyr")
install.packages("ggplot2")

## ---is mypath exising?
mypath
## ---is pfadu exising?
pfadu

#Just in case mypath and pfadu do not exist in your R workspace
## ----change mypath 
# mypath = "/Users/reubold/myEMURdata"
# pfadu = "http://www.phonetik.uni-muenchen.de/~jmh/lehre/Rdf"

## ---go externally to this path here ...
mypath

# download testsample.zip from 
#http://www.phonetik.uni-muenchen.de/~jmh/lehre/Rdf/testsample.zip
# and unzip it ...

## ...and have a look at these four filesfor two utterances:
list.files(file.path(mypath,"testsample/german"))

## ---- 
# load package
library(emuR)

# pathger= where are the above mentioned wav and txt files?
pathger = file.path(mypath,"testsample/german")
# targetger = where you want your speech database to be
targetger = file.path(mypath,"gerDB")

## create the speech database
convert_txtCollection(dbName = "gertest",
                     sourceDir = pathger,
                     targetDir = targetger)





## load the database into R
db.ger = load_emuDB(file.path(targetger, "gertest_emuDB"))


runBASwebservice_all(db.ger,
                    transcriptionAttributeDefinitionName = "transcription",
                    language = "eng-AU")


summary(db.ger)

# To open the EMU-webApp:
serve(db.ger)
# in case this fails (e.g. after an update to Chrome Version 70), try:
serve(db.ger,autoOpenURL = "https://ips-lmu.github.io/EMU-webApp/?autoConnect=true")



## forced-alignment by means of the BASwebservices (uncomment by selecting code and
## Code--> Comment/Uncomment Lines):
#runBASwebservice_all(db.ger,
#                    transcriptionAttributeDefinitionName = "transcription",
#                    language = "deu-DE")

# re-open the webApp
serve(db.ger)

## ------------------------------------------------------------------------
list_levelDefinitions(db.ger)



# re-open the webApp with serve(db.ger), then choose the second utterance (or `bundle`) 
# and click on `show hierarchy`; 
# you can choose from the drop-down menu for each level 
# in the upper part of the browser window to select which label or attribute 
# is to be displayed. You can also click on 'rotate by 90°'.
serve(db.ger)

