Using A Browser for TTS?

Peter Reid preid at reidit.co.uk
Sun Jan 6 05:25:07 EST 2019


A while ago I asked whether there was any way to do Text-To-Speech (TTS) for Android. Unfortunately there were no replies.  Since then I came across a browser JavaScript API that seems to provide speech synthesis:

Here's a sample HTML that plays through my default browser on my Mac:

---------
<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>TTS Generator</title>
</head>
<body>
<script type='text/javascript'>
	var u = new SpeechSynthesisUtterance();
	u.text = '[PHRASE]';
	u.lang = 'en-GB';
	u.rate = [RATE];
	u.name = "[VOICE]";
	speechSynthesis.speak(u);
</script>
<h2>
Generating speech for:
<i>Hello, how are you?</i>
</h2>
</body>
</html>
---------

The method is as follows:

1. Create an HTML file with the above content, replacing the [...] elements with specific text.

2. Use 'launch' to open the HTML file in the Android tablet's default browser (Firefox works well) that synthesises and plays the phrase:

	launch url [path to HTML file]

3. Wait for speech to finish (I calculate an approx. duration based on the number of characters spoken)

4. Bring my app to the front or quit browser - DON'T KNOW HOW TO DO THIS!

Note that I tried using a browser widget to play the HTML/phrase but it is silent on the Android tablet (it speaks OK on the Mac).

My questions are:

Q1. Is there a simpler way of getting TTS for Android?

Q2. How can I make my app the front app and/or how can I quit another app?

Q3. How can I get the list of voices available on an Android tablet?

Q4. When will LiveCode fully support TTS and STT across Mac, Win, iOS and Android?!

Thanks

Peter
--
Peter Reid
Loughborough, UK





More information about the use-livecode mailing list