2019-01-07 11:50:24 +01:00
|
|
|
|
#
|
|
|
|
|
# forced alignment using novo-api.
|
|
|
|
|
#
|
|
|
|
|
# *** IMPORTANT ***
|
|
|
|
|
# This file should be treated as confidencial.
|
|
|
|
|
# This file should not be copied or uploaded to public sites.
|
|
|
|
|
#
|
|
|
|
|
# NOTES:
|
|
|
|
|
# The usage of novo api: https://bitbucket.org/novolanguage/python-novo-api
|
|
|
|
|
# I couldn't make it work as I described in the mail to Martijn Bartelds on
|
|
|
|
|
# 2018/12/03.
|
|
|
|
|
# As per the advice from him, I modified testgrammer.py and made it a function.
|
|
|
|
|
#
|
|
|
|
|
# In order to run on Python 3.6, the following points are changed in novo-api.
|
|
|
|
|
# (1) backend/__init__.py
|
|
|
|
|
# - #import session
|
|
|
|
|
# from . import session
|
|
|
|
|
# (2) backend/session.py
|
|
|
|
|
# - #except Exception, e:
|
|
|
|
|
# except Exception as e:
|
|
|
|
|
# - #print self.last_message
|
|
|
|
|
# print(self.last_message)
|
|
|
|
|
# (3) asr/segment/praat.py
|
|
|
|
|
# - def print_tier(output, title, begin, end, segs, (format, formatter))
|
|
|
|
|
# def print_tier(output, title, begin, end, segs, format, formatter):
|
|
|
|
|
# (4) asr/spraaklab/__init.py
|
|
|
|
|
# - #import session
|
|
|
|
|
# from . import session
|
|
|
|
|
# (5) asr/spraaklab/schema.py
|
|
|
|
|
# - #print data, "validated not OK", e.message
|
|
|
|
|
# print("{0} validated not OK {1}".format(data, e.message))
|
|
|
|
|
# - #print data, "validated OK"
|
|
|
|
|
# print("{} validated OK".format(data))
|
|
|
|
|
# - #if isinstance(object, basestring):
|
|
|
|
|
# if isinstance(object, str)
|
|
|
|
|
#
|
|
|
|
|
# Aki Kunikoshi
|
|
|
|
|
# 428968@gmail.com
|
|
|
|
|
#
|
2019-01-10 23:39:02 +01:00
|
|
|
|
import os
|
|
|
|
|
os.chdir(r'C:\Users\Aki\source\repos\acoustic_model\acoustic_model')
|
|
|
|
|
|
2019-01-07 11:50:24 +01:00
|
|
|
|
import argparse
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
from novoapi.backend import session
|
2019-01-07 23:27:02 +01:00
|
|
|
|
import novoapi_functions
|
2019-01-10 23:39:02 +01:00
|
|
|
|
import defaultfiles as default
|
2019-01-07 11:50:24 +01:00
|
|
|
|
|
|
|
|
|
# username / password cannot be passed as artuments...
|
|
|
|
|
p = argparse.ArgumentParser()
|
|
|
|
|
#p.add_argument("--user", default=None)
|
|
|
|
|
#p.add_argument("--password", default=None)
|
|
|
|
|
p.add_argument("--user", default='martijn.wieling')
|
2019-02-06 00:00:14 +01:00
|
|
|
|
p.add_argument("--password", default='xxxxxx')
|
2019-01-07 11:50:24 +01:00
|
|
|
|
args = p.parse_args()
|
|
|
|
|
|
2019-01-10 23:39:02 +01:00
|
|
|
|
#wav_file = 'c:\\OneDrive\\WSL\\test\\onetwothree.wav'
|
|
|
|
|
wav_file = os.path.join(default.stimmen_wav_dir, 'pg_pauw_2206_0fjd8.wav')
|
2019-01-07 23:27:02 +01:00
|
|
|
|
# list of the pronunciation for each words
|
|
|
|
|
word = 'pauw'
|
|
|
|
|
pronunciation_ipa = ['pau', 'pɑu']
|
2019-01-10 23:39:02 +01:00
|
|
|
|
|
|
|
|
|
result = novoapi_functions.forced_alignment(wav_file, word, pronunciation_ipa)
|
|
|
|
|
pronunciation_ipa, pronunciation_novo70, llh = novoapi_functions.result2pronunciation(result, word)
|