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.

emoji 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/python3
  2. import os
  3. import re
  4. import sys
  5. import codecs
  6. class Emoji:
  7. def __init__(self, m):
  8. self.emoji = m.group(1)
  9. self.pronunciation = m.group(2)
  10. self.codepoints = m.group(3)
  11. self.comment = m.group(4)
  12. def __repr__(self):
  13. return "Emoji(emoji={0}, pronunciation={1}, codepoints={2}, comment={3})".format(
  14. repr(self.emoji),
  15. repr(self.pronunciation),
  16. repr(self.codepoints),
  17. repr(self.comment))
  18. def __str__(self):
  19. return "{0}{1}// [{2}]{3}".format(self.emoji, self.pronunciation, self.codepoints, self.comment)
  20. def read_emoji(filename, encoding="utf-8"):
  21. re_emoji = re.compile(r"^([^ \t]*)([^/]*)// \[([^\]]*)\](.*)$")
  22. with codecs.open(filename, "r", encoding) as f:
  23. for line in f:
  24. line = line.replace("\n", "")
  25. if line.strip() == "":
  26. yield line # blank line
  27. elif line.startswith("//"):
  28. yield line # line comment
  29. elif line.startswith("$"):
  30. yield line # flags only
  31. else:
  32. m = re_emoji.match(line)
  33. if m:
  34. yield Emoji(m)
  35. else:
  36. yield line
  37. for line in read_emoji(sys.argv[1]):
  38. print(line)