Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 20:31 07 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Did you know S.A.M.? (text to speech)

     Page 5 of 8    
Author Message
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1421
Posted: 11:51pm 18 Oct 2018
Copy link to clipboard 
Print this post

  Frank N. Furter said  
Is it a big effort to make PITCH, SPEED, MOUTH and THROAT adjustable?
Frank


I'd like to see that. Or should I say that I'd like to hear that?

  Frank N. Furter said  
For fun I compiled the project once for the MX150 - it seems to work!
Frank


Nice!
Micromites and Maximites! - Beginning Maximite
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 07:29am 19 Oct 2018
Copy link to clipboard 
Print this post

For all those who want to try it out:
2018-10-19_171944_SAM_TTS_TESTMX170.zip

You can flash this file for example with PicKit3 in a 28 pin MX170.
Tx_µC is on pin 11 and Rx_µC is on pin 12 (equivalent to our Micromite), but with 9600,8,N,1 with a normal terminal (no VT100).

The loudspeaker is connectet to pin 7 (better with a 10..100µF in series).

When you send something via the terminal, SAM speaks after a RETURN.

Frank
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8598
Posted: 07:31am 19 Oct 2018
Copy link to clipboard 
Print this post

  Quote  The sound is unfortunately very unsatisfactory!


Have you got an MMX or a Armmite H7 you can compare it to? It isn't great on any platform. Are you using a low pass filter on the output like the design in the MM+ manual?

I'm away from home so can't do any real testing for the next week or so.


  Quote  Is it a big effort to make PITCH, SPEED, MOUTH and THROAT adjustable?
Frank


Should be easy enough, just use a specific character to indicate that the next sequence is a command rather than text. e.g. $Mnnn, $Tnnn

  Quote  Peter, can you help me to implement a BUSY_PIN?


This is trivial, revised main.c code below:



/*******************************************************************************
* Includes and Defines
******************************************************************************/
#include "PIC32MX270_STD.h"
#include "delay.h"
#include "uart1.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "sam.h"
#include "reciter.h"
#include "tts.h"
#define BUSY LATBbits.LATB8 //Change to whatever pin you want

/*******************************************************************************
* Function Name: void initMain(void)
*
* Specification: initializes main
*
*******************************************************************************/
void initMain(void)
{
// unlock PPS
systemReg_Unlock();
CFGCONbits.IOLOCK = 0;
TRISBbits.TRISB8 = 0; // set PINB8 as output, Change to whatever pin you want
BUSY = 1; //set Busy while we get started

RPB3Rbits.RPB3R = 0x0005; //RB3->OC1
RPB4Rbits.RPB4R = 0x0001; //RB4->UART1 TX
U1RXR = 0b0010; //RA4->UART1 RX
// lock PPS
CFGCONbits.IOLOCK = 1;
systemReg_Lock();
}


int main()
{
char input[512];
int j;
uc_init();
initMain();

// initialize UART
UART1_Initialize();
delay_ms(300);

// initialize the TTS module
initTTS();

while(1)
{
// configure printf to use UART1
__XC_UART = 1;

// begin speaking
printf(">");
BUSY = 0; //ready to receive input
j=0;
// The next statement which should read the incoming serial input never returns
while((input[j++]=UART1_Read())!=13);
BUSY = 1; //Busy
input[j++]=10;
input[j]=0;
printf(input);
// speak text
speakText(input);

// end speaking
}
}
Edited by matherp 2018-10-20
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 07:54am 19 Oct 2018
Copy link to clipboard 
Print this post

Hi, Peter,

no, I have all parts for an MMX here, but annoyingly no system executable.

I didn't put a filter in between - the BBC:Microbit sounds very good even without it!

Thank you for your efforts
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 09:43am 19 Oct 2018
Copy link to clipboard 
Print this post

Okay, now I have a BUSY pin.

I put "BUSY = 1; //Busy" just before "speakText(input);" - Now I know exactly when SAM is still busy talking.

(Peter, you still have the wrong value for U1RXR in your code...)

SAM sounds very much better with this changes in Delay.h:
#define us_SCALE (GetSystemClock()/1500000) //2000000)
#define ms_SCALE (GetSystemClock()/1500) //2000)
Now SAM has about the same speech speed as the original online Version.

Peter, can you help me to read the variables for PITCH, SPEED, MOUTH and THROAT and transfer them to Sam.h? Unfortunately my skills are not enough!

Frank
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8598
Posted: 11:49am 19 Oct 2018
Copy link to clipboard 
Print this post

Here is a version that I think is much better, should run on any variant of MX150/170

2018-10-19_214652_23_TTS.X.production.zip

This has the following changes/features:

40MHz clock for better compatibility with MX150

Improved sound quality by synchronising PWM changes with the PWM output

Echos characters as you type them

Set speed, pitch, mouth and throat using the commands

$Pnnn
$Snnn
$Mnnn
$Tnnn


Read current values of speed, pitch, mouth and throat using the commands

?P
?S
?M
?T

  Quote  (Peter, you still have the wrong value for U1RXR in your code...)


No I haven't - 0b0010 = 2

Complete MPLabX project

2018-10-19_215022_23_TTS.X.zip

Edited by matherp 2018-10-20
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 12:11pm 19 Oct 2018
Copy link to clipboard 
Print this post

