array(2) { ["docs"]=> array(10) { [0]=> array(10) { ["id"]=> string(3) "428" ["text"]=> string(77) "Visual Studio 2017 单独启动MSDN帮助(Microsoft Help Viewer)的方法" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(8) "DonetRen" ["tagsname"]=> string(55) "Visual Studio 2017|MSDN帮助|C#程序|.NET|Help Viewer" ["tagsid"]=> string(23) "[401,402,403,"300",404]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400964" ["_id"]=> string(3) "428" } [1]=> array(10) { ["id"]=> string(3) "427" ["text"]=> string(42) "npm -v;报错 cannot find module "wrapp"" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(4) "zzty" ["tagsname"]=> string(50) "node.js|npm|cannot find module "wrapp“|node" ["tagsid"]=> string(19) "[398,"239",399,400]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400760" ["_id"]=> string(3) "427" } [2]=> array(10) { ["id"]=> string(3) "426" ["text"]=> string(54) "说说css中pt、px、em、rem都扮演了什么角色" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(12) "zhengqiaoyin" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400640" ["_id"]=> string(3) "426" } [3]=> array(10) { ["id"]=> string(3) "425" ["text"]=> string(83) "深入学习JS执行--创建执行上下文(变量对象,作用域链,this)" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "Ry-yuan" ["tagsname"]=> string(33) "Javascript|Javascript执行过程" ["tagsid"]=> string(13) "["169","191"]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511399901" ["_id"]=> string(3) "425" } [4]=> array(10) { ["id"]=> string(3) "424" ["text"]=> string(30) "C# 排序技术研究与对比" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(9) "vveiliang" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(8) ".Net Dev" ["catesid"]=> string(5) "[199]" ["createtime"]=> string(10) "1511399150" ["_id"]=> string(3) "424" } [5]=> array(10) { ["id"]=> string(3) "423" ["text"]=> string(72) "【算法】小白的算法笔记:快速排序算法的编码和优化" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(9) "penghuwan" ["tagsname"]=> string(6) "算法" ["tagsid"]=> string(7) "["344"]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511398109" ["_id"]=> string(3) "423" } [6]=> array(10) { ["id"]=> string(3) "422" ["text"]=> string(64) "JavaScript数据可视化编程学习(二)Flotr2,雷达图" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "chengxs" ["tagsname"]=> string(28) "数据可视化|前端学习" ["tagsid"]=> string(9) "[396,397]" ["catesname"]=> string(18) "前端基本知识" ["catesid"]=> string(5) "[198]" ["createtime"]=> string(10) "1511397800" ["_id"]=> string(3) "422" } [7]=> array(10) { ["id"]=> string(3) "421" ["text"]=> string(36) "C#表达式目录树(Expression)" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(4) "wwym" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(4) ".NET" ["catesid"]=> string(7) "["119"]" ["createtime"]=> string(10) "1511397474" ["_id"]=> string(3) "421" } [8]=> array(10) { ["id"]=> string(3) "420" ["text"]=> string(47) "数据结构 队列_队列实例:事件处理" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "idreamo" ["tagsname"]=> string(40) "C语言|数据结构|队列|事件处理" ["tagsid"]=> string(23) "["246","247","248",395]" ["catesname"]=> string(12) "数据结构" ["catesid"]=> string(7) "["133"]" ["createtime"]=> string(10) "1511397279" ["_id"]=> string(3) "420" } [9]=> array(10) { ["id"]=> string(3) "419" ["text"]=> string(47) "久等了,博客园官方Android客户端发布" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(3) "cmt" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511396549" ["_id"]=> string(3) "419" } } ["count"]=> int(200) } 222 JAVA 实现语音播报 - 爱码网
kkxwze

准备工作:

下载jar包,链接:https://pan.baidu.com/s/1qXPgCzy 密码:xigv

解压jar包,将jacob.jar复制到工程目录,右键该文件→Build Path→Add to...

将jacob-1.17-M2-x86.dll添加到JDK的bin目录和Windows的system32目录(64位系统添加jacob-1.17-M2-x64.dll)

代码实现如下:

import com.jacob.activeX.ActiveXComponent;

import com.jacob.com.Dispatch;

import com.jacob.com.Variant;
 

public class Test04 {

public static void main(String[] args) {

ActiveXComponent sap = new ActiveXComponent("Sapi.SpVoice");

try {

// 音量 0-100

sap.setProperty("Volume", new Variant(100));

// 语音朗读速度 -10 到 +10

sap.setProperty("Rate", new Variant(-2));

// 获取执行对象

Dispatch sapo = sap.getObject();

// 执行朗读

Dispatch.call(sapo, "Speak", new Variant("你好,很高兴见到你。"));

// 关闭执行对象

sapo.safeRelease();

} catch (Exception e) {

e.printStackTrace();

} finally {

// 关闭应用程序连接

sap.safeRelease();

}

}

}

我们可以朗读文件内容,代码实现如下:

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.IOException;
 

import com.jacob.activeX.ActiveXComponent;

import com.jacob.com.Dispatch;

import com.jacob.com.Variant;
 

public class Test05 {

public static void main(String[] args) throws IOException {

ActiveXComponent sap = new ActiveXComponent("Sapi.SpVoice");

//输入文件

File srcFile = new File("E:/tmp/testvoice.txt");

//使用包装字符流读取文件

BufferedReader br = new BufferedReader(new FileReader(srcFile));

String content = br.readLine();

try {

// 音量 0-100

sap.setProperty("Volume", new Variant(100));

// 语音朗读速度 -10 到 +10

sap.setProperty("Rate", new Variant(-2));

// 获取执行对象

Dispatch sapo = sap.getObject();

// 执行朗读

while (content != null) {

Dispatch.call(sapo, "Speak", new Variant(content));

content = br.readLine();

}

// 关闭执行对象

sapo.safeRelease();

} catch (Exception e) {

e.printStackTrace();

} finally {

br.close();

// 关闭应用程序连接

sap.safeRelease();

}

}

}

出现的问题:

关于java使用jacob.jar调用word的配置问题
最近用到了jacob.jar来转换word文件,出现一些问题都是关于配置的,先将一些配置说明一下,以供大家参考。

文件下载地址,

https://pan.baidu.com/s/1Fd5d3dvJ8IGeqxuU-vcN3Q

jacob-1.17-M2-x64.dll放到C:\Windows\System32下面(64位)

jacob-1.17-M2-x86.dll 放到C:\Windows\SysWOW64下面(32位)
将jacob.dll拷贝至%JAVA_HOME%\jre\bin目录。

再把jacob.jar拷入lib下

重启完成

https://blog.csdn.net/qq_40864915/article/details/86573079


https://blog.csdn.net/qq_34137397/article/details/77814851

1.下载jacob.ja

2.32位操作系统下载:jacob-1.17-M2-x32.dll,64位操作系统下载:jacob-1.17-M2-x64.dll

3.将jacob.jar考到项目中进行构建路径。

4.将jacob-1.17-M2-x32.dll或者jacob-1.17-M2-x64.dll,考到系统盘:\Windows\System32\下面。

5.将jacob-1.17-M2-x32.dll或者jacob-1.17-M2-x64.dll,考到JDK安装目录的bin下面。

然后写个test方法测试一下即可,测试代码如下:

 /**  
* @Title: Voice.java
* @Package org.util
* @Description: TODO该方法的主要作用:
* @author A18ccms A18ccms_gmail_com  
* @date 2017-7-3 下午9:03:45
* @version V1.0  
*/
package cn.bdqn.bdqn.utils;
 
 
import org.junit.Test;
 
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
 
 /**   
 *    
 * 项目名称:avoice   
 * 类名称:Voice   
 * 类描述:   语音播报工具类
 * 创建人:Mu Xiongxiong  
 * 创建时间:2017-7-3 下午9:03:45   
 * 修改人:Mu Xiongxiong   
 * 修改时间:2017-7-3 下午9:03:45   
 * 修改备注:   
 * @version    
 *    
 */
public class Voice {
 
    /**
     * 
    * @Title: strat
    * @Description: 该方法的主要作用:朗读
    * @param  @param content
    * @param  @param type 设定文件   0:开始,1停止
    * @return  返回类型:void   
    * @throws
     */
    public void strat(String content, int type) {
        // ?? 这个Sapi.SpVoice是需要安装什么东西吗,感觉平白无故就来了
        ActiveXComponent sap = new ActiveXComponent("Sapi.SpVoice");
        // Dispatch是做什么的?
        Dispatch sapo = sap.getObject();
        
        if (type == 0) {
            try {
                // 音量 0-100
                sap.setProperty("Volume", new Variant(100));
                // 语音朗读速度 -10 到 +10
                sap.setProperty("Rate", new Variant(1.3));
                Variant defalutVoice = sap.getProperty("Voice");
 
                Dispatch dispdefaultVoice = defalutVoice.toDispatch();
                Variant allVoices = Dispatch.call(sapo, "GetVoices");
                Dispatch dispVoices = allVoices.toDispatch();
 
                Dispatch setvoice = Dispatch.call(dispVoices, "Item",
                        new Variant(1)).toDispatch();
                ActiveXComponent voiceActivex = new ActiveXComponent(
                        dispdefaultVoice);
                ActiveXComponent setvoiceActivex = new ActiveXComponent(
                        setvoice);
 
                Variant item = Dispatch.call(setvoiceActivex, "GetDescription");
                // 执行朗读
                Dispatch.call(sapo, "Speak", new Variant(content));
 
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                sapo.safeRelease();
                sap.safeRelease();
            }
        } else {
            // 停止
 
            try {
                Dispatch.call(sapo, "Speak", new Variant(content), new Variant(
                        2));
            } catch (Exception e) {
                System.out.println(e.getMessage());
                e.printStackTrace();
            }
        }
 
    }
    
    
    /**
     * 
    * @Title: test
    * @Description: 该方法的主要作用:执行朗读内容
    * @param   设定文件  
    * @return  返回类型:void   
    * @throws
     */
    @Test
    public void test()
    {
        strat("语音朗读的内容", 0);
    }
    
 
}

 

分类:

技术点:

相关文章: