Page 1 of 1

help me I need text to speech on android

Posted: Mon May 11, 2015 7:39 pm
by sunkim
I made a app for education of language,
and the app need text to speech
who can show me the way ?
help me please

Re: help me I need text to speech on android

Posted: Tue May 12, 2015 3:16 pm
by Mark

Re: help me I need text to speech on android

Posted: Tue May 12, 2015 9:06 pm
by paul_gr
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

Re: help me I need text to speech on android

Posted: Tue May 12, 2015 10:19 pm
by Simon
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

Re: help me I need text to speech on android

Posted: Wed May 13, 2015 5:38 pm
by sunkim
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.

Re: help me I need text to speech on android

Posted: Wed May 13, 2015 6:03 pm
by sunkim
hi simon
thank you for reply,
it is good news to me

thank you very much

Re: help me I need text to speech on android

Posted: Wed May 13, 2015 8:17 pm
by sunkim
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

Re: help me I need text to speech on android

Posted: Wed May 13, 2015 8:57 pm
by Simon
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

Re: help me I need text to speech on android

Posted: Wed May 13, 2015 9:16 pm
by Simon
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

Re: help me I need text to speech on android

Posted: Thu May 14, 2015 12:38 pm
by sunkim
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