Java文本转语音

package com.xh.speak;

import java.io.IOException;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;

public class Speak {

	public static void main(String[] args) throws IOException {
	   
	    ActiveXComponent sap = new ActiveXComponent("Sapi.SpVoice");
	  
	    Dispatch sapo = sap.getObject();
	    try {

	        // 音量 0-100
	        sap.setProperty("Volume", new Variant(100));
	        // 语音朗读速度 -10 到 +10
	        sap.setProperty("Rate", new Variant(2));


	        // 执行朗读
	        Dispatch.call(sapo, "Speak", new Variant("汪**,你是个大傻逼"));

	    } catch (Exception e) {
	        e.printStackTrace();
	    } finally {
	        sapo.safeRelease();
	        sap.safeRelease();
	    }
	    }
}



需要用到jacob-1.17-M2.rar


原文:http://www.codeweblog.com/%E4%BD%BF%E7%94%A8java%E5%AE%9E%E7%8E%B0%E8%AF%AD%E9%9F%B3%E6%9C%97%E8%AF%BB%E4%B8%80%E6%AE%B5%E6%96%87%E6%9C%AC/






你可能感兴趣的:(java,java,文本转语音)