import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class TTStest {
public static void main(String[] args){
ActiveXComponent sap = new ActiveXComponent("Sapi.SpVoice");
Dispatch sapo = sap.getObject();
try {
sap.setProperty("Volume", new Variant(100));
sap.setProperty("Rate", new Variant(-2));
Dispatch.call(sapo, "Speak", new Variant("Hi,Nice to meet you!"));
Dispatch.call(sapo, "Speak", new Variant("明天北京天气如何?"));
Dispatch.call(sapo, "Speak", new Variant("明天北京下雨吗?"));
System.out.println("end!!!");
} catch (Exception e) {
e.printStackTrace();
} finally {
sapo.safeRelease();
sap.safeRelease();
}
}
}
匹配jar包可以去此下载:http://download.csdn.net/detail/qitehuanjue/9635100