本文介绍了如何实现Text-to-Speech示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MaryTTS是一个用Java编写的开源,文本到语音合成平台:





我尝试用GitHub实现一个例子(3行代码,请找如下)。

主题:使用默认设置的简单文本转语音:





MaryTTS is an open-source, Text-to-Speech Synthesis platform written in Java:
http://mary.dfki.de

I try to implement an example from GitHub (3 line codes, please find as follows).
Subject: Simple text-to-speech with default settings:
https://github.com/marytts/marytts/wiki/MaryInterface#simple-text-to-speech-with-default-settings

MaryInterface marytts = new LocalMaryInterface();
AudioInputStream audio = marytts.generateAudio("This is my text.");
MaryAudioUtils.writeWavFile(MaryAudioUtils.getSamplesAsDoubleArray(audio), "/tmp/thisIsMyText.wav", audio.getFormat());



我使用MaryTTS安装程序在我的Windows上安装了Mary TTS:





我开始了Mary TTS服务器和Mary TTS客户端(),我做了一些文本到音频转换的试验(很棒) 。



我希望我不会因为太多的新手问题而困扰你。

过去三周我在这个问题上花了几个小时但没有成功。



刚开始.. ,我无法实现如何实现这个例子。

即使用MaryTTS安装程序后,需要执行哪些步骤才能使上面的示例代码生效?



再次感谢您的帮助请求。

Mike


I installed Mary TTS on my Windows, using MaryTTS installer:
https://github.com/marytts/marytts-installer

I started the Mary TTS server and the Mary TTS client (http://localhost:59125), and I did some trials with text to audio conversion (its great).

I hope I'm not bothering you with too much of a newbie questions.
I've spent a few hours over the last three weeks on this issue but with no success.

Just to get started.., I can't realize how to implement this example.
I.e. After using MaryTTS installer, what steps are needed to get the above example code to work?

Thanks again for the help request.
Mike

推荐答案

try {
		    AudioInputStream input = AudioSystem.getAudioInputStream(new File("/tmp/thisIsMyText.wav"));
		    SourceDataLine line = AudioSystem.getSourceDataLine(input.getFormat());
		    line.open(input.getFormat());
		    line.start();
		    byte[] buffer = new byte[1024];
		    int count;
		    while((count = input.read(buffer, 0, 1024)) != -1) {
		        line.write(buffer, 0, count);
		    }
		    line.drain();
		    line.stop();
		    line.close();
		} catch(Exception e) {
		    e.printStackTrace();
		}


这篇关于如何实现Text-to-Speech示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 03:00