In certain (quantifiable by my program) circumstances I want the tts engine to speak a string of letters as their own names rather than what they spell.
For example, in the square with corners named A, B, C, & D, I want it to speak the name of the line AB as "ay bee". At the moment it says "ab".
Can I do this? And, obviously, if so, how?
As suggested You can add spaces between alphabets and feed the it to TTS.
String a_z="A B C ...";
or if it is coming from some input source then do
input = "ABCDE".replaceAll("([A-Z])"," $1").trim()
where ([A-Z]) mean capture any capital alphabet which is represented by $1
and you can use setSpeechRate to stretch the speed to make it sounds as required.
Related
My app needs to display numeric ranges in a TextView, such as "34-93". TalkBack is reading this as "thirty-four minus ninety-three". I want it to either read "thirty-four dash ninety-three" or "thirty-four to ninety-three" I've tried inserting spaces before and after the dash, as well as using both a hyphen and en-dash, to no avail. In general, though, I have little control over how this string is formatted.
It seems like it should read "dash" if there were some attribute to cause it to read punctuation literally, like accessibilitySpeechPunctuation in iOS.
Is there a way to limit a text field so that it only accept certain letters from an array?
Let's say I have an array:
val array = arrayOf("a", "b", "c")
I want the list to be manipulated inside code, so that the letters you can type in the text field is changed by code. How do I implement this via a class to make it accept only the letters a, b, or c?
Yes you can do this. In XML of edit text you need to use below code
android:digits="abc123"
Here abc123 are your required digits you want your edit text should accept. You can also limit to abc as your desire. So use below code
android:digits="abc"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Pass whatever alphabets you want
I am setting the content description for a TextView using setContentDescription method.
The string passed to this method is a concatenation of two sentences separated by a period "."
When TalkBack ot TTS (Text-To-Speech) read this, it does not mark a pause between the two sentences.
My question is, is there a some way to handle this, a special UTF character for example ?
Try a newline charachter.
To read this barcode: "3S REGR 2345", I found that "3 S\nR E G R\n2 3 4 5" got me the result I was after on Samsung TTS.
It will be read as "Three S. R E G R. Two Three Four Five"
Uncertain if there is any special character available, but another solution might be to split the speech and add
textToSpeech.playSilence(750, TextToSpeech.QUEUE_ADD, null);
then continue with the rest of the split
I'm doing a Android project and facing a problem with EditText when I type Vietnamese.
Example, when i type the word "thử" into EditText and get string from it.
String text = edittext.getText().toString()
It always returns a String object with 4 characters "t", "h", "ư" and the accent character.
But if i create a String object by code like:String text = "thử";. It only contains 3 characters "t", "h" and "ử". So they do not match when I compare them. I want the String object contain 3 characters, not 4 characters.
I also think about a way that loop through all characters to replace them manually. But Vietnamese has 12 vowels and 6 accents so that it makes me have to check 72 cases. I don't think it is a good way. Anyway to get proper text from EditText? Or any good way to replace the text manually?UPDATE:I have found why the EditText always return weird String. It is cause by the phone keyboard app. I am using LG Magna and using default keyboard app. The app always encodes seperately base vowels and accents everything i input. I have just installed another keyboard app, then it works like a charm.Now, I have to find a way to make sure that the text always returns properly from any keyboard app.
Android use UTF-8 codepage, so please be sure that you're typing your vietnamese symbols using those UTF-8 but not any kind of Windows-1258`
I have the following idea:
In German we have four extra letters (ä, ö, ü, ß) and I don't know any other language which has these vocals but I think French people with their accents also know this problem. We have a lot of apps in the Google Play store for cities, bus stations, trains and other stuff like that. Now it is really exhausting that we always have to write these letters if we are on the go. It would be much easier to write Munchen (=München [de] = Munich [en]), Osterreich (Österreich [de] = Austria [en]) or something like Uberwasserstrasse (Überwasserstraße [de] = Over-Water-Street [en]). So my question is now:
A lot of apps show suggestions for our just typed word. I think in the code it is something like this:
String current = editText.getText().toString();
db.lookUp(current); // Of course SQL statement
Can we hook this so that Android thinks that we have typed an ä, ö, ü, ß if we write an a, o, u, ss and the system looks for words with one of these vowels and suggests both? Here I do not want to ask for code - I want to discuss if we are able to write a hack or hook for the Android system. Also, root-rights can be assumed with the solution. I'm looking forward to your ideas.
You could do this the other way around, by "normalizing" typed characters into their related non-diacritical versions. You can use the java.Text.Normalizer class for this. A good snippet can be found in this article:
public static String removeAccents(String text) {
return text == null ? null :
Normalizer.normalize(text, Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
When applied to "Münich", this returns "Munich". That way, you can use a simple string comparison using these normalized versions.
This wouldn't work for "ß" though. If that's the only special case, you could handle it separately.
What you are looking for is called accent-insensitive collating sequence. SQLite's COLLATE operator can be used to do such searches, but I learned from another post that there might be bugs you'll need to look out for.