Jump to content
43oh

webbotlib speech synthesizer on launchpad


Recommended Posts

not sure this is considered a project. the package i am providing allows one to play w/ TTS on a launchpad w/ g2553 chip.

i did not create the TTS s/w, credit belongs to webbot at http://webbot.org.uk

instead of publishing derived code, i am publishing a perl script to convert his code for msp430 use.

this allows me to avoid licensing issues and i think anyone want to implement this should look at the original source.

 

the speech system is not high quality but fun to use in projects. i.e. talking clocks, alert / alarm modules, robot voices, etc.

 

 

. s/w only speech synthesizer technique from webbot

. one pin pwm.

. text-to-speech and synthesizer code under 10k.

. fits in a g2553 mcu.

 

source

 

https://github.com/simpleavr/webbot_talk430

. hosted in github, search for "webbot_talk430" project

. there are 4 files.

. zconv.pl converts the webbotlib speech source codes to a msp430 compatible source.

. talk.c TTS exercising firmware, talks to PC at 9600bps turns what u type into speech.

. uart.h uart code

. common.h some macros i used.

. pwm hardware hook-up is in talk.c, just one resistor and one capacitor, can be improved by using better filters.

 

 

instructions (as in README and help from conversion script)

 

this is a perl script to convert the webbotlib speech sythesizer code from avr

to msp430 usage. this script is use at your own risk giftware. webbotlib has

it's own license terms.

 

. locate "webbotlib" and download version 1.x, i tried w/ webbotavrclib-1.35

. inside the package locate and extract the Audio/Text2Speech directory

. u will see the following files

 

Text2Speech.h

phoneme2sound.c

phonemeWriter.c

sound2noise.c

speech2phoneme.c

speechWriter.c

vocab_en.c

 

. place these files in a same directory as this (zconv.pl) script

. run it again and this script will

. extract what's needed, ignore others

. combine into a tighter package name "../webbot_speech.h"

. replace avr controls w/ msp430 controls

. to use it in your firmware, do

. include "webbot_speech.h"

. say("Hello World");

. enjoy :) and thanks webbot

 

<<< IMPORTANT >>>

please observe the fact that webbotlib is GPL licensed and use / share accordingly

 

 

 

will be glad to answer questions anyone may have in this thread. happy hacking.

Link to post
Share on other sites
  • 7 months later...

I ran the conversion script and tried compiling with Energia. There were a couple of items that needed to be defined

#define TRUE 1
#define FALSE 0

I had to move

uint8_t _speech_timeFactor;

to the top of the header file, and changed the pause function (due to compiler errors)

static void pause(uint8_t delay){
 uint8_t r;
 for(r=_speech_timeFactor; r>0; r--){
         //__delay_cycles(delay);
         delay(sleep);
 }
}

though I'm not sure what issues this will introduce...

 

I was able to get webbotlib to compile for the g2553, but all I have is a g2452 and the code is 78 bytes too big...

Is there anything that can be removed/reworked to reduce the size?

 

