protected AllophoneSet getAllophoneSetFor(Locale locale) throws MaryConfigurationException { return MaryRuntimeUtils.needAllophoneSet(locale.toString() + ".allophoneset"); } }
if (!MaryRuntimeUtils.canCreateMP3()) { throw new UnsupportedAudioFileException("Conversion to MP3 not supported."); audioFormat = MaryRuntimeUtils.getMP3AudioFormat(); } else if (audioFileFormatType.toString().equals("Vorbis")) { if (!MaryRuntimeUtils.canCreateOgg()) { throw new UnsupportedAudioFileException("Conversion to OGG Vorbis format not supported."); audioFormat = MaryRuntimeUtils.getOggAudioFormat();
toFestival.println(request); toFestival.flush(); AudioDestination audioDestination = MaryRuntimeUtils.createAudioDestination(); int c = -1; InputStream fromFestival = socket.getInputStream();
/** * List the available audio file format types, as a multi-line string. Each line consists of the name of an Audio file format * type, followed by a suffix "_FILE" if the format can be produced as a file, and "_STREAM" if the format can be streamed. * * @return a multi-line string, or an empty string if no audio file types are available. */ public static String getAudioFileFormatTypes() { StringBuilder output = new StringBuilder(); AudioFileFormat.Type[] audioTypes = AudioSystem.getAudioFileTypes(); for (int t = 0; t < audioTypes.length; t++) { AudioFileFormat.Type audioType = audioTypes[t]; String typeName = audioType.toString(); boolean isSupported = true; if (typeName.equals("MP3")) isSupported = canCreateMP3(); else if (typeName.equals("Vorbis")) isSupported = canCreateOgg(); audioType = MaryAudioUtils.getAudioFileFormatType(typeName); if (audioType == null) { isSupported = false; } if (isSupported && AudioSystem.isFileTypeSupported(audioType)) { output.append(typeName).append("_FILE\n"); if (typeName.equals("MP3") || typeName.equals("Vorbis")) output.append(typeName).append("_STREAM\n"); } } return output.toString(); }
return MaryRuntimeUtils.getMaryVersion(); else if (request.equals("datatypes")) return MaryRuntimeUtils.getDataTypes(); else if (request.equals("locales")) return MaryRuntimeUtils.getLocales(); else if (request.equals("voices")) return MaryRuntimeUtils.getVoices(); else if (request.equals("audioformats")) return MaryRuntimeUtils.getAudioFileFormatTypes(); else if (request.equals("exampletext")) { if (queryItems != null) { return MaryRuntimeUtils.getVoiceExampleText(voice); if (datatype != null && locale != null) { Locale loc = MaryUtils.string2locale(locale); return MaryRuntimeUtils.getExampleText(datatype, loc); return null; } else if (request.equals("audioeffects")) return MaryRuntimeUtils.getDefaultAudioEffects(); else if (request.equals("audioeffect-default-param")) { if (queryItems != null) { String effect = queryItems.get("effect"); if (effect != null) return MaryRuntimeUtils.getAudioEffectDefaultParam(effect); String params = queryItems.get("params"); if (effect != null && params != null) {
public Allophone getAllophone() { if (maryxmlElement != null) { AllophoneSet allophoneSet = null; Element voiceElement = (Element) MaryDomUtils.getAncestor(maryxmlElement, MaryXML.VOICE); if (voiceElement != null) { Voice v = Voice.getVoice(voiceElement); if (v != null) { allophoneSet = v.getAllophoneSet(); } } if (allophoneSet == null) { try { allophoneSet = MaryRuntimeUtils.determineAllophoneSet(maryxmlElement); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } String sampa; if (maryxmlElement.getNodeName().equals(MaryXML.PHONE)) { sampa = maryxmlElement.getAttribute("p"); } else { assert maryxmlElement.getNodeName().equals(MaryXML.BOUNDARY); sampa = "_"; } return allophoneSet.getAllophone(sampa); } return null; }
@Test public void testMP3Available() throws Exception { AudioFormat mp3af = new AudioFormat(new AudioFormat.Encoding("MPEG1L3"), AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED, 1, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED, false); AudioInputStream waveStream = AudioSystem.getAudioInputStream(this.getClass().getResourceAsStream("test.wav")); // Now attempt conversion: if (MaryRuntimeUtils.canCreateMP3()) { assertTrue(AudioSystem.isConversionSupported(mp3af, waveStream.getFormat())); AudioInputStream mp3Stream = AudioSystem.getAudioInputStream(mp3af, waveStream); } else { assertFalse(AudioSystem.isConversionSupported(mp3af, waveStream.getFormat())); } } }
public LocalMaryInterface() throws MaryConfigurationException { try { MaryRuntimeUtils.ensureMaryStarted(); } catch (Exception e) { throw new MaryConfigurationException("Cannot start MARY server", e); } init(); }
return MaryRuntimeUtils.getMaryVersion(); else if (request.equals("datatypes")) return MaryRuntimeUtils.getDataTypes(); else if (request.equals("locales")) return MaryRuntimeUtils.getLocales(); else if (request.equals("voices")) return MaryRuntimeUtils.getVoices(); else if (request.equals("audioformats")) return MaryRuntimeUtils.getAudioFileFormatTypes(); else if (request.equals("exampletext")) { if (queryItems != null) { return MaryRuntimeUtils.getVoiceExampleText(voice); if (datatype != null && locale != null) { Locale loc = MaryUtils.string2locale(locale); return MaryRuntimeUtils.getExampleText(datatype, loc); return null; } else if (request.equals("audioeffects")) return MaryRuntimeUtils.getDefaultAudioEffects(); else if (request.equals("audioeffect-default-param")) { if (queryItems != null) { String effect = queryItems.get("effect"); if (effect != null) return MaryRuntimeUtils.getAudioEffectDefaultParam(effect); String params = queryItems.get("params"); if (effect != null && params != null) {
/** * List the available audio file format types, as a multi-line string. Each line consists of the name of an Audio file format * type, followed by a suffix "_FILE" if the format can be produced as a file, and "_STREAM" if the format can be streamed. * * @return a multi-line string, or an empty string if no audio file types are available. */ public static String getAudioFileFormatTypes() { StringBuilder output = new StringBuilder(); AudioFileFormat.Type[] audioTypes = AudioSystem.getAudioFileTypes(); for (int t = 0; t < audioTypes.length; t++) { AudioFileFormat.Type audioType = audioTypes[t]; String typeName = audioType.toString(); boolean isSupported = true; if (typeName.equals("MP3")) isSupported = canCreateMP3(); else if (typeName.equals("Vorbis")) isSupported = canCreateOgg(); audioType = MaryAudioUtils.getAudioFileFormatType(typeName); if (audioType == null) { isSupported = false; } if (isSupported && AudioSystem.isFileTypeSupported(audioType)) { output.append(typeName).append("_FILE\n"); if (typeName.equals("MP3") || typeName.equals("Vorbis")) output.append(typeName).append("_STREAM\n"); } } return output.toString(); }
public Allophone getAllophone() { if (maryxmlElement != null) { AllophoneSet allophoneSet = null; Element voiceElement = (Element) MaryDomUtils.getAncestor(maryxmlElement, MaryXML.VOICE); if (voiceElement != null) { Voice v = Voice.getVoice(voiceElement); if (v != null) { allophoneSet = v.getAllophoneSet(); } } if (allophoneSet == null) { try { allophoneSet = MaryRuntimeUtils.determineAllophoneSet(maryxmlElement); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } String sampa; if (maryxmlElement.getNodeName().equals(MaryXML.PHONE)) { sampa = maryxmlElement.getAttribute("p"); } else { assert maryxmlElement.getNodeName().equals(MaryXML.BOUNDARY); sampa = "_"; } return allophoneSet.getAllophone(sampa); } return null; }
@Test public void testMP3Available() throws Exception { AudioFormat mp3af = new AudioFormat(new AudioFormat.Encoding("MPEG1L3"), AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED, 1, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED, false); AudioInputStream waveStream = AudioSystem.getAudioInputStream(this.getClass().getResourceAsStream("test.wav")); // Now attempt conversion: if (MaryRuntimeUtils.canCreateMP3()) { assertTrue(AudioSystem.isConversionSupported(mp3af, waveStream.getFormat())); AudioInputStream mp3Stream = AudioSystem.getAudioInputStream(mp3af, waveStream); } else { assertFalse(AudioSystem.isConversionSupported(mp3af, waveStream.getFormat())); } } }
public LocalMaryInterface() throws MaryConfigurationException { try { MaryRuntimeUtils.ensureMaryStarted(); } catch (Exception e) { throw new MaryConfigurationException("Cannot start MARY server", e); } init(); }
return MaryRuntimeUtils.getMaryVersion(); else if (request.equals("datatypes")) return MaryRuntimeUtils.getDataTypes(); else if (request.equals("locales")) return MaryRuntimeUtils.getLocales(); else if (request.equals("voices")) return MaryRuntimeUtils.getVoices(); else if (request.equals("audioformats")) return MaryRuntimeUtils.getAudioFileFormatTypes(); else if (request.equals("exampletext")) { if (queryItems != null) { return MaryRuntimeUtils.getVoiceExampleText(voice); if (datatype != null && locale != null) { Locale loc = MaryUtils.string2locale(locale); return MaryRuntimeUtils.getExampleText(datatype, loc); return null; } else if (request.equals("audioeffects")) return MaryRuntimeUtils.getDefaultAudioEffects(); else if (request.equals("audioeffect-default-param")) { if (queryItems != null) { String effect = queryItems.get("effect"); if (effect != null) return MaryRuntimeUtils.getAudioEffectDefaultParam(effect); String params = queryItems.get("params"); if (effect != null && params != null) {
protected AllophoneSet getAllophoneSetFor(Locale locale) throws MaryConfigurationException { return MaryRuntimeUtils.needAllophoneSet(locale.toString() + ".allophoneset"); } }
if (!MaryRuntimeUtils.canCreateMP3()) { throw new UnsupportedAudioFileException("Conversion to MP3 not supported."); audioFormat = MaryRuntimeUtils.getMP3AudioFormat(); } else if (audioFileFormatType.toString().equals("Vorbis")) { if (!MaryRuntimeUtils.canCreateOgg()) { throw new UnsupportedAudioFileException("Conversion to OGG Vorbis format not supported."); audioFormat = MaryRuntimeUtils.getOggAudioFormat();
/** * List the available audio file format types, as a multi-line string. Each line consists of the name of an Audio file format * type, followed by a suffix "_FILE" if the format can be produced as a file, and "_STREAM" if the format can be streamed. * * @return a multi-line string, or an empty string if no audio file types are available. */ public static String getAudioFileFormatTypes() { StringBuilder output = new StringBuilder(); AudioFileFormat.Type[] audioTypes = AudioSystem.getAudioFileTypes(); for (int t = 0; t < audioTypes.length; t++) { AudioFileFormat.Type audioType = audioTypes[t]; String typeName = audioType.toString(); boolean isSupported = true; if (typeName.equals("MP3")) isSupported = canCreateMP3(); else if (typeName.equals("Vorbis")) isSupported = canCreateOgg(); audioType = MaryAudioUtils.getAudioFileFormatType(typeName); if (audioType == null) { isSupported = false; } if (isSupported && AudioSystem.isFileTypeSupported(audioType)) { output.append(typeName).append("_FILE\n"); if (typeName.equals("MP3") || typeName.equals("Vorbis")) output.append(typeName).append("_STREAM\n"); } } return output.toString(); }
/** * For an element in a MaryXML document, do what you can to determine the appropriate AllophoneSet. First search for the * suitable voice, then if that fails, go by locale. * * @param e * e * @return an allophone set if there is any way of determining it, or null. * @throws MaryConfigurationException * if a suitable allophone set exists in principle, but there were problems loading it. */ public static AllophoneSet determineAllophoneSet(Element e) throws MaryConfigurationException { AllophoneSet allophoneSet = null; Element voice = (Element) MaryDomUtils.getAncestor(e, MaryXML.VOICE); Voice maryVoice = Voice.getVoice(voice); if (maryVoice == null) { // Determine Locale in order to use default voice Locale locale = MaryUtils.string2locale(e.getOwnerDocument().getDocumentElement().getAttribute("xml:lang")); maryVoice = Voice.getDefaultVoice(locale); } if (maryVoice != null) { allophoneSet = maryVoice.getAllophoneSet(); } else { Locale locale = MaryUtils.string2locale(e.getOwnerDocument().getDocumentElement().getAttribute("xml:lang")); allophoneSet = determineAllophoneSet(locale); } return allophoneSet; }
public LocalMaryInterface() throws MaryConfigurationException { try { MaryRuntimeUtils.ensureMaryStarted(); } catch (Exception e) { throw new MaryConfigurationException("Cannot start MARY server", e); } init(); }
toFestival.println(request); toFestival.flush(); AudioDestination audioDestination = MaryRuntimeUtils.createAudioDestination(); int c = -1; InputStream fromFestival = socket.getInputStream();