Speech to Text Using Android SDK

Posted by Unknown Sabtu, 23 Maret 2013 0 komentar

Speech to Text using Android APIs


You can create a simple application using the google speech engine and convert the voice to text.

Create an android project and create the following res layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/textView1"
android:layout_toLeftOf="@+id/textView1"
android:gravity="center"
android:orientation="vertical" >

<ImageButton
android:id="@+id/btnSpeak"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
/>

<TextView
android:id="@+id/txtText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>

Now you can use the following activity code to add in your sample application.

package com.example.speech2text;

import java.util.ArrayList;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.view.Menu;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

protected static final int RESULT_SPEECH = 1;

private ImageButton btnSpeak;
private TextView txtText;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

txtText = (TextView) findViewById(R.id.txtText);

btnSpeak = (ImageButton) findViewById(R.id.btnSpeak);

btnSpeak.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {

Intent intent = new Intent(
RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US");

try {
startActivityForResult(intent, RESULT_SPEECH);
txtText.setText("");
} catch (ActivityNotFoundException a) {
Toast t = Toast.makeText(getApplicationContext(),
"Opps! Your device doesn't support Speech to Text",
Toast.LENGTH_SHORT);
t.show();
}
}
});

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

switch (requestCode) {
case RESULT_SPEECH: {
if (resultCode == RESULT_OK && null != data) {

ArrayList<String> text = data
.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

txtText.setText(text.get(0));
}
break;
}

}
}
}





Baca Selengkapnya ....

Using Speech Engine in Android

Posted by Unknown Kamis, 21 Maret 2013 0 komentar

This post is focusing on speech engine in Android SDK. The TTS engine is very important component of the Android SDK and the Android 4.0 version has great APIs to write the custom TTS engines.

Here i am explaining a sample code to use the TTS engine in your android application.

Create the following layout in your android application.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent" >

<TextView android:id="@+id/msglabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter some text in english:"
/>
<EditText android:id="@+id/inputtext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button android:id="@+id/speakenglish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="speak in english"
/>

</LinearLayout>


Here is the code of the sample speak activity you can just copy and paste this in your application project.

package com.example.speaksample;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;

import android.app.Activity;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.view.View;
import android.widget.EditText;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.content.Intent;
import java.util.Locale;
import android.widget.Toast;

public class speaksample extends Activity implements OnClickListener, OnInitListener {
//Create the TTS object
private TextToSpeech TTSObject;
//status check code
private int DATA_CHECK_CODE = 0;
//create the Activity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_speaking_android);
//get a reference to the button element listed in the XML layout
Button speakButton = (Button)findViewById(R.id.speakenglish);
//set the click listener
speakButton.setOnClickListener(this);
//check for TTS data
Intent checkTTSIntent = new Intent();
checkTTSIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(checkTTSIntent, DATA_CHECK_CODE);
}
//respond to button clicks
public void onClick(View v) {
//get the text entered
EditText inputtext = (EditText)findViewById(R.id.inputtext);
String data = inputtext.getText().toString();
speakInEnglish(data);
}
//speak the user text
private void speakInEnglish(String speech) {
//speak straight away
TTSObject.speak(speech, TextToSpeech.QUEUE_FLUSH, null);
}
//act on result of TTS data check
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == DATA_CHECK_CODE) {
if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
//the user has the necessary data - create the TTS
TTSObject = new TextToSpeech(this, this);
}
else {
//no data - install it now
Intent installTTSIntent = new Intent();
installTTSIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installTTSIntent);
}
}
}
//setup TTS
public void onInit(int initStatus) {
//check for successful instantiation
if (initStatus == TextToSpeech.SUCCESS) {
if(TTSObject.isLanguageAvailable(Locale.US)==TextToSpeech.LANG_AVAILABLE)
TTSObject.setLanguage(Locale.US);
}
else if (initStatus == TextToSpeech.ERROR) {
Toast.makeText(this, "TTS engine fails", Toast.LENGTH_LONG).show();
}
}
}


If you like the code please share your feedback.

Thanks

Baca Selengkapnya ....

open a facebook page on browser in android

Posted by Unknown Rabu, 20 Maret 2013 0 komentar

Open a facebook page in Android Application

To open a facebook page in your android application you can create the following method and call this method in a class derived from activity

This will run the facebook page of the user in a different activity window.

public static Intent getOpenFacebookIntent(Activity acty,String szUserId,String szUserName) {

try {
acty.getBaseContext().getPackageManager().getPackageInfo("com.facebook.katana", 0);
return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + szUserId));
} catch (Exception e) {
return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + szUserName));
}
}


If you like the code please provide your feedback.

Baca Selengkapnya ....

Android Read SMS

Posted by Unknown 0 komentar

Reading the SMS inbox from Android phone

Here is the quick way to read all the SMS stored in the inbox on android.

package com.csr.targetplus;

import java.util.List;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.database.Cursor;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.support.v4.app.NavUtils;

public class TargetPlus extends Activity {

private static final String TAG = null;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView view = new TextView(this);
Uri uriSMSURI = Uri.parse("content://sms/inbox");
Cursor cur = getContentResolver().query(uriSMSURI, null, null, null,null);
String sms = "";
while (cur.moveToNext()) {
sms += "From :" + cur.getString(2) + " : " + cur.getString(11)+"\n";
}
view.setText(sms);
setContentView(view);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_target_plus, menu);
return true;
}


}




Baca Selengkapnya ....

Speed Up Your Computer with Run commands

Posted by Unknown Selasa, 19 Maret 2013 0 komentar


Speed Up Computer with Run commands


Learn how to speed up your computer with simple RUN commands.This can improve your PC processing speed and simultaneously you can save loading time of computer files like MP3 etc and system Drives.Before going to know the commands to operate let us know some of the mistakes we do that kills computer speed.

Avoid Doing this:

These are the most common mistakes that can kill the processing speed of the computer.So avoid those and gain the speed.
Never keep all the files/folders on the Desktop Screen.
Don't add too many side bar widgets.
Don't add animation images on Desktop.
Avoid too many Start Up programs.
Avoid keeping unused programs which occupies the disk space.

Follow these Steps:

Follow the steps given below to improve computer speed and keep your computer safe.
Use Strong anti-virus to keep away your computer from Mall-ware and spyware.
Never log out system with out closing all the applications and folders.
Use Disk space cleaner tools to free disk space.
If you want to delete a file permanently use SHIFT+DELETE
Don't open too many folders or application at once.
Most common but yet we should remember this Refresh the computer every time when you log in.This can be done either by Functional key F5 or right click on the desktop screen and then click "Refresh" option.

RUN COMMANDS TO SPEED UP COMPUTER:

Use the following run commands to remove the systems temporary and recent files whenever you feel that system is working slowly with that you can  improve computer  processing.

Open Run command and type the following commands one-by-one and delete those files and folders permanently from your computer.Some of the files won't delete then let it  be and skip those files.

Run commands:

Temp  
%Temp%
Recent 
Prefetch 
ipconfig







Baca Selengkapnya ....

Android Beam Mobile Phones

Posted by Unknown Senin, 18 Maret 2013 0 komentar
Android Beam : Android beam is the new concept which already known by a lot of people. The Beam is a new device which is used to use the internet connection. We have the beam internet connection in india as well as other parts of the world. So connecting the internet using the beam connection in android mobile phone is called as the android beam.

Android Beam

This is just my view on the concept. Please research before doing any act.

Baca Selengkapnya ....

online bullying Teenagers Victimised

Posted by Unknown Minggu, 17 Maret 2013 0 komentar

Teenagers are the biggest victims of online bullying, the majority of which takes place on popular social networking site Facebook, a new UK study has claimed.

After Facebook, Twitter was the next most frequent face for bullying - or trolling - to take place, according to the study of more than 2,000 teenagers by Opinium Research.

The study revealed that 85 per cent of 19-year-old men had experienced some form of online bullying.

Of those who admitted they had been bullied, 87 per cent said it had happened on Facebook, 19 per cent on Twitter and 13 per cent on BlackBerry Messenger.

Of all the teenagers who said they had been bullied, only 37 per cent had reported it to the social network where it took place.

Only 17 per cent said that their first reaction would be to tell their parents, and just 1 per cent said it would be to tell their teacher, The Telegraph reported.

The study was carried out for knowthenet.org.uk, a free online site offering advice on how to stay safe online.

Media psychologist Arthur Cassidy said online bullying could have a "massive impact" on older male teenagers.

"Suicide rates are particularly high amongst this demographic, so it's worrying to hear that teenagers on the whole are choosing to deal with internet abuse themselves

rather than speaking to parents or teachers for help," he said.

"Whilst some might expect girls to be more vulnerable online, this study shows that older boys are more at risk from trolling and cyber-bullying," he said.

Baca Selengkapnya ....
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of apk xda.