Move the sample text logic into SpeechSynthesis.getSampleText and add test cases for it.

This commit is contained in:
Reece H. Dunn
2012-12-18 14:38:57 +00:00
parent 026110c64d
commit 2a3a1a0a81
5 changed files with 148 additions and 222 deletions
@@ -1,4 +1,5 @@
/*
* Copyright (C) 2012 Reece H. Dunn
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,7 +25,10 @@
package com.reecedunn.espeak;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.speech.tts.TextToSpeech;
import android.util.DisplayMetrics;
import android.util.Log;
import java.io.File;
@@ -159,6 +163,15 @@ public class SpeechSynthesis {
mInitialized = true;
}
public static String getSampleText(Context context, Locale locale) {
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
final Configuration config = context.getResources().getConfiguration();
config.locale = locale;
Resources res = new Resources(context.getAssets(), metrics, config);
return res.getString(R.string.sample_text, locale.getDisplayName(locale));
}
private int mNativeData;
private static native final boolean nativeClassInit();