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.

debug.cpp 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include "speech.h"
  4. #include "debug.h"
  5. #ifdef DEBUG_ENABLED
  6. #include <sys/time.h>
  7. #include <unistd.h>
  8. static FILE* fd_log=NULL;
  9. static const char* FILENAME="/tmp/espeak.log";
  10. void debug_init()
  11. {
  12. fd_log = fopen(FILENAME,"a");
  13. setvbuf(fd_log, NULL, _IONBF, 0);
  14. }
  15. void debug_enter(const char* text)
  16. {
  17. struct timeval tv;
  18. gettimeofday(&tv, NULL);
  19. // fd_log = fopen(FILENAME,"a");
  20. if (!fd_log)
  21. {
  22. debug_init();
  23. }
  24. if (fd_log)
  25. {
  26. fprintf(fd_log, "%03d.%03dms > ENTER %s\n",(int)(tv.tv_sec%1000), (int)(tv.tv_usec/1000), text);
  27. // fclose(fd_log);
  28. }
  29. }
  30. void debug_show(const char *format, ...)
  31. {
  32. va_list args;
  33. va_start(args, format);
  34. // fd_log = fopen(FILENAME,"a");
  35. if (!fd_log)
  36. {
  37. debug_init();
  38. }
  39. if (fd_log)
  40. {
  41. vfprintf(fd_log, format, args);
  42. // fclose(fd_log);
  43. }
  44. va_end(args);
  45. }
  46. void debug_time(const char* text)
  47. {
  48. struct timeval tv;
  49. gettimeofday(&tv, NULL);
  50. // fd_log = fopen(FILENAME,"a");
  51. if (!fd_log)
  52. {
  53. debug_init();
  54. }
  55. if (fd_log)
  56. {
  57. fprintf(fd_log, "%03d.%03dms > %s\n",(int)(tv.tv_sec%1000), (int)(tv.tv_usec/1000), text);
  58. // fclose(fd_log);
  59. }
  60. }
  61. #endif