1.将jacob.jar考到项目中进行构建路径。
2.将jacob-1.17-M2-x32.dll或者jacob-1.17-M2-x64.dll,考到系统盘:\Windows\System32\下面。
3.将jacob-1.17-M2-x32.dll或者jacob-1.17-M2-x64.dll,考到JDK安装目录的bin下面。
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("I am work")); } catch (Exception e) { e.printStackTrace(); } finally { sapo.safeRelease(); sap.safeRelease(); } }
标签:1.17,java,dll,jacob,语音,M2,字符串,new,sap
From: https://www.cnblogs.com/-xyk/p/16745927.html