freetts 实现中文代码
时间: 2024-05-10 19:17:49 浏览: 264
php调用Google translate_tts api实现代码
FreeTTS 是一个免费的文本到语音合成系统,支持多种语言,包括中文。下面是一份基于 FreeTTS 的中文示例代码:
```java
import java.io.IOException;
import java.util.Locale;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import com.sun.speech.freetts.AudioPlayer;
import com.sun.speech.freetts.FreeTTSEngineCentral;
import com.sun.speech.freetts.FreeTTSUtils;
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
public class FreeTTSChinese {
public static void main(String[] args) throws IOException, UnsupportedAudioFileException, LineUnavailableException {
// 设置中文语音引擎
System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_time_awb.AlarmClockVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_time_awb.AlarmClockVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_awb_arctic.ArcticVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory,"
+ "com.sun.speech.freetts.en
阅读全文