Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.82 KB | None | 0 0
  1. {{
  2. ┌─────────────────────────────────────────────────────────┐
  3. │ Emic 2 Text-to-Speech Module: Basic Demonstration │
  4. │ │
  5. │ Author: Joe Grand [www.grandideastudio.com] │
  6. │ Contact: [email protected]
  7. │ │
  8. │ See end of file for terms of use. │
  9. └─────────────────────────────────────────────────────────┘
  10.  
  11. Program Description:
  12.  
  13. This program demonstrates the Emic 2 Text-to-Speech Module.
  14. Debug messages are displayed in the Parallax Serial Terminal.
  15. Please refer to the Emic 2 product manual for full details
  16. of functionality and capabilities.
  17.  
  18.  
  19. Emic 2 Connections (4 pin male header)
  20. ────────────────────────────────────────────────
  21.  
  22. SIN ────── P6
  23. SOUT ────── P7
  24. VCC ────── +5V (VDD)
  25. GND ──────┐
  26. GND (VSS)
  27.  
  28.  
  29. Revisions:
  30.  
  31. 1.0 (February 14, 2012): Initial release
  32.  
  33. }}
  34.  
  35.  
  36. CON
  37. _clkmode = xtal1 + pll16x
  38. _xinfreq = 5_000_000
  39.  
  40. EMIC_TX = 6 ' Serial output (connects to Emic 2 SIN)
  41. EMIC_RX = 7 ' Serial input (connects to Emic 2 SOUT)
  42.  
  43. VAR
  44.  
  45.  
  46. OBJ
  47. pst : "Parallax Serial Terminal" ' Debug Terminal
  48. serial : "FullDuplexSerial" ' Full Duplex Serial
  49.  
  50. PUB main
  51. pst.Start(115_200) ' Set Parallax Serial Terminal to 115.2kbps
  52. pst.Clear ' Clear PST screen
  53. pst.Str(@InitHeader) ' Print header; uses string in DAT section.
  54.  
  55. ' Set-up serial port for communication with the Emic 2
  56. serial.Start(EMIC_RX, EMIC_TX, %0000, 9_600) ' Start serial port, normal mode, 9600bps
  57.  
  58. {{
  59. When the Emic 2 powers on, it takes about 3 seconds for it to successfully
  60. intialize. It then sends a ":" character to indicate it's ready to accept
  61. commands. If the Emic 2 is already initialized, a CR will also cause it
  62. to send a ":"
  63. }}
  64. pst.Str(String("Waiting for Emic 2..."))
  65. serial.TX(pst#NL) ' Send a CR in case the system is already up
  66. repeat until serial.RxCheck == ":" ' When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
  67. pst.Str(String("Ready!", pst#NL))
  68.  
  69. waitcnt(clkfreq / 100 + cnt) ' Delay 10mS
  70. serial.RxFlush ' Flush the receive buffer
  71.  
  72. pst.Str(String("Speaking some text..."))
  73. serial.TX("S")
  74. serial.Str(@TextString) ' Send the desired string to convert to speech (stored in the DAT section below)
  75. serial.TX(pst#NL)
  76. repeat until serial.RxCheck == ":" ' Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command
  77. pst.Str(String("Done!", pst#NL))
  78.  
  79. waitcnt(clkfreq >> 1 + cnt) ' Delay 1/2 second
  80.  
  81. pst.Str(String("Singing a song..."))
  82. serial.Str(String("D1", pst#NL)) ' Play the built-in demonstration song. See the product manual for exact settings used to create this song.
  83. repeat until serial.RxCheck == ":" ' Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command
  84. pst.Str(String("Done!", pst#NL))
  85.  
  86.  
  87. DAT
  88. InitHeader byte "Emic 2 Text-to-Speech Module Demonstration", pst#NL, pst#NL, 0
  89. TextString byte "Hello. My name is the Emic 2 Text-to-Speech module. I would like to sing you a song.", 0
  90.  
  91.  
  92. {{
  93. ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
  94. │ TERMS OF USE: MIT License │
  95. ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
  96. │Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │
  97. │files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │
  98. │modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│
  99. │is furnished to do so, subject to the following conditions: │
  100. │ │
  101. │The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│
  102. │ │
  103. │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │
  104. │WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │
  105. │COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │
  106. │ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
  107. └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
  108. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement