You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.1 KiB

  1. #
  2. # forced alignment using novo-api.
  3. #
  4. # *** IMPORTANT ***
  5. # This file should be treated as confidencial.
  6. # This file should not be copied or uploaded to public sites.
  7. #
  8. # NOTES:
  9. # The usage of novo api: https://bitbucket.org/novolanguage/python-novo-api
  10. # I couldn't make it work as I described in the mail to Martijn Bartelds on
  11. # 2018/12/03.
  12. # As per the advice from him, I modified testgrammer.py and made it a function.
  13. #
  14. # In order to run on Python 3.6, the following points are changed in novo-api.
  15. # (1) backend/__init__.py
  16. # - #import session
  17. # from . import session
  18. # (2) backend/session.py
  19. # - #except Exception, e:
  20. # except Exception as e:
  21. # - #print self.last_message
  22. # print(self.last_message)
  23. # (3) asr/segment/praat.py
  24. # - def print_tier(output, title, begin, end, segs, (format, formatter))
  25. # def print_tier(output, title, begin, end, segs, format, formatter):
  26. # (4) asr/spraaklab/__init.py
  27. # - #import session
  28. # from . import session
  29. # (5) asr/spraaklab/schema.py
  30. # - #print data, "validated not OK", e.message
  31. # print("{0} validated not OK {1}".format(data, e.message))
  32. # - #print data, "validated OK"
  33. # print("{} validated OK".format(data))
  34. # - #if isinstance(object, basestring):
  35. # if isinstance(object, str)
  36. #
  37. # Aki Kunikoshi
  38. # 428968@gmail.com
  39. #
  40. import os
  41. os.chdir(r'C:\Users\Aki\source\repos\acoustic_model\acoustic_model')
  42. import argparse
  43. import json
  44. from novoapi.backend import session
  45. import novoapi_functions
  46. import defaultfiles as default
  47. # username / password cannot be passed as artuments...
  48. p = argparse.ArgumentParser()
  49. #p.add_argument("--user", default=None)
  50. #p.add_argument("--password", default=None)
  51. p.add_argument("--user", default='martijn.wieling')
  52. p.add_argument("--password", default='xxxxxx')
  53. args = p.parse_args()
  54. #wav_file = 'c:\\OneDrive\\WSL\\test\\onetwothree.wav'
  55. wav_file = os.path.join(default.stimmen_wav_dir, 'pg_pauw_2206_0fjd8.wav')
  56. # list of the pronunciation for each words
  57. word = 'pauw'
  58. pronunciation_ipa = ['pau', 'pɑu']
  59. result = novoapi_functions.forced_alignment(wav_file, word, pronunciation_ipa)
  60. pronunciation_ipa, pronunciation_novo70, llh = novoapi_functions.result2pronunciation(result, word)