c:/energi~1/hardware/tools/msp430/bin/../lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld.exe: Webbotlib.cpp.elf section `.bss' will not fit in region `ram'
c:/energi~1/hardware/tools/msp430/bin/../lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld.exe: region `ram' overflowed by 78 bytes
collect2: ld returned 1 exit status

Link to post
Share on other sites

apologies for late reply, i got notified of the newer message only yesterday. looks like the forum notify feature has some delay

[edit]oops, forum notify is fine, i got notified immediately, my eyes are not, i mis-read and thought the last message was from August.[/edit]

 

1. the "#define TRUE .. FALSE" is needed and u can added them correctly.

2. the __delay_cycle(...)

i tried w/ newer versions of mspgcc and it now provides __delay_cycles(..) and collide w/ mine. u should

a) change __delay_cycles(..) to __my_delay_cycles(..), do it on all source files (common.h, webbot_speech.h, etc)

B) your change will not work as it will call the delay() function that calls pause(), they will go into circles.

3. ram issue

. you will not get by w/ a 2452 or anything w/ 256 bytes and less ram

. u may try, but i used obj-dump and looked at the listings

. the sound lib uses a 128 byte "char sounds[]" to dynamically construct the phonemes, u can't do w/o

. there is little room to optimize memory, i already "static const" all tables that can be done.

. u need stack and other variables, they will eat up 256 bytes easily. i.e. u need 2553 w/ 512 bytes ram

 

 

. I will find time to align the code for more recent mspgcc versions and will update github code. u will need a 2553 or something w/ 512 bytes ram. good luck w/ your project.

Link to post
Share on other sites
  • 1 month later...

@mbeals

 

i build this w/ mspgcc under both ubuntu 11 and windows/cygwin.

i had just re-worked the package and tried build it in CCS, which compiled well but i had no way to verify it as i had setup issues and it did not download.

u still need cygwin perl or some other perl to generate webbot_speech.h

for CCS build u need to create a new project (w/ g2553 target), and copy talk.c, common.h, uart.h, webbot_speech.h to that folder.

 

search simpleavr or webbot_talk430 on github

 

the re-worked github package w/ the following highlighted changes

 

. webbot_lib.h now reside in same directory

. now uses webbotlib package 2.x versions

. now compiles under CCS

. adopt to new mspgcc

. mspgcc-20120406-p20120502

. use of #include

. retire own intrinsic __delay_cycle(), now uses mspgcc's

. adopt to newer interrupt naming convention

 

i don't have the audio setup right now but the new cygwin build got loaded and i can connect via uart. just no sound as i don't have a speaker right now.

 

let me know if u have any issues.

 

good luck and happy building.

Link to post
Share on other sites

Thanks a lot for your help. I did manage to get it to compile and sort of run. I know the code is working because the blink_led function is working as it should, but I'm not getting sound. I set the PWM to output on pin 1.5 by editing the block of code in talk.c from:

 

P1SEL = 0;
P1DIR = 0;
P1OUT = 0;

 

to

 

P1SEL |= BIT5;
P1DIR |= BIT5;
P1OUT |= BIT5;

 

Which produces a single tone on every key press in the terminal window and a squelch when I hit enter but nothing close to audio. Did I set the output pin correctly?

Link to post
Share on other sites

the pwm output is done inside webbot_speech.h -> soundOn(), where P2.6 is used.

there should be no need for u to setup things up inside talk.c

 

1. did u use CCS to build or did u use mspgcc?

2. when u talk (via putty maybe) to the launchpad, after entering what u want to say and hit enter, does it take a few seconds (depending on length of sentence to say) before the "done" shows up?

 

i can only hookup sound tomorrow to validate the code change. and i recall the tricky part is getting the timing right.

i had to change pause() and __delay_cycle() to adopt to CCS and new version of mspgcc. this may have impact on timing.

u may want to look at pause() and try and play around w/ the duration / delay, etc.

the __delay_cycle() are now supplied by CCS and mspgcc library so i am not sure how they behave now.

 

i will try to validate the changes tomorrow. if there are issues it can only be the timing issues i mentioned.

also u can revisit my youtube video and compare w/ your experience.

Link to post
Share on other sites
but there is no pin 2.6, at least on this rev of the board.

 

:problem: are u sure? even g2231 has 2.6. it's the same pin as X.in (crystal)

 

u should be using a g2553. inside talk.c we set P2SEL=0 to indicate we want to use 2.6, 2.7 as io.

 

did u have xtal soldered? i am not sure if it failed because of this. if this is the case, u should alter the code and use another timer out pin from the soundOn() and soundOff() functions in webbot_lib.h. do a look up on the datasheet for the correct alternate pin to use.

 

i am dual using timer0 for both uart and pwm out, that's why the setup is done in soundOn() and soundOff(). could have used timer1 though.

Link to post
Share on other sites

ok, i tried the new code and everything works. it is talking faster though. we can adjust the loop inside pause() to make it slower.

 

hooking up a direct 8ohm smallish speaker i could barely make out what it says but should work ok if u spend time to construction a rc filter, and or fiddle w/ the timer / timing a bit.

 

i also tried my CCS build (eventually used mspdebug to download the .out file) and it also works likewise.

 

in case we had crystal installed and can't use p2.6....

i checked and find out that i had used p2.6 for TA0.1 (timerA out1) as p1.2 is already used for uart.

we can changed the code so that we use the 2nd timerA and have our pwm out at p2.1 or p2.2.

i tried p2.2 and it works well, basically we need to change inside webbot_lib.h

 

CCR0 -> TA1CCR0

CCR1 -> TA1CCR1

CCTL0 -> TA1CCTL0

CCTL1 -> TA1CCTL1

TAR -> TA1R

TACTL -> TA1CTL

BIT6 -> BIT2 (both in P2SEL and P2DIR, setups)

 

i tested the above on mspgcc.

 

ie.

void sound(uint8_t  {
   b = (b & 15);

   // Update PWM volume
   int16_t duty = Volume[b];     // get duty cycle
   if (duty != TA1CCR1) {
       TA1R = 0;
       TA1CCR1 = duty;
   }//if

}

 

and

 

void soundOff(void) {
   TA1CCTL0 &= ~CCIE;
   P2DIR &= ~BIT2;
}

void soundOn(void) {
   TA1CCTL0 &= ~CCIE;
   TA1CCTL1 = OUTMOD_7;
   TA1CCR0 = 0x200;                            // more like 16Khz (16Mhz/1024)
   TA1CCR1 = 0x00;
   TA1CTL = TASSEL_2 + MC_1;

   P2SEL |= BIT2;
   P2DIR |= BIT2;

   // initialise random number seed
   seed[0]=0xecu;
   seed[1]=7;
   seed[2]=0xcfu;
}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...