mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-05 14:47:26 +00:00
eSpeakActivity.java: support speaking specified text in the activity.
This commit is contained in:
@@ -35,9 +35,46 @@
|
||||
<ListView
|
||||
android:id="@+id/properties"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" >
|
||||
|
||||
</ListView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/synthesis_demo"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editText1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:ems="10"
|
||||
android:inputType="textMultiLine" >
|
||||
|
||||
</EditText>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/speak"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/speak" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/ssml"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/ssml" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -129,5 +129,8 @@
|
||||
</string-array>
|
||||
<string name="status">Status</string>
|
||||
<string name="tts_version">eSpeak version</string>
|
||||
<string name="speak">Speak</string>
|
||||
<string name="ssml">Load SSML Template</string>
|
||||
<string name="synthesis_demo">Enter text to speak:</string>
|
||||
|
||||
</resources>
|
||||
@@ -32,6 +32,7 @@ import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.EditText;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
@@ -63,6 +64,7 @@ public class eSpeakActivity extends Activity {
|
||||
private TextToSpeech mTts;
|
||||
private List<Pair<String,String>> mInformation;
|
||||
private InformationListAdapter mInformationView;
|
||||
private EditText mText;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -73,9 +75,29 @@ public class eSpeakActivity extends Activity {
|
||||
mInformation = new ArrayList<Pair<String,String>>();
|
||||
mInformationView = new InformationListAdapter(this, mInformation);
|
||||
((ListView)findViewById(R.id.properties)).setAdapter(mInformationView);
|
||||
mText = (EditText)findViewById(R.id.editText1);
|
||||
|
||||
setState(State.LOADING);
|
||||
checkVoiceData();
|
||||
|
||||
findViewById(R.id.speak).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mTts.speak(mText.getText().toString(), TextToSpeech.QUEUE_ADD, null);
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.ssml).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String ssml =
|
||||
"<?xml version=\"1.0\"?>\n" +
|
||||
"<speak xmlns=\"http://www.w3.org/2001/10/synthesis\" version=\"1.0\">\n" +
|
||||
"\n" +
|
||||
"</speak>";
|
||||
mText.setText(ssml);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user