| package com.reecedunn.espeak.test; | package com.reecedunn.espeak.test; | ||||
| import java.util.HashMap; | |||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import java.util.Map; | |||||
| import java.util.Set; | import java.util.Set; | ||||
| import com.reecedunn.espeak.SpeechSynthesis; | import com.reecedunn.espeak.SpeechSynthesis; | ||||
| } | } | ||||
| }; | }; | ||||
| private List<Voice> mVoices = null; | |||||
| private Map<String, Voice> mVoices = null; | |||||
| private Set<String> mAdded = new HashSet<String>(); | private Set<String> mAdded = new HashSet<String>(); | ||||
| private Set<String> mRemoved = new HashSet<String>(); | private Set<String> mRemoved = new HashSet<String>(); | ||||
| public List<Voice> getVoices() | |||||
| public Map<String, Voice> getVoices() | |||||
| { | { | ||||
| if (mVoices == null) | if (mVoices == null) | ||||
| { | { | ||||
| final SpeechSynthesis synth = new SpeechSynthesis(getContext(), mCallback); | final SpeechSynthesis synth = new SpeechSynthesis(getContext(), mCallback); | ||||
| mVoices = synth.getAvailableVoices(); | |||||
| mVoices = new HashMap<String, Voice>(); | |||||
| for (Voice voice : synth.getAvailableVoices()) { | |||||
| mVoices.put(voice.name, voice); | |||||
| } | |||||
| assertThat(mVoices, is(notNullValue())); | assertThat(mVoices, is(notNullValue())); | ||||
| Set<String> voices = new HashSet<String>(); | Set<String> voices = new HashSet<String>(); | ||||
| for (Voice data : mVoices) | |||||
| for (Voice data : mVoices.values()) | |||||
| { | { | ||||
| voices.add(data.name); | voices.add(data.name); | ||||
| } | } | ||||
| public Voice getVoice(String name) | public Voice getVoice(String name) | ||||
| { | { | ||||
| for (Voice voice : getVoices()) | |||||
| { | |||||
| if (voice.name.equals(name)) | |||||
| { | |||||
| return voice; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| return getVoices().get(name); | |||||
| } | } | ||||
| public void testConstruction() | public void testConstruction() |