eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
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.

mkdictlist 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/python
  2. #
  3. # Copyright (C) 2011 Reece H. Dunn
  4. # Licence: GPLv3
  5. #
  6. # A script for generating the dictionary Makefile rules from the files in dictsource.
  7. import sys
  8. import os
  9. voices = set()
  10. dictionaries = {}
  11. # Map voice names to dictionaries when these do not match.
  12. special_voices = {
  13. 'zh-yue': 'zhy',
  14. }
  15. def find_voices(path):
  16. for filename in os.listdir(path):
  17. voice_path = os.path.join(path, filename)
  18. if os.path.isdir(voice_path):
  19. if not filename in ['!v', 'mb']:
  20. find_voices(voice_path)
  21. else:
  22. if filename in special_voices.keys():
  23. voices.add(special_voices[filename])
  24. else:
  25. voices.add(filename)
  26. find_voices('espeak-data/voices')
  27. for filename in os.listdir('dictsource'):
  28. if filename.endswith('_rules') or filename.endswith('_list') or filename.endswith('_listx'):
  29. dic, cat = filename.split('_')
  30. if dic in voices:
  31. if not dic in dictionaries.keys():
  32. dictionaries[dic] = []
  33. dictionaries[dic].append('dictsource/%s' % filename)
  34. print '##### dictionaries:'
  35. print
  36. print 'dictionaries: \\'
  37. for n, name in enumerate(sorted(dictionaries.keys())):
  38. if not name in ['bo']: # espeak fails to read these voices
  39. if n == len(dictionaries.keys()) - 1:
  40. print '\tespeak-data/%s_dict' % name
  41. else:
  42. print '\tespeak-data/%s_dict \\' % name
  43. for name, files in sorted(dictionaries.items()):
  44. print
  45. print '%s: espeak-data/%s_dict' % (name, name)
  46. print 'dictsource/%s_extra:' % name
  47. print '\ttouch dictsource/%s_extra' % name
  48. print 'espeak-data/%s_dict: src/espeak espeak-data/phontab %s dictsource/%s_extra' % (name, ' '.join(sorted(files)), name)
  49. print '\tcd dictsource && ../src/espeak --compile=%s && cd ..' % name