Projects‎ > ‎

SAM SPEAKER NETWORK

This is another project, autonomous but can be used in combination with Annex to implement voice messages.

Sam is a very small Text-To-Speech (TTS) program converted to C from the original Commodore C64 by Sebastian Macke and published in source code on github.
It was originally published in the year 1982 by Don't Ask Software (now SoftVoice, Inc.). 
It includes a Text-To-Phoneme converter called reciter and a Phoneme-To-Speech routine for the final output.
It is so small that it was really easy to implement in the ESP8266, in particular on ESP-01 modules with only 512KB of flash memory.

This implementation use a poor documented feature of the ESP8266, the sigma-delta generator acting like an 8 bits DAC, which makes it possible to overcome the lack of an H/W PWM.

It uses the serial port to communicate with SAM and a simple speaker (or earphones) connected on the SOUND_OUT pin (GPIO2 by default).

The module communicate at 115200 baud No parity 8 bits and uses the a pin (GPIO0 by default) as handshake signal indicating when the module is ready (HIGH) or is busy (LOW).

Both pins can be redefined using the commands @pin_out=pin and @pin_rdy=pin.
These pins will be stored in the module and taken into account at next reboot.

In addition, the SAM can be also controlled using the network, using HTTP GET requests as detailed lower in this page

This page shows how it speaks using an online version of SAM.


At the startup, the module send a welcome message "This is SAM Speaker. Hello World!" to confirm that is running.
At the same time, the module send a complete help of all the commands available, as can see in the image on the right.

It is then possible to send any sentence in English via the serial port to make it talk.

There are several commands available starting with @, like for example @volume= that permit to control the volume.

The module can be also used in phoneme mode to have a better control of the speech.

To install, simply flash the bin file using the tab "Backup / Restore " of the Annex Toolkit


To test it, the Serial Monitor can be used typing directly the sentences terminating with return.
It will be required to remove the local echo unchecking the related checkbox



For more information, in particular on the phonemes, this is the link of the original documentation

NETWORK ADDITIONAL INFORMATION

In addition to the serial port, the module can be also controlled using the network, using HTTP get requests.
This can be done from Annex using the function WGET$.

To use it for the network, SAM network must be configured before.
This can be done typing, via the serial port, the following commands :

@net_ssid=YOUR_WIFI_SSID
@net_pass=YOUR_WIFI_PASSWORD

These parameters will be stored in the module and taken into account at next reboot.

The IP will be automatically assigned by your WIFI router and will be shown at the top of the page.

Optionally it is possible to set manually the IP with the following commands :
@net_ip=DESIRED_IP
@net_mask=YOUR_NETWORK_MAKS
@net_gate=YOUR_GATEWAY_IP

As an example if your network is :
Name : VODAPHONE_123
Pass : KARTOFFEL
Router IP : 192.168.1.1

And you want set SAM with the IP 192.168.1.222 , the commands to type are :

@net_ssid=VODAFONE_123
@net_pass=KARTOFFEL
@net_ip=192.168.1.222
@net_mask=255.255.255.0
@net_gate=192.168.1.1

These parameters will be automatically stored in the module and taken into account at next reboot.
This can be forced using the command @reboot=1

At next reboot, the module will report "speaking" the assigned IP address.

To test SAM network, you can simply use your internet browser and type the IP of the module


A simple help message will be shown.

You can then type any message using the syntax as below :


This little program shown how is easy to control it using Annex :

CODE: SAM_net2.bas

' demo program for SAM speaker Network
' by cicciocb 2019
SAM_ip$ = "192.168.1.222"
speak "my name is SAM speaker network."
speak "I can be controlled using Network commands"
speak "From Annex or any other controller."
speak "Obiously I can be also controlled"
speak "Using the serial port."
speak "You can also use special symbols such as * $ % & # + @ /"
end

sub speak(msg$)
local ret$
url_encode msg$, ret$
print wget$(SAM_ip$ + "/?"+ ret$, 80) ' makes an http://SAM_IP/?message
end sub

' encode the in url format (%xx...) where xx is the hex code of the char
sub url_encode(msg$, ret$)
local i
ret$ = ""
for i=1 to len(msg$)
  ret$ = ret$ + "%" + hex$(asc(mid$(msg$, i, 1))) 
next i
end sub


This program contains a little routine (url_encode) that converts all the characters to url format; this prevents certain characters (such as '=', for example) from being misinterpreted.





License:

As Sebastian Macke states here this software cannot be considered open source but more like "Abandonware". 

Download:

The download is available here
Comentarios