ttsTask.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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[20];
  30. //static unsigned int tickCnt;
  31. SUT_MODEM_AT_MSG *pMsg=&sutAtmPro;
  32. if(ttsVoice.Update == 0)return ;
  33. else {
  34. if(
  35. (os_time_get() > VoiceTimeCnt)) //如果当前没有语音在播报,则没有LTTS: END返回,则按300ms超时值算
  36. {
  37. ModemSendAT("AT+LSHTTSTP\r\n");
  38. os_dly_wait(30); //85
  39. //播报最新TTS语音
  40. ttsVoice.Update=0;
  41. SpeakerCtrl(1);
  42. //noSpeakFlag=1;
  43. snprintf(buf, sizeof(buf), "AT+LSHTTS=%d,\"",ttsVoice.Languange);
  44. //SlwTrace(INF,ttsVoice.voice,1);
  45. ModemSendAT(buf);
  46. if(ttsVoice.voiceStatic == NULL)
  47. ModemSendAT(ttsVoice.voice);
  48. else
  49. ModemSendAT(ttsVoice.voiceStatic);
  50. ModemSendAT("\"\r\n");
  51. }
  52. }
  53. }
  54. __task void TTSTask(void)
  55. {
  56. memset((unsigned char *)&ttsVoice, 0, sizeof(TTS_DEF));
  57. os_sem_init (&TTSonSem, 0);
  58. while(1)
  59. {
  60. os_sem_wait (&TTSonSem, 0xffff);
  61. LocalTTSHandle();
  62. }
  63. }