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.

63 lines
2.0 KiB

  1. novoapi( https://bitbucket.org/novolanguage/python-novo-api ) is written in Python 2.7.
  2. To install it on Python 3.x the following points should be modified.
  3. - basestring --> str
  4. - print xxx --> print({}.format(xxx)).
  5. - import xxx --> from . import xxx
  6. - except Exception, e --> except Exception as e
  7. - remove tuples from input arguments of a function.
  8. Concretely...
  9. === novoapi\backend\__init__.py
  10. #import session
  11. from . import session
  12. === novoapi\backend\session.py
  13. #except Exception, e:
  14. except Exception as e:
  15. #print self.last_message
  16. print(self.last_message)
  17. === novoapi\asr\__init__.py
  18. #import segments
  19. #import spraaklab
  20. from . import segments
  21. from . import spraaklab
  22. === novoapi\asr\segments\praat.py
  23. #print_tier(output, "confidence", begin, end, confidences, ('%.3f', lambda x: x))
  24. #print_tier(output, "words", begin, end, word_labels, ('%s', lambda x: x))
  25. #print_tier(output, "phones", begin, end, phones, ('%s', lambda x: x))
  26. print_tier(output, "confidence", begin, end, confidences, '%.3f', lambda x: x)
  27. print_tier(output, "words", begin, end, word_labels, '%s', lambda x: x)
  28. print_tier(output, "phones", begin, end, phones, '%s', lambda x: x)
  29. === novoapi\asr\spraaklab\__init__.py ===
  30. #import schema
  31. from . import schema
  32. === novoapi\asr\spraaklab\schema.py ===
  33. #if isinstance(object, basestring):
  34. if isinstance(object, str):
  35. except jsonschema.ValidationError as e:
  36. #print data, "validated not OK", e.message
  37. print("{0} validated not OK {1}".format(data, e.message))
  38. else:
  39. #print data, "validated OK"
  40. print("{0} validated OK".format(data))
  41. Then to make it correctly work, few more modification is needed.
  42. When the wav file is read using the wave module, the output (named buf) is a string of bytes on Python 2.7 while buf is a byte object on Python 3.6.
  43. Therefore...
  44. === novoapi\backend\session.py
  45. #audio_packet = str(buf[j:j + buffer_size])
  46. audio_packet = buf[j:j + buffer_size]
  47. Also, because of this difference, Segment.__repr__ (novoapi\asr\segments\segments.py) does not work.