AMAZING!!! THAT'S IT!!! WE HAVE A TTS CHIP!!!


The sound is incredible! - no filter, only a active loudspeaker! I'm very impressed!

(I overlooked the "b" in your code...)

...setting and reading values doesn't work for me:

I send: $S100 for speed 100 ,get back "00" and SAM says zero, zero...
When I send ?S he says s...
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8598
Posted: 12:51pm 19 Oct 2018
Copy link to clipboard 
Print this post

  Quote  ...setting and reading values doesn't work for me:


You need CR after each command - no spaces, no LF

Here is a version that filters out invalid characters to make it a bit more robust. Invalid commands are just ignored.

Hex file:
2018-10-19_224759_23_TTS.X.production.zip

Pinout for 44-pin MM is:
console as per MM2
audio output - pin 24
busy output (active high) - pin 44



Full project:
2018-10-19_225256_23_TTS.X.zip Edited by matherp 2018-10-20
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 01:05pm 19 Oct 2018
Copy link to clipboard 
Print this post

SAM and question mark

This SAM code based on a code from ToughDev which based on the original reengineered code from Sebastian Macke (simulationcorner.net).
The original code understands question marks and raises the voice at the end of the sentence - the code of ToughDev has an error in ReciterTabs.h and therefore ignores the question mark.

I found this bug a few years ago when I was experimenting with the PIC24 code:

In line 210 in ReciterTabs.h "174" must be replaced with "191", then the tone boost works for a question mark! (that had cost a lot of effort at that time to find this error...)

Frank
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8598
Posted: 01:09pm 19 Oct 2018
Copy link to clipboard 
Print this post

V1.1 with added question mark

2018-10-19_230918_23_TTS.X.production.zip
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 01:28pm 19 Oct 2018
Copy link to clipboard 
Print this post

Hmmm, I can read the values with ?P or ?S, but when I try to write $P100, SAM always says zero, zero...

I don't know if Br@y++ sends an LF, but the reading is OK now...
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8598
Posted: 01:35pm 19 Oct 2018
Copy link to clipboard 
Print this post

What about if you try

$P78

What do you get? All my testing is with teraterm which works perfectly
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 01:41pm 19 Oct 2018
Copy link to clipboard 
Print this post

SAM says "eight"...
I don't know what's wrong...

Is it possible that Br@y++ sends to fast? I type the text in one line and press send. Where ist the "7"?Edited by Frank N. Furter 2018-10-20
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8598
Posted: 02:04pm 19 Oct 2018
Copy link to clipboard 
Print this post

  Quote  SAM says "eight"...
I don't know what's wrong...


Sounds like your terminal emulator is dropping characters or the internal clock on your MX170 is way off, I assume you get ?

"Speed 8"

Try this version and play with different values to see if it is always the 7th character that is dropped.

Is the speed changing as per the instruction?

2018-10-20_000259_23_TTS.X.production.zip Edited by matherp 2018-10-21
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 03:07pm 19 Oct 2018
Copy link to clipboard 
Print this post

No change! Unfortunately it is not possible to set different speeds with Br@y++. With Terraterm it also works with me.

I think the characters get lost while the "$" is being responded to. Probably it would be better to react to CR/LF and evaluate it afterwards...

I don't think the sign will get lost - if I transfer a sentence to speak it works too.

It is possible that there are problems if the conversion is to happen later over a µC...
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8598
Posted: 03:34pm 19 Oct 2018
Copy link to clipboard 
Print this post

Just tried it with realterm which does batch send and it works. Also works with MMEdit in ASCII terminal mode so I don't think the error is in the TTS code; get a decent terminal emulator . The processing time for $ is trivial compared to the millisecond it takes to send a character at 9600 baud so there is no point in changing the way it works.
Is your terminal set up for 8N1?

"Final" project source

2018-10-20_032928_23_TTS.X.zip Edited by matherp 2018-10-21
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1421
Posted: 08:29pm 19 Oct 2018
Copy link to clipboard 
Print this post

'170 works for me, '150 does not.
Micromites and Maximites! - Beginning Maximite
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1421
Posted: 12:06am 20 Oct 2018
Copy link to clipboard 
Print this post

There must be a limit to the input buffer size? If I send:

[code]
Bacon ipsum dolor amet picanha tail beef ribs capicola. Leberkas tail prosciutto flank pig frankfurter. Pastrami jerky beef ribs pig. Pastrami andouille sirloin ground round spare ribs ribeye buffalo beef. Andouille buffalo brisket flank.
[/code]

I get about as far as frankfurter.

Also: Fs and Ss don't sound good.

2018-10-20_101915_TTS.zip

But I love hearing that SAM again! Excellent work so far!Edited by CircuitGizmos 2018-10-21
Micromites and Maximites! - Beginning Maximite
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8598
Posted: 08:11am 20 Oct 2018
Copy link to clipboard 
Print this post

  Quote   '150 does not.


Please try this version, specifically compiled for MX150 but still works on MX470

2018-10-20_181116_23_TTS.X.production.zip
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 09:12am 20 Oct 2018
Copy link to clipboard 
Print this post

Hi Peter,

I think you are right with my terminal program - I tried HTerm and everything runs as desired! It seems that Br@ay++ uses the "$" for some internal settings and does not send...

Have you made any changes to the project?

Frank
 
     Page 5 of 8    
Print this page
© JAQ Software 2024