ttsTask.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "includes.h"
  2. OS_TID idTTSTask=0;
  3. U64 stkTTSTask[TTS_TASK_STK_SIZE];
  4. OS_SEM TTSonSem;
  5. TTS_DEF ttsVoice;
  6. void MeSpeak(ENCODE_DEF type, char *voice, unsigned char useLocalOrNot)
  7. {
  8. unsigned short len;
  9. len = strlen(voice);
  10. if(len > TTS_VOICE_SIZE) len = TTS_VOICE_SIZE;
  11. if(useLocalOrNot==0)
  12. {
  13. memcpy(ttsVoice.voice, voice, len);
  14. if(len < TTS_VOICE_SIZE) ttsVoice.voice[len]=0;
  15. ttsVoice.voiceStatic=NULL;
  16. }else{
  17. ttsVoice.voiceStatic = voice;
  18. }
  19. ttsVoice.Languange = type;
  20. ttsVoice.Update++;
  21. os_sem_send(&TTSonSem);
  22. }
  23. void LocalTTSHandle(void)
  24. {
  25. char buf[15];
  26. if(ttsVoice.Update == 0) return;
  27. ModemSendAT("AT+LSHTTSSTP\r\n");
  28. os_dly_wait(30);
  29. sutPocStatus.TTS=1;
  30. SpeakerEnable();
  31. sprintf(buf, "AT+LSHTTS=%d,\"",ttsVoice.Languange);
  32. ModemSendAT(buf);
  33. if(ttsVoice.voiceStatic == NULL)
  34. ModemSendAT(ttsVoice.voice);
  35. else
  36. ModemSendAT(ttsVoice.voiceStatic);
  37. ModemSendAT("\"\r\n");
  38. ttsVoice.Update=0;
  39. os_dly_wait(30);
  40. }
  41. __task void TTSTask(void)
  42. {
  43. memset((unsigned char *)&ttsVoice, 0, sizeof(TTS_DEF));
  44. os_sem_init (&TTSonSem, 0);
  45. while(1)
  46. {
  47. os_sem_wait (&TTSonSem, 0xffff);
  48. LocalTTSHandle();
  49. }
  50. }