Debian Codegraph @

android/src/com/reecedunn/espeak/GetSampleText.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2012-2013 Reece H. Dunn
3 * Copyright (C) 2011 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package com.reecedunn.espeak;
19
20 import android.annotation.SuppressLint;
21 import android.app.Activity;
22 import android.content.Intent;
23 import android.os.Bundle;
24 import android.speech.tts.TextToSpeech;
25
26 import java.util.Locale;
27
28 /*
29 * Returns the sample text string for the language requested
30 */
31 @SuppressLint("NewApi")
32 public class GetSampleText extends Activity {
33 @Override
34 protected void onCreate(Bundle savedInstanceState) {
35 super.onCreate(savedInstanceState);
36
37 final Locale locale = getLocaleFromIntent(getIntent());
38 final String text = SpeechSynthesis.getSampleText(getBaseContext(), locale);
39
40 final int result = TextToSpeech.LANG_AVAILABLE;
41 final Intent returnData = new Intent();
42 returnData.putExtra(TextToSpeech.Engine.EXTRA_SAMPLE_TEXT, text);
43 setResult(result, returnData);
44 finish();
45 }
46
47 private static Locale getLocaleFromIntent(Intent intent) {
48 if (intent != null) {
49 final String language = intent.getStringExtra("language");
50
51 if (language != null) {
52 return new Locale(language);
53 }
54 }
55
56 return Locale.getDefault();
57 }
58 }