本文整理汇总了Java中marytts.util.data.audio.AudioPlayer类的典型用法代码示例。如果您正苦于以下问题:Java AudioPlayer类的具体用法?Java AudioPlayer怎么用?Java AudioPlayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AudioPlayer类属于marytts.util.data.audio包,在下文中一共展示了AudioPlayer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: speakTextFromAcousticParameters
import marytts.util.data.audio.AudioPlayer; //导入依赖的package包/类
private void speakTextFromAcousticParameters(Document doc, MaryProsody mp) throws TTSException
{
AudioInputStream audio = speakTextToAudioInputStream(doc, MaryDataType.ACOUSTPARAMS);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream is1, is2;
try
{
ByteStreams.copy(audio, baos);
is1 = new ByteArrayInputStream(baos.toByteArray());
is2 = new ByteArrayInputStream(baos.toByteArray());
double data[] = MaryAudioUtils.getSamplesAsDoubleArray(new AudioInputStream(is1, audio.getFormat(), audio.getFrameLength()));
mp.setRMSEnergy(getRMSEnergy(data, audio.getFormat().getFrameRate()));
is1.close();
}
catch (IOException e)
{
throw new TTSException(e.getLocalizedMessage(), e);
}
AudioPlayer ap = new AudioPlayer(new AudioInputStream(is2, audio.getFormat(), audio.getFrameLength()), null);
ap.start();
}
示例2: speakBlocking
import marytts.util.data.audio.AudioPlayer; //导入依赖的package包/类
public synchronized void speakBlocking(String text) //synchronized so that together with the call to join(), calls to this method will wait until previous calls are finished
{
if (text != null && !text.isEmpty())
{
try
{
AudioPlayer ap = new AudioPlayer();
ap.setAudio(maryTTS.generateAudio(text));
ap.start();
ap.join();
}
catch (SynthesisException se)
{
logger.log(Level.SEVERE, "MaryTTS failed to generate audio for text \"" + text + "\"", se);
}
catch (InterruptedException ie)
{
logger.log(Level.SEVERE, "MaryTTS AudioPlayer thread was interrupted.", ie);
}
}
}
示例3: say
import marytts.util.data.audio.AudioPlayer; //导入依赖的package包/类
public static void say(String comment) {
if (isSilenced) {
System.out.println(comment);
return;
}
try {
if (!inited) {
init();
}
if (comment.isEmpty()) return;
final AudioInputStream audio = marytts.generateAudio(comment);
final AudioPlayer player = new AudioPlayer(audio);
player.start();
} catch (MaryConfigurationException | SynthesisException e) {
logger.error("Error sythesizing text to voice", e);
}
}
示例4: playAudio
import marytts.util.data.audio.AudioPlayer; //导入依赖的package包/类
private void playAudio(AudioInputStream audio)
{
LineListener lineListener = new LineListener()
{
public void update(LineEvent event)
{
if (event.getType() == LineEvent.Type.START) { Log.print(Log.DEBUG,"Audio started playing."); }
else if (event.getType() == LineEvent.Type.STOP) { Log.print(Log.DEBUG,"Audio stopped playing."); }
else if (event.getType() == LineEvent.Type.OPEN) { Log.print(Log.DEBUG,"Audio line opened."); }
else if (event.getType() == LineEvent.Type.CLOSE) { Log.print(Log.DEBUG,"Audio line closed."); }
}
};
AudioPlayer ap = new AudioPlayer(audio, lineListener);
ap.start();
}
示例5: executeSpeaking
import marytts.util.data.audio.AudioPlayer; //导入依赖的package包/类
private void executeSpeaking(String speech) throws SynthesisException, InterruptedException {
AudioInputStream audio = marytts.generateAudio(speech.trim());
currentlySpeeking = new AudioPlayer(audio);
log.debug("Speeking: " + speech.trim());
notifySpeechListeners(speech.trim());
currentlySpeeking.start();
currentlySpeeking.join();
}
示例6: executeSpeaking
import marytts.util.data.audio.AudioPlayer; //导入依赖的package包/类
private void executeSpeaking(String speech) throws SynthesisException, InterruptedException {
AudioInputStream audio = marytts.generateAudio(speech);
currentlySpeeking = new AudioPlayer(audio);
log.debug("Speeking: " + speech);
currentlySpeeking.start();
currentlySpeeking.join();
}
示例7: read
import marytts.util.data.audio.AudioPlayer; //导入依赖的package包/类
public static void read(String s) throws SynthesisException, InterruptedException {
AudioInputStream audio = marytts.generateAudio(s.length() > 0 ? s : "Ich kann das leider nicht lesen.");
player = new AudioPlayer(audio);
player.start();
player.join();
}