Shop OBEX P1 Docs P2 Docs Learn Events
Emic2 code for the propeller — Parallax Forums

Emic2 code for the propeller

Jim the HermitJim the Hermit Posts: 79
edited 2013-07-11 11:21 in Propeller 1
Can someone post code for the emic2? just a spin file saying a few things.

I got the demo program to work, but I don't know how to change the volume or the voice, pitch, etc.

The demo uses the Parallax Serial Terminal, which I want to get rid of (I successfully hook up my LCD to do the same thing.)

I can't delete pst from OBJ because something called pst#NL gets sent to the emic for some reason.


The emic2 manual has no examples in a computer language as far as I can tell.
Example:
:V-10
:

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-07-29 15:12
    pst#NL is a carraige return. ASCII 13.

    Remember the ":" is what the EMIC 2 returns. It isn't part of the command.

    In your example, if you were using PST as a serial device you'd use:
      Pst.str(string("v-10", 13))
    

    Would set the volume to -10.

    And to say "Hello World" use:

      Pst.str(string("SHello World", 13))
    

    The "S" is for "say" or "speak" (I don't remember which).

    I'm pretty sure the Emic 2 doesn't care about case.

    Have you seen this thread?
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2012-07-29 15:38
    Can someone post code for the emic2? just a spin file saying a few things.

    I got the demo program to work, but I don't know how to change the volume or the voice, pitch, etc.

    The demo uses the Parallax Serial Terminal, which I want to get rid of (I successfully hook up my LCD to do the same thing.)

    I can't delete pst from OBJ because something called pst#NL gets sent to the emic for some reason.


    The emic2 manual has no examples in a computer language as far as I can tell.
    Example:


    :V-10


    :

    Here is an example playing Happy Birthday...
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
    
    ' -------  Pin assigments ------
      green = 0                                 
      blue  = 1
      red   = 2 
      
     
    OBJ
      pst       : "Parallax Serial Terminal"                   ' Debug Terminal
      serial    : "FullDuplexSerial"                           ' Full Duplex Serial
      
    PUB main
      dira[0..2]~~                                          ' set to outputs (i.e. 1)
      outa[0..2]~~                                          ' set high
    
    
      serial.Start(7, 6, 00, 9_600)                      ' Start serial port, normal mode, 9600bps
      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
      
      waitcnt(clkfreq / 100 + cnt)                          ' Delay 10mS
      serial.RxFlush                                        ' Flush the receive buffer
      
    
    
      serial.Str(String("R", pst#NL))                        'reset to defaults
      repeat until serial.RxCheck == ":"
    
    
      serial.Str(String("P0", pst#NL))                       'set Parser to DecTalk
      repeat until serial.RxCheck == ":"
    
    
    '  serial.Str(String("N2", pst#NL))                      'voice
    '  repeat until serial.RxCheck == ":"
      
      serial.Str(String("V-4", pst#NL))                      'volume -48 to 18
      repeat until serial.RxCheck == ":"
      
      serial.Str(String("W240", pst#NL))                    'words per minute
      repeat until serial.RxCheck == ":"
    
    
      serial.TX("S")
      serial.Str(@HappyBday)                               ' Send the desired string to convert to speech (stored in the DAT section below)
      serial.TX(pst#NL)
      repeat until serial.RxCheck == ":"
    
    
    PUB Delay(mS)       ' Delay in milliseconds  
       waitcnt(clkfreq / 1000 * mS + cnt)
    
    
    DAT
    HappyBday byte "[:phone arpa speak on][:rate 200][:n0]"
              byte "[hxae<300,10>piy<300,10>brrrx<600,12>th<100>dey<600,10>tuw<600,15>yu<1200,14>_<300>"
              byte "hxae<300,10>piy<300,10>brrrx<600,12>th<100>dey<600,10>tuw<600,17>yu<1200,15>_<300>"
              byte "hxae<300,10>piy<300,10>brrrx<600,22>th<100>dey<600,19>dih<600,15>r"
              byte " eh<600,14>m<100,12>ih<350,12>k_<120>_<300>"
              byte "hxae<300,20>piy<300,20>brrrx<600,19>th<100>dey<600,15> tuw<600,17> yu<1200,15>]"
              byte "[:n0]", 0
    
  • Jim the HermitJim the Hermit Posts: 79
    edited 2012-07-29 20:11
    Thanks- I tried something like Pst.str(string("v-10"), but it just said "Vee ten." I'll try again.
  • Jim the HermitJim the Hermit Posts: 79
    edited 2012-07-29 20:15
    Thanks- this example is very useful. But do I need to load in the Debug Terminal? Doesn't it take up RAM space?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-07-29 21:19
    Thanks- this example is very useful. But do I need to load in the Debug Terminal? Doesn't it take up RAM space?

    You need some sort of serial driver in order to communicate with the Emic 2. So yes it does take up some RAM but there's not much you can do about it. If you used BST, you can have it remove unused methods which would cut down on the amount of ram used.

    Since the Emic 2 communicates at 9600 bps, you could probably get away with using Simple Serial which doesn't launch in a separate cog. I personally think you'll have more problems than it would be worth using Simple Serial though.

    If you're going to want to use a debug window, you could use a multi-port serial driver which wouldn't take up much more RAM than the single port driver.
  • vanmunchvanmunch Posts: 568
    edited 2013-07-10 09:44
    Hello, I've been working on trying to get the volume to change and I've been trying to use the examples Duane has given and I've looked at his program example on the other thread, but I don't hear any differences. I'm guessing that there is some goofy thing that I have incorrect (location, or something else that's off). I'm working with the plain demo code (original, unmodified below). Does anyone know where and what to put in the code so that the volume can be increased? The documentation just says "V-10"
    Vx: Set audio volume (dB)
    Set the audio output volume in decibels from -48 (softest) to 18 (loudest).
    This setting will remain in effect until another value is entered or Emic 2 is powered off. Upon power-up,
    the default value is 0.
    Example:
    :V-10
    :
    

    Thanks for your time.

    Dave


    {{
    &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;
    &#9474; Emic 2 Text-to-Speech Module: Basic Demonstration       &#9474;
    &#9474;                                                         &#9474;
    &#9474; Author: Joe Grand [www.grandideastudio.com]             &#9474;
    &#9474; Contact: support@parallax.com                           &#9474; 
    &#9474;                                                         &#9474;
    &#9474; See end of file for terms of use.                       &#9474;                      
    &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;
    
    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)
    &#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;
    
    SIN     &#61609;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#61627; P6
    SOUT    &#61609;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#61627; P7
    VCC     &#61609;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#61627; +5V (VDD)
    GND     &#61609;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;
                   &#61464;
                  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
    
    
    {{
    &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;
    &#9474;                                                   TERMS OF USE: MIT License                                                  &#9474;                                                            
    &#9500;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9508;
    &#9474;Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation    &#9474; 
    &#9474;files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,    &#9474;
    &#9474;modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software&#9474;
    &#9474;is furnished to do so, subject to the following conditions:                                                                   &#9474;
    &#9474;                                                                                                                              &#9474;
    &#9474;The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.&#9474;
    &#9474;                                                                                                                              &#9474;
    &#9474;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE          &#9474;
    &#9474;WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR         &#9474;
    &#9474;COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,   &#9474;
    &#9474;ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                         &#9474;
    &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;
    }}     
    
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-10 10:48
    vanmunch wrote: »
    The documentation just says "V-10

    That would be a very low volume setting. Have you tried "V10"?

    I don't recall what the max setting is, but I'm pretty sure it's a positive number.

    Did you also send a carriage return?

    Edit: The volume range is -48 to 18.

    I know I've used the volume setting on my Emic2 without a problem.
  • vanmunchvanmunch Posts: 568
    edited 2013-07-10 11:33
    Hi Duane,
    One of the things that I tried was to add:
    Pst.str(string("v18", 13))
    

    such as:
      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))   
    
      serial.RxFlush                                        ' Flush the receive buffer
      Pst.str(string("v18", 13))
      serial.TX("S")
      serial.Str(@Introduction)                             ' 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
    
    but no luck :/

    Any suggestions?

    BTW here is another thread where someone was having the same problem. You posted your code at #5. I tried adding what you did, but still no joy. http://forums.parallax.com/showthread.php/141461-Emic-2-and-Parallax-Terminal
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-10 11:41
    What are you using for audio out? I've used my Emic2 with those small Veho360 speakers and it works well. I don't think the audio driver of the Emic2 board is very strong (headphone type of audio out).
  • vanmunchvanmunch Posts: 568
    edited 2013-07-10 11:50
    Duane Degn wrote: »
    What are you using for audio out? I've used my Emic2 with those small Veho360 speakers and it works well. I don't think the audio driver of the Emic2 board is very strong (headphone type of audio out).

    I'm using a pair of earbuds. I don't have a problem hearing anything and I can use the "##" to make it say a word softer. I just can't get it to be louder of softer using
    Pst.str(string("v18", 13))

    I know that I must be making some small mistake.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-10 11:52
    The "V" needs to be uppercase.
    vanmunch wrote: »
    I know that I must be making some small mistake.

    I think you're right.
  • vanmunchvanmunch Posts: 568
    edited 2013-07-10 11:59
    Duane Degn wrote: »
    The "V" needs to be uppercase.



    I think you're right.

    I tried it again just now with the uppercase "V" and there is no difference.

    Pst.str(string("V18", 13))
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-10 12:01
    If you attach an archived version of the code you're using, I'll try it out with my Emic2.
  • vanmunchvanmunch Posts: 568
    edited 2013-07-10 12:07
    Thanks Duane, below is the code that I'm using. The only difference is the Pst.str(string("V18", 13)) that I've added and I made it so that it doesn't sing the song. It's a great song, but after the 10th time... :)


    {{
    &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;
    &#9474; Emic 2 Text-to-Speech Module: Basic Demonstration       &#9474;
    &#9474;                                                         &#9474;
    &#9474; Author: Joe Grand [www.grandideastudio.com]             &#9474;
    &#9474; Contact: support@parallax.com                           &#9474; 
    &#9474;                                                         &#9474;
    &#9474; See end of file for terms of use.                       &#9474;                      
    &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;
    
    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)
    &#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;
    
    SIN     &#61609;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#61627; P6
    SOUT    &#61609;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#61627; P7
    VCC     &#61609;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#61627; +5V (VDD)
    GND     &#61609;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;
                   &#61464;
                  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..."))
      Pst.str(string("V18", 13))    
      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
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-10 12:11
    Could you save it as an archive? Just in case something in your Prop library has been modified.
  • vanmunchvanmunch Posts: 568
    edited 2013-07-10 12:23
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-10 13:42
    Just found my Veho 360. Wouldn't you know it; it was in the box marked "Speakers". I hate when I put stuff away. I usually have a couple of small speakers scattered about my work area. What possessed me to clean up?

    I'll test the code soon.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-10 14:12
    The program seems to work with my hardware.

    Here's another demo to make it easier to tell if the volume is changing.
    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)
    
    
      MAX_VOL = 18
      MIN_VOL = -48
      VOL_STEP = 6
      
    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("Set and Speak Volume", pst#NL))
      repeat
        repeat result from MIN_VOL to MAX_VOL - 1 step VOL_STEP
          SetAndSayVolume(result)
        repeat result from MAX_VOL to MIN_VOL + 1 step VOL_STEP
          SetAndSayVolume(result)
     
    PUB SetAndSayVolume(volume)
    
    
      serial.TX("V")
      serial.dec(volume)
      serial.TX(pst#NL)
      serial.rxtime(500)
      serial.TX("S")
      serial.Str(@textTheVol)
      serial.dec(volume)
      pst.Str(@textTheVol)
      pst.dec(volume)
      serial.TX(pst#NL) 
      pst.Char(pst#NL)
      serial.rxtime(500)
      waitcnt(clkfreq * 6 + cnt)
    DAT
    InitHeader    byte "Emic 2 Text-to-Speech Module Demonstration", pst#NL, pst#NL, 0
    textTheVol    byte "The volume of the E mic 2 is now set to ", 0 
    
    
    

    The volume gets very loud at 18 and I can barely hear it when it's -30.
  • vanmunchvanmunch Posts: 568
    edited 2013-07-10 20:15
    Duane Degn wrote: »
    The program seems to work with my hardware.

    Here's another demo to make it easier to tell if the volume is changing.


    The volume gets very loud at 18 and I can barely hear it when it's -30.

    Hey Duane, thanks!
    I got it working on my set-up. It seems like the key was to break the volume command into three part (two might work, but that's for tomorrow). Changed this:
    Pst.str(string("V18", 13))
    
    to this:
      serial.TX("V")
      serial.dec(18)
      serial.TX(pst#NL)
    

    Thanks again for all of your help and for taking the time in getting out your speaker, setting it up, and making the variable volume demo. :)

    Dave
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-10 20:51
    I think the difference is in your second code block you used the "serial" object while in the first code block you used "Pst". I now notice you did the same thing in post #9.

    So the problem was your using the wrong serial line. I didn't notice it until now.
  • vanmunchvanmunch Posts: 568
    edited 2013-07-11 08:10
    Duane Degn wrote: »
    I think the difference is in your second code block you used the "serial" object while in the first code block you used "Pst". I now notice you did the same thing in post #9.

    So the problem was your using the wrong serial line. I didn't notice it until now.

    You're right! I changed it to the serial object serial.str(string("V18", 13)) and it works just fine. Details? hu? they make a difference. :) Thanks again for your help.

    Dave
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-07-11 11:21
    vanmunch wrote: »
    You're right! I changed it to the serial object serial.str(string("V18", 13)) and it works just fine. Details? hu? they make a difference. :) Thanks again for your help.

    Dave

    Sometimes those details become invisible from looking at the code so long. Sometimes a second set of eyes helps.

    You're very welcome.
Sign In or Register to comment.