本文整理汇总了Java中android.speech.tts.Voice类的典型用法代码示例。如果您正苦于以下问题:Java Voice类的具体用法?Java Voice怎么用?Java Voice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Voice类属于android.speech.tts包,在下文中一共展示了Voice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentVoice
import android.speech.tts.Voice; //导入依赖的package包/类
@ReactMethod
public void getCurrentVoice(Promise promise) {
if(notReady(promise)) return;
try {
if(Build.VERSION.SDK_INT >= 21) {
Voice currentVoice = tts.getVoice();
WritableMap map = returnMapForVoice(currentVoice);
promise.resolve(map);
} else {
promise.reject("error", "Method not availaible for SDK version " + Build.VERSION.SDK_INT + ". Requires(SDK version >= 21)");
}
} catch(Exception e) {
promise.reject("error", "Unable to retrieve voice for getCurrentVoice()", e);
}
}
开发者ID:echo8795,项目名称:react-native-android-text-to-speech,代码行数:18,代码来源:RNAndroidTextToSpeechModule.java
示例2: getAvailableVoices
import android.speech.tts.Voice; //导入依赖的package包/类
@ReactMethod
public void getAvailableVoices(Promise promise) {
if(notReady(promise)) return;
try {
WritableArray voicesList = Arguments.createArray();
Voice[] array = tts.getVoices().toArray(new Voice[tts.getVoices().size()]);
for(Voice voice: array) {
WritableMap newVoice = returnMapForVoice(voice);
voicesList.pushMap(newVoice);
}
promise.resolve(voicesList);
} catch(Exception e) {
promise.reject("not_found", "Unable to retrieve voices for getAvailableVoices()", e);
}
}
开发者ID:echo8795,项目名称:react-native-android-text-to-speech,代码行数:18,代码来源:RNAndroidTextToSpeechModule.java
示例3: getEngineDefaultSaiyVoice
import android.speech.tts.Voice; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private SaiyVoice getEngineDefaultSaiyVoice() {
final Voice voice = getDefaultVoice();
if (voice != null) {
final SaiyVoice saiyVoice = new SaiyVoice(voice);
saiyVoice.setEngine(getInitialisedEngine());
saiyVoice.setGender(saiyVoice.getName());
if (DEBUG) {
MyLog.i(CLS_NAME, "getEngineDefaultSaiyVoice: setting Gender: " + saiyVoice.getGender().name());
}
return saiyVoice;
} else {
if (DEBUG) {
MyLog.i(CLS_NAME, "getEngineDefaultSaiyVoice: voice null");
}
return null;
}
}
示例4: getVoices
import android.speech.tts.Voice; //导入依赖的package包/类
@Override
public Set<Voice> getVoices() {
final long then = System.nanoTime();
if (defaultVoiceSet == null || defaultVoiceSet.isEmpty()) {
defaultVoiceSet = super.getVoices();
} else {
if (DEBUG) {
MyLog.i(CLS_NAME, "getVoices: already prepared");
}
}
if (DEBUG) {
MyLog.getElapsed("getVoices", then);
}
return defaultVoiceSet;
}
示例5: getSaiyVoices
import android.speech.tts.Voice; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Set<SaiyVoice> getSaiyVoices() {
final long then = System.nanoTime();
final Set<Voice> voiceSet = getVoices();
if (saiyVoiceSet == null || saiyVoiceSet.size() != voiceSet.size()) {
saiyVoiceSet = SaiyVoice.getSaiyVoices(voiceSet, getInitialisedEngine());
} else {
if (DEBUG) {
MyLog.i(CLS_NAME, "getSaiyVoices: already prepared");
}
}
if (DEBUG) {
MyLog.getElapsed("getSaiyVoices", then);
}
return saiyVoiceSet;
}
示例6: returnMapForVoice
import android.speech.tts.Voice; //导入依赖的package包/类
private WritableMap returnMapForVoice(Voice voice) {
WritableMap voiceData = Arguments.createMap();
voiceData.putString("voiceName", voice.getName());
voiceData.putString("languageName", voice.getLocale().getDisplayLanguage());
voiceData.putString("languageCode", voice.getLocale().getISO3Language());
voiceData.putString("languageString", voice.getLocale().toString());
voiceData.putString("countryName", voice.getLocale().getDisplayCountry());
voiceData.putString("countryCode", voice.getLocale().getISO3Country());
return voiceData;
}
开发者ID:echo8795,项目名称:react-native-android-text-to-speech,代码行数:12,代码来源:RNAndroidTextToSpeechModule.java
示例7: pronounceWord
import android.speech.tts.Voice; //导入依赖的package包/类
public static void pronounceWord(CharSequence word, float pitch, float speechRate, Voice accent) {
//manual pronunciation of a word, never used.
american_speaker_google.setPitch(pitch);
american_speaker_google.setSpeechRate(speechRate);
american_speaker_google.setVoice(accent);
american_speaker_google.speak(word, QUEUE_FLUSH, null, null);
}
示例8: searchVoice
import android.speech.tts.Voice; //导入依赖的package包/类
public static Voice searchVoice(String voiceName, TextToSpeech tts) {
if (MainActivity.isLoggingEnabled)
Log.i("VOICES:", tts.getVoices().toString()); //stampa tutte le voci disponibili
for (Voice tmpVoice : tts.getVoices()) {
if (tmpVoice.getName().equals(voiceName)) {
return tmpVoice;
}
}
return null;
}
示例9: getBoundSaiyVoice
import android.speech.tts.Voice; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public SaiyVoice getBoundSaiyVoice() {
final Voice voice = getVoice();
if (voice != null) {
final SaiyVoice saiyVoice = new SaiyVoice(voice);
saiyVoice.setEngine(getInitialisedEngine());
saiyVoice.setGender(saiyVoice.getName());
return saiyVoice;
} else {
return null;
}
}
示例10: TTS
import android.speech.tts.Voice; //导入依赖的package包/类
public TTS(Context c){
tts = new TextToSpeech(c, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int i) {
if (i==TextToSpeech.SUCCESS) {
tts.setLanguage(Locale.ITALY);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
tts.setVoice(new Voice("My Voice", Locale.ITALY, QUALITY_VERY_HIGH, LATENCY_NORMAL, true, tts.getFeatures(Locale.ITALY)));
}
}
});
}
示例11: onGetVoices
import android.speech.tts.Voice; //导入依赖的package包/类
@Override
@TargetApi(21)
public List<Voice> onGetVoices() {
// Work-around for https://github.com/De7vID/klingon-assistant/issues/132.
List<Voice> list = new ArrayList<Voice>();
list.add(new Voice("Klingon (Canada)", new Locale("tlh", "CAN"), 100, 100, false,
new HashSet<String>()));
return list;
}
示例12: getVoice
import android.speech.tts.Voice; //导入依赖的package包/类
public Voice getVoice() {
return voice;
}
示例13: setVoice
import android.speech.tts.Voice; //导入依赖的package包/类
public void setVoice(@NonNull final Voice voice) {
this.voice = voice;
}
示例14: SaiyVoice
import android.speech.tts.Voice; //导入依赖的package包/类
public SaiyVoice(@NonNull final Voice voice) {
super(voice.getName(), voice.getLocale(), voice.getQuality(), voice.getLatency(), voice.isNetworkConnectionRequired(),
voice.getFeatures());
}
示例15: compare
import android.speech.tts.Voice; //导入依赖的package包/类
@Override
public int compare(final Voice v1, final Voice v2) {
return v1.getLocale().toString().compareTo(v2.getLocale().toString());
}