Speech output for bangle.js?

Posted on
  • Hi,

    Is it possible to do speech output on the bangle.js watch? How loud is the speaker?

    I'm interested in developing an assistive device for a blind runner. It would basically be a glorified talking clock, with the ability to speak the time, with stopwatch functions, maybe also heart rate and distance travelled. So I don't need generalised text-to-speech, just a limited vocabulary of numbers and a few extra phrases.

    It looks like the speaker is wired to a digital pin, so I could presumably read some pre-recorded data from a file, and then write it out using Waveform API. Is this the best approach? Is it possible to mix javascript code on the bangle.js with standard Arduino libaries or C code? A quick search reveals the Talkie arduino speech library (https://github.com/going-digital/Talkie). Would this be usable on the bangle.js platform?

    I have tried to implement something like this before using an Android smart watch. While these devices are very capable, the UI is quite inflexible and is usually hopelessly dependent on the touchscreen display. From this standpoint, having a bunch of chunky buttons on the bangle.js is a huge plus, and it should be possible to develop a simple UI that does not require sight.

    Cheers,
    Stewart

  • Yes, it should be very possible to do. As you say, with the Waveform API you should be able to write a file into the Bangle's storage and then play it back reasonably easily. I could help with some code examples for this.

    However the speaker really isn't very loud at all - there's a thread on this but most Bangles don't have one in and use the vibration motor (which could still play back waveforms). There's not actually much difference in volume between the two options though.

    It'd be good enough that if the runner held it to their ear they could hear (you may even be able to detect this motion and start the playback), or potentially you could open it up and try and add a better speaker to it.

    In terms of mixing C and JS, you can compile in code to the firmware, but it's not that easy and there won't be the same Arduino APIs you might expect. For short functions you could use Inline C though: http://www.espruino.com/InlineC

    Sounds like a great idea though - especially as with GPS it might even be able to provide some kind of basic navigation?

  • OK, thanks for the information. I had a look at the disassembly video, and a few ideas come to mind. Part of the reason the speaker is not loud may be that it is not well coupled to the case of the watch. In its normal position, the heart rate sensor and a layer of plastic film is between the speaker and the case. One solution might be to stick the speaker directly to the back of the case. It would have to avoid the existing sensor window and connector pins. Piezos come as small as 12mm, so a couple of these might fit, or alternatively could be cut down to size. Adding an air hole might also increase the loudness, at the expense of some water resistance. Another solution might be to stick the speaker inside the front of the watch. A blind user can't see the LCD anyway so there is no great loss in sacrificing all or part of the front display area.

    I will go ahead and order a couple of watches to experiment with. Is it possible to buy extra cases? This could be useful in case I break something while tinkering.

  • Thanks! Yes, the small piezo glued to the rear is something I have been wondering about as well - I haven't got around to trying it yet though. It may even be possible to cut one down.

    If you're happy to mess around there are all kinds of options - even using a smaller battery and inserting a proper speaker in the remaining space.

    Right now I'm not selling extra cases but I have been trying to get some spares so if that goes well I will. If you do hit issues I can probably find one kicking around here though.

    Hope it goes well - it sounds like an amazing use for Bangle.js!

  • Just gave this a very quick try... Downloaded some WAV files of someone saying numbers - and converted them to 4kHz unsigned 8 bit raw files with sox 0.wav -r 4k -b 8 -c 1 -e unsigned-integer 0.raw vol 2 (on linux - but you could just use Audacity) and uploaded them using the Web IDE's storage menu.

    Then ran this:

    function play(txt, callback) {  
      function playChar(txt) {
        if (txt.length==0) {
          digitalWrite(D18,0);
          if (callback) callback();
          return;
        }
        var c = txt[0];
        var s = require("Storage").read(c+".raw");
        var w = new Waveform(s.length);
        w.buffer.set(s); 
        w.startOutput(D18, 4000);
        w.on("finish", function(buf) {
          playChar(txt.substr(1));
        });
      }
      analogWrite(D18, 0.5, {freq:40000});
      playChar(txt);
    }
    
    play("012"); // says 'zero' 'one' 'two'
    

    Definitely works ok, although not loud.

    Without a speaker it's more of a pain since you have to scale the output values so they're not high enough to move the vibration motor:

    function play(txt, callback) {  
      function playChar(txt) {
        if (txt.length==0) {
          digitalWrite(D18,0);
          if (callback) callback();
          return;
        }
        var c = txt[0];
        var s = require("Storage").read(c+".raw");
        var w = new Waveform(s.length);
        var b = w.buffer;
        b.set(s);
        for (var i=s.length-1;i>=0;i--)b[i]/=4;
        w.startOutput(VIBRATE, 4000);
        w.on("finish", function(buf) {
          playChar(txt.substr(1));
        });
      }
      analogWrite(VIBRATE, 0.1, {freq:40000});
      playChar(txt);
    }
    

    But that could actually be done before the files are even written to flash

  • Great, thanks! This is very helpful. :-)

    I wasn't sure if I would have to implement my own PWM, but this looks easy.

    I'm fairly confident that a piezo stuck to the back will be better. This is how talking watches are constructed, and they can be very loud. It might not be optimal because of the need to use a smaller piezo, positioned away from the center of the plate. Looking forward to trying it out when my devices arrive.

  • Great! Actually looking at it if you didn't care about the heart rate monitor you could probably push out the little 'window' in the rear case and stick a nice big Piezo over it. I bet that'd be great.

  • Yes, but I think heart rate measurement will be very useful in this application. Unless of course its wildly inaccurate, in which case I could afford to lose the window. Another option is a big piezo with a small hole in the middle. Not sure how well that would work.

  • Well first I thought this is a joke, drilling a hole into a piezzo and than I found this video https://youtu.be/59AWAWpSCk8

    I definitely have to try this. Thanks for sharing this idea!

  • @Gordon, neat... a new thing... with a piece getting a better connection to the case / back cover of the watch, it may actually 'sound'. I think the main issue is that that the piezo sitz between the battery and foamy tape tuck to the flex pcboard with the heart monitor sensor. If the piezo can have its center on the glass of the back of the bck cover and its rim resting on the insert, then that could produce better audible sound.

  • Yes, if you're careful not to crack the ceramic or distort the disk you can drill piezos without any problems. It would be easier with a drill press than using a handheld drill as shown. The aim should be to maximise the area of the ceramic. I suspect that a large disk with a hole will yield more ceramic, and thus more piezo electric force than two or more small disks. Looking at the disassembley video, there is also an area that would have to be cut away from the disk for the charging pins to pass through.

  • Hello @stewartg Does your blind runner know Morse code?

  • Tue 2020.09.22

    re: 'Morse code?'

    Now there's someone with their thinking cap on!!

    Simpler interface, less memory avoiding wav files and stealthy too! Most competitors wouldn't have a clue as to what 'data' is being conveyed.



    @user101245       
    --.   .-.   .   .-   -      ..   -..   .   .-  !

    for the impaired

  • That sounds like a great idea.

    I've just added a very simple clock app: https://banglejs.com/apps/#vibrclock

    Press BTN1 and it'll buzz out the current time. While potentially you could do morse code, I've just done it as a series of digits so you don't have anything to learn - just could the amount of buzzes.

    Right now there's no way for a widget to know if it's running under a clock app or not, but when that ability gets added this sort of thing could be a widget, so you can then run it with any clock face you want.

  • @Robin

    .-- .... -.-- / - .... .- -. -.- / -.-- --- ..- !

  • @Gene, Morse code messages sound like an interesting idea.
    I was actually thinking of using Morse code as a means to input text on the device, given the limited set of buttons that it has. However, I can't imagine myself decoding Morse code that easily, let alone inputting text with it. It's probably worth a try, regardless.
    Edit: Excuse me if this is a dumb question in regards to capability but, is it possible to play sounds from the watch using a Bluetooth audio device?

  • It's definitely worth trying the vibration clock app I added above - while not morse code it feels pretty usable.

    is it possible to play sounds from the watch using a Bluetooth audio device?

    I'm afraid not, no... Pretty much all the Bluetooth Audio devices use normal Bluetooth, not 'Bluetooth low energy'.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Speech output for bangle.js?

Posted by Avatar for stewartg @stewartg

Actions