help me I need text to speech on android

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
sunkim
Posts: 23
Joined: Tue May 05, 2015 8:30 pm

help me I need text to speech on android

Post by sunkim » Mon May 11, 2015 7:39 pm

I made a app for education of language,
and the app need text to speech
who can show me the way ?
help me please

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: help me I need text to speech on android

Post by Mark » Tue May 12, 2015 3:16 pm

The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

paul_gr
Posts: 319
Joined: Fri Dec 08, 2006 7:38 pm

Re: help me I need text to speech on android

Post by paul_gr » Tue May 12, 2015 9:06 pm

As Mark says you need an external. Unfortunately, there is no Android Externals SDK from Runrev, so how to make Android externals will be complex and undocumented.
I don't know of anyone making Android externals that will give you text to speech on Android.
IMO -- if you really must have text to speech in Android, I would stop using LC and go native, or use one of the other programming environments that will do what you want.

Paul

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: help me I need text to speech on android

Post by Simon » Tue May 12, 2015 10:19 pm

Hi sunkim,
I've used Googles text to speech
http://translate.google.com/translate_t ... to%20speak
i think it's limited to 10 seconds for each sentence. Oh and it's not officially supported.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

sunkim
Posts: 23
Joined: Tue May 05, 2015 8:30 pm

Re: help me I need text to speech on android

Post by sunkim » Wed May 13, 2015 5:38 pm

paul_gr wrote:As Mark says you need an external. Unfortunately, there is no Android Externals SDK from Runrev, so how to make Android externals will be complex and undocumented.
I don't know of anyone making Android externals that will give you text to speech on Android.
IMO -- if you really must have text to speech in Android, I would stop using LC and go native, or use one of the other programming environments that will do what you want.

Paul
thank you for your advice
very much.

sunkim
Posts: 23
Joined: Tue May 05, 2015 8:30 pm

Re: help me I need text to speech on android

Post by sunkim » Wed May 13, 2015 6:03 pm

hi simon
thank you for reply,
it is good news to me

thank you very much

sunkim
Posts: 23
Joined: Tue May 05, 2015 8:30 pm

Re: help me I need text to speech on android

Post by sunkim » Wed May 13, 2015 8:17 pm

below this is an example of google TTS API for android of java,
can I use this in livecode?


package com.nxhoaf;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

public class SimpleTextToSpeech {
private static final String TEXT_TO_SPEECH_SERVICE =
"http://translate.google.com/translate_tts";
private static final String USER_AGENT =
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) " +
"Gecko/20100101 Firefox/11.0";

public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.out.println("Usage: SimpleTextToSpeech " +
"where: ");
System.out.println();
System.out.println("- Language: all languages accepted by " +
"google translate, in this example, we'll use fr, en");
System.out.println("- Text : If text is more than one word, " +
"then is must be put inside double quote, for example:");
System.out.println("\tjava SimpleTextToSpeech en Hello");
System.out.println("\tjava SimpleTextToSpeech en \"Hello World\"");
System.exit(1);
}
Language language = Language.valueOf(args[0].toUpperCase());
String text = args[1];
text = URLEncoder.encode(text, "utf-8");
new SimpleTextToSpeech().go(language, text);
}

public void go(Language language, String text) throws Exception {
// Create url based on input params
String strUrl = TEXT_TO_SPEECH_SERVICE + "?" +
"tl=" + language + "&q=" + text;
URL url = new URL(strUrl);

// Etablish connection
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Get method
connection.setRequestMethod("GET");
// Set User-Agent to "mimic" the behavior of a web browser. In this
// example, I used my browser's info
connection.addRequestProperty("User-Agent", USER_AGENT);
connection.connect();

// Get content
BufferedInputStream bufIn =
new BufferedInputStream(connection.getInputStream());
byte[] buffer = new byte[1024];
int n;
ByteArrayOutputStream bufOut = new ByteArrayOutputStream();
while ((n = bufIn.read(buffer)) > 0) {
bufOut.write(buffer, 0, n);
}

// Done, save data
File output = new File("output.mp3");
BufferedOutputStream out =
new BufferedOutputStream(new FileOutputStream(output));
out.write(bufOut.toByteArray());
out.flush();
out.close();
System.out.println("Done");
}

public enum Language {
FR("french"),
EN("english");

private final String language;
private Language(String language) {
this.language = language;
}

public String getFullName() {
return language;
}
}
}
--[from]- http://www.androidside.com/B56/23972

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: help me I need text to speech on android

Post by Simon » Wed May 13, 2015 8:57 pm

Hi sunkim,
Nope, you just use a url like I posted.
It doesn't show well in the post but click it and look at your address bar.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: help me I need text to speech on android

Post by Simon » Wed May 13, 2015 9:16 pm

Here is the url
All you need to do is change what is said after "q="
I'd try it in a different browser to see if you can get it to work. Works here.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

sunkim
Posts: 23
Joined: Tue May 05, 2015 8:30 pm

Re: help me I need text to speech on android

Post by sunkim » Thu May 14, 2015 12:38 pm

hi simon
thank you
I connected the url of you
and I knew TTS of google
and I think there is a way to use TTS of google in livecode that I don't know.
but I'm a beginner,
and can little speak english

Post Reply