ttsTask.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #include "includes.h"
  2. OS_TID idTTSTask=0;
  3. U64 stkTTSTask[TTS_TASK_STK_SIZE];
  4. OS_SEM TTSonSem;
  5. static int VoiceTimeCnt=0;
  6. //if(os_time_get() < sucCt) continue;
  7. // sucCt = os_time_get()+100;
  8. TTS_DEF ttsVoice;
  9. void MeSpeak(ENCODE_DEF type, char *voice, unsigned char useLocalOrNot)
  10. {
  11. unsigned short len;
  12. len = strlen(voice);
  13. if(len > TTS_VOICE_SIZE) len = TTS_VOICE_SIZE;
  14. if(useLocalOrNot==0)
  15. {
  16. memcpy(ttsVoice.voice, voice, len);
  17. if(len < TTS_VOICE_SIZE) ttsVoice.voice[len]=0;
  18. ttsVoice.voiceStatic=NULL;
  19. }else{
  20. ttsVoice.voiceStatic = voice;
  21. }
  22. ttsVoice.Languange = type;
  23. ttsVoice.Update++;
  24. VoiceTimeCnt = os_time_get()+40;
  25. // os_sem_send(&TTSonSem);////
  26. }
  27. void LocalTTSHandle(void)
  28. {
  29. // char buf[15];
  30. // if(ttsVoice.Update == 0) return;
  31. //
  32. // ModemSendAT("AT+LSHTTSSTP\r\n");
  33. // os_dly_wait(60);
  34. // sutPocStatus.TTS=1;
  35. // SpeakerEnable();
  36. // snprintf(buf, sizeof(buf), "AT+LSHTTS=%d,\"",ttsVoice.Languange);
  37. // ModemSendAT(buf);
  38. // if(ttsVoice.voiceStatic == NULL)
  39. // ModemSendAT(ttsVoice.voice);
  40. // else
  41. // ModemSendAT(ttsVoice.voiceStatic);
  42. // ModemSendAT("\"\r\n");
  43. // ttsVoice.Update=0;
  44. // //time1
  45. // //os_dly_wait(30);
  46. char buf[20];
  47. //static unsigned int tickCnt;
  48. SUT_MODEM_AT_MSG *pMsg=&sutAtmPro;
  49. if(ttsVoice.Update == 0)return ;
  50. else {
  51. if(
  52. (os_time_get() > VoiceTimeCnt)) //如果当前没有语音在播报,则没有LTTS: END返回,则按300ms超时值算
  53. {
  54. ModemSendAT("AT+LSHTTSSTP\r\n");
  55. os_dly_wait(30); //85
  56. //播报最新TTS语音
  57. ttsVoice.Update=0;
  58. SpeakerCtrl(1);
  59. //noSpeakFlag=1;
  60. //SlwTrace(INF, "Ustart",1);
  61. //SlwTrace(INF,"TTS SEND",1);
  62. snprintf(buf, sizeof(buf), "AT+LSHTTS=%d,\"",ttsVoice.Languange);
  63. //SlwTrace(INF,ttsVoice.voice,1);
  64. ModemSendAT(buf);
  65. if(ttsVoice.voiceStatic == NULL)
  66. ModemSendAT(ttsVoice.voice);
  67. else
  68. ModemSendAT(ttsVoice.voiceStatic);
  69. ModemSendAT("\"\r\n");
  70. }
  71. }
  72. }
  73. __task void TTSTask(void)
  74. {
  75. memset((unsigned char *)&ttsVoice, 0, sizeof(TTS_DEF));
  76. os_sem_init (&TTSonSem, 0);
  77. while(1)
  78. {
  79. os_sem_wait (&TTSonSem, 0xffff);
  80. LocalTTSHandle();
  81. }
  82. }