Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {{
- ┌─────────────────────────────────────────────────────────┐
- │ Emic 2 Text-to-Speech Module: Basic Demonstration │
- │ │
- │ Author: Joe Grand [www.grandideastudio.com] │
- │ Contact: [email protected] │
- │ │
- │ See end of file for terms of use. │
- └─────────────────────────────────────────────────────────┘
- Program Description:
- This program demonstrates the Emic 2 Text-to-Speech Module.
- Debug messages are displayed in the Parallax Serial Terminal.
- Please refer to the Emic 2 product manual for full details
- of functionality and capabilities.
- Emic 2 Connections (4 pin male header)
- ────────────────────────────────────────────────
- SIN ────── P6
- SOUT ────── P7
- VCC ────── +5V (VDD)
- GND ──────┐
-
- GND (VSS)
- Revisions:
- 1.0 (February 14, 2012): Initial release
- }}
- CON
- _clkmode = xtal1 + pll16x
- _xinfreq = 5_000_000
- EMIC_TX = 6 ' Serial output (connects to Emic 2 SIN)
- EMIC_RX = 7 ' Serial input (connects to Emic 2 SOUT)
- VAR
- OBJ
- pst : "Parallax Serial Terminal" ' Debug Terminal
- serial : "FullDuplexSerial" ' Full Duplex Serial
- PUB main
- pst.Start(115_200) ' Set Parallax Serial Terminal to 115.2kbps
- pst.Clear ' Clear PST screen
- pst.Str(@InitHeader) ' Print header; uses string in DAT section.
- ' Set-up serial port for communication with the Emic 2
- serial.Start(EMIC_RX, EMIC_TX, %0000, 9_600) ' Start serial port, normal mode, 9600bps
- {{
- When the Emic 2 powers on, it takes about 3 seconds for it to successfully
- intialize. It then sends a ":" character to indicate it's ready to accept
- commands. If the Emic 2 is already initialized, a CR will also cause it
- to send a ":"
- }}
- pst.Str(String("Waiting for Emic 2..."))
- serial.TX(pst#NL) ' Send a CR in case the system is already up
- 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
- pst.Str(String("Ready!", pst#NL))
- waitcnt(clkfreq / 100 + cnt) ' Delay 10mS
- serial.RxFlush ' Flush the receive buffer
- pst.Str(String("Speaking some text..."))
- serial.TX("S")
- serial.Str(@TextString) ' Send the desired string to convert to speech (stored in the DAT section below)
- serial.TX(pst#NL)
- repeat until serial.RxCheck == ":" ' Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command
- pst.Str(String("Done!", pst#NL))
- waitcnt(clkfreq >> 1 + cnt) ' Delay 1/2 second
- pst.Str(String("Singing a song..."))
- serial.Str(String("D1", pst#NL)) ' Play the built-in demonstration song. See the product manual for exact settings used to create this song.
- repeat until serial.RxCheck == ":" ' Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command
- pst.Str(String("Done!", pst#NL))
- DAT
- InitHeader byte "Emic 2 Text-to-Speech Module Demonstration", pst#NL, pst#NL, 0
- TextString byte "Hello. My name is the Emic 2 Text-to-Speech module. I would like to sing you a song.", 0
- {{
- ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ TERMS OF USE: MIT License │
- ├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
- │Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation │
- │files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, │
- │modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software│
- │is furnished to do so, subject to the following conditions: │
- │ │
- │The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.│
- │ │
- │THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE │
- │WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR │
- │COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │
- │ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │
- └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement