“English voice to translated Bangla Text” report - WordPress.com

knapsackyarnΚινητά – Ασύρματες Τεχνολογίες

14 Δεκ 2013 (πριν από 3 χρόνια και 6 μήνες)

48 εμφανίσεις

My Project Description

Project title

:
English voice to “Bangla
Translated text “ for android
phone by Java language .


Working Step of my project

:

Full working step of my project is given below
-

1.

Speaking
English voice

2.

Voice recognized with the help of
Voice Recognizer

3.

Getting
English Sentence or text

4.

Tokenization of English sentence

5.

Obtaining Bangla meaning of each word

6.

Making
English to Bangla dictionary

7.

Construction of Bangla sentence

8.

Bangla text

Flowchart :
















English Voice


English Sentence

Tokenization

Recognizer

Obtaining Bangla
meaning

Bangla sentence or

text


Construction of
Bangla Sentence by
rule

English to Bangla

Dictionary


Completed Task yet :

Designing the
layout :

We can design the layout

with the help of java code or xml code. I have designed the
layout my my project layout with the xml code.



<?
xml

version
=
"1.0"

encoding
=
"utf
-
8"
?>

<
LinearLayout


xmlns:android
=
"http://schemas.android.com/apk/res/android"


android:layout_width
=
"match_parent"


android:layout_height
=
"match_parent"


android:orientation
=
"vertical"
>








<
Button




android:id
=
"@+id/click_button"


android:layout_wid
th
=
"match_parent"


android:layout_height
=
"wrap_content"


android:text
=
"Click first then speak"

/>




<
EditText


android:id
=
"@+id/edittext01"


android:layout_width
=
"fill_parent"


android:layout_height
=
"
wrap_content"



android:layout_weight
=
"0.19"
/>



<
requestFocus
>



</
requestFocus
>

<
TableRow

android:layout_width
=
"fill_parent"


android:layout_height
=
"wrap_content"
>


<
Button




android:id
=
"@+id/send_button"


android:text
=
"Send"



android:layout_height
=
"48dp"



android:layout_width
=
"105dp"
/>



<
Button




android:id
=
"@+id/save_button"


android:text
=
"Save"



android:layout_height
=
"48dp"



android:layout_width
=
"105dp"
/>




<
Button




android:id
=
"@+id/exit_button"


android:text
=
"Exit"



android:layout_height
=
"48dp"



android:layout_width
=
"105dp"
/>





</
TableRow
>



<
TextView


android:layout_width
=
"
match_parent"


android:layout_height
=
"wrap_content"


android:text
=
"Select the Right one "


android:textSize
=
"20dp"




android:gravity
=
"center"
>


</
TextView
>




<
ListView


andro
id:id
=
"@+id/list"


android:layout_width
=
"match_parent"


android:layout_height
=
"0dip"


android:layout_weight
=
"1"

/>


</
LinearLayout
>


Look like this :





First Step :






English voice










English sentence or text



Google
Recognizer

Algorithm :

Input : Voice.

Output : sentence or text


Step
-
1:
Speaking

Step
-
2 : Accepted by microphone

Step
-
3 : while(speaking){



Calling Google Recognizer();


If (speaking word )


Return matched word


Else



Not marching


}

Step
-
4: end


The main activity class :

package

altaf.cse.ruet;


import

android.app.Activity;

import

android.os.Bundle;

import

android.content.Intent;

import

android.content.pm.PackageManager;

import

android.content.pm.ResolveInfo;

import

android.speech.RecognizerIntent;



import

android.view.View;

import

android.view.View.OnClickListener;

import

android.widget.AdapterView;

import

android.widget.AdapterV
iew.OnItemClickListener;

import

android.widget.ArrayAdapter;

import

android.widget.Button;

import

android.widget.EditText;

import

android.widget.TextView;

import

android.widget.Toast;



import

android.widget.ListView;

import

java.util.ArrayList;

import

java.util.List;



public

class

SpeakActivity
extends

Activity
implements

OnClickListener {


private

static

final

int

VOICE_RECOGNITION_REQUEST_CODE

= 1234;


private

ListView
listv
;



private

EditText
edittext01
;




@Override


public

void

onCreate
(Bundle savedInstanceState) {


super
.onCreate(savedInstanceState);


setContentView(R.layout.
main
);


Button exitButton = (Button) findViewById(R.id.
exit_button
);


exitButton.setOnClickListener(
this
);


Button speakButton =

(Button) findViewById(R.id.
click_button
);


listv

= (ListView) findViewById(R.id.
list
);


edittext01

= (EditText)findViewById(R.id.
edittext01
);


Button saveButton = (Button) findViewById(R.id.
save_button
);


saveButton.setOnClickL
istener(
this
);


Button sendButton = (Button) findViewById(R.id.
send_button
);


sendButton.setOnClickListener(
this
);






PackageManager pm = getPackageManager();


List<ResolveInfo> activities =
pm.queryIntentActivities(




new

Intent(RecognizerIntent.
ACTION_RECOGNIZE_SPEECH
), 0);


if

(activities.size() != 0) {



speakButton.setOnClickListener(
this
);



}
else

{



speakButton.setEnabled(
false
);



speakButto
n.setText(
"Recognizer not found"
);



}



}








//////////////////////////


public

void

onClick(View v) {



switch

(v.getId()) {



case

R.id.
click_button
:




startVoiceRecognitionActivity();




break
;



case

R.id.
exit_button
:


finish();



break
;



case

R.id.
save_button
:




Toast.
makeText
(
this
,
"Not Database create yet."
, Toast.
LENGTH_SHORT
)




.show();




break
;



case

R.id.
send_button
:




Toast.
makeText
(
this
,
"Not implemented yet."
, Toast.
LENGTH_SHORT
)




.show();




break
;






}


}


//////////////////////////





private

void

startVoiceRecognitionActivity() {



Intent intent =
new

Intent(RecognizerIntent.
ACTION_RECOGNIZE_SPEECH
);



intent.putExtra(RecognizerIntent.
EXTRA_LANGUAGE

,



RecognizerIntent.
LANGUAGE_MODEL_FREE_FORM
);



intent.putExtra(RecognizerIntent.
EXTRA_PROMPT
,
"Speech recognition demo"
);



startActivityForResult(intent,
VOICE_RECOGNITION_REQUEST_CODE
);



}



@Override


protected

void

onActivityResult(
int

requestCode,
int

resultCode, Intent data) {


if

(requestCode ==
VOICE_RECOGNITION_REQUEST_CODE

&& resultCode ==
RESULT_OK
) {




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


list
v
.setAdapter(
new

ArrayAdapter<String>(
this
,
android.R.layout.
simple_list_item_1
,


matches));




}


super
.onActivityResult(requestCode, resultCode, data);


listv
.setOnItemClickListener(
new

OnItemClickListener() {



public

void

onItemClick(
AdapterView<?> parent, View v,





int

position,
long

id) {




// When clicked, show a toast with the TextView text




//Toast.makeText(getApplicationContext(), ((TextView)
v).getText(),




//Toast.LENGTH_SHORT).show();







edittext01
.setText(String





.
valueOf
(((TextView) v).getText()));




}


});




}


}




ACTION_RECOGNIZE_SPEECH

:

Starts an activity that will prompt the user for speech and sends it through a speech recognizer. The
results will be returned via activity results (in
onActivityResult(int, int, Intent)
, if you start
the intent using
startActivityForResult(Intent, int)
), or forwarded via a PendingIntent if one
is provided.

Starting this intent with just
startActivity(Intent)

is not supported. You must either use
startActivityForResult(Intent, int)
, or provide a PendingIntent, to receive recognition
results.

EXTRA_LANGUAGE :

Informs the recognizer which speech model to
prefer when performing
ACTION_RECOGNIZE_SPEECH
.
The recognizer uses this information to fine tune the results. This

extra is required. Activities
implementing
ACTION_RECOGNIZE_SPEECH

may interpret the values as they see fit.

LANGUAGE_MODEL_FREE_FORM :

Use a language model based on free
-
form speech recognition. This is a value to use for
EXTR
A_LANGUAGE_MODEL
.

EXTRA_PROMPT :

Optional text prompt to show to the user when asking them to speak.

Constant Value:
"android.speech.extra.PROMPT

EXTRA_RESULTS:

An ArrayList<String> of the recognition results when performing
ACTION_RECOGNIZE_SPEECH
.
Returned in the results; not to be specified in the recognition request. Only present when
RESULT_OK

is
returned in an activity result. In a PendingIntent, the lack of this extra indicates failure.


English to Bangla Dictionary creating :