BlocklyProp icon indicating copy to clipboard operation
BlocklyProp copied to clipboard

Block updates for text2speech on Activity Board

Open AndyLindsay opened this issue 7 years ago • 6 comments

There's a forum discussion about no sound from Activity Board on VEHO speaker even though earbuds work fine.

A speaker that mixes the signals or shorts two leads together for stereo to mono will cause reflected signals to cancel each other out. To keep both earbuds and VEHO options, I would recommend defaulting the text2speech initialize block to 27, 27 with the ability to change it to any pair of pins or single I/O pin. If you prefer to set up the block so that it has mono and stereo options, consider using the the terms mono and reflected instead.

I removed some caveats from the talk_run function so that -1, 27, 27, 27, and 27, -1 all produce the same result. A second pin is only added and configured when you do something like 26, 27.

One last update, there is now a talk_setVolume feature that goes from 0 to 7.

// ------ Libraries and Definitions ------
#include "simpletools.h"
#include "text2speech.h"

// ------ Global Variables and Objects ------
talk * spkr; // Talk process ID/data pointer

// ------ Main Program ------
int main() 
{

  // Speaker behavior will vary depending on speaker type and connections
  // On Activity Board
  //spkr = talk_run(26,27);                    // Left and -right
  //spkr = talk_run(26,26);                    // Left only
  spkr = talk_run(27, 27); // Right only
  //spkr = talk_run(-1,27);                    // Right only
  //spkr = talk_run(26,-1);                    // Left only
  //spkr = talk_run(27,-1);                    // Right only
  //spkr = talk_run(-1,26);                    // left only

  // Try volume values from 0...7
  talk_setVolume(spkr, 6);

  talk_say(spkr, "heloa"); // Say hello
  pause(1000);
  talk_say(spkr, "goodbae"); // Say goodbye
}

AndyLindsay avatar Sep 24 '18 18:09 AndyLindsay

P.S. It is quiet but audible on a piezospeaker, so it would probably be worth supporting options P0..17, P26, and P27. The large resistors on servo headers won't necessarily work with piezospeakers, but could still send the signal to another board.

AndyLindsay avatar Sep 24 '18 18:09 AndyLindsay

@AndyLindsay @Steph-Parallax I did not set the default to 27,27 - there is a bit of a complication there. Each board type has a "profile.default.earphone_jack" property that allows me to not have to create a bunch of conditional code that looks at what board type you are using - and it's shared by the wav player, which does not invert the signal L/R. That being said, with a little more time, I could create a dual (inverting/non-inverting) earphone jack profile that would get around this issue...Something to ponder, decide, and then document accordingly. We would then need to decide the best pin selection options for TTS, WAV, and libsound for each possible board type (PABWX, HEB, & Badge WX)

MatzElectronics avatar Oct 01 '18 02:10 MatzElectronics

@AndyLindsay @Steph-Parallax Update - I created an "_inverted" profile, so this should now work as requested.

MatzElectronics avatar Oct 05 '18 04:10 MatzElectronics

Need to verify by:

  • playing the same WAV file with earbuds on both the Badge WX (with no other code) and on the Activity Board WX.
  • Using the Audio >TTS Say and TTS Spell blocks with earbuds on both Badge WX and Activity Board WX.

Steph-Parallax avatar Oct 11 '18 23:10 Steph-Parallax

@Steph-Parallax - TTS Say and TTS Spell blocks work with earbuds on both Badge WX and ActivityBoard WX on Demo Site. This tests correctly

I could not get the WAV file play to work on either Board with speaker or earbuds. Both failed. I tried the block alone, with other blocks, etc. None worked - I verified a good card and WAV file using the code below on the Live Blockly Site.

I used the WAV file play Block successfully and the ActivityBot 360 (ActivityBoard WX) with the Veho Speaker using code 51940 on the Live Site.

wstodghill avatar Oct 12 '18 22:10 wstodghill

I'm having 51940 fail for me, it plays only one of the three WAV files I'm using. But when I remove the robot blocks it works on both Demo and the live site (with longer pauses.) Suspect our code, will investigate.

Steph-Parallax avatar Oct 12 '18 23:10 Steph-Parallax