唤醒词的离线语音唤醒实现方案二 ubuntu 22.04

自定义修改唤醒词的离线语音唤醒实现方案二(ubuntu 22.04)

实现功能(离线唤醒):

  • 指定唤醒词可随时唤醒目标
  • 唤醒词可自定义修改
  • 本地修改唤醒词且不需要繁琐生成模型和代码
  • 源码后续上传 github 并更新

实验方案二:使用讯飞开放平台的 AIkit语音唤醒 Linux SDK

1. 讯飞开放平台的语音唤醒(新版)
2. 下载SDK
  • 使用的ubuntu 22.04,下载Linux AIKit

  • SDK 包下载(我只选择了语音唤醒一个包)
    在这里插入图片描述

3. SDK 修改编译

主函数在samples目录下:

$ tree samples/
samples/
├── ivw_record_sample
│   ├── build.sh
│   ├── ivw_record_sample.cpp		# 本次使用有文件唤醒和MIC唤醒
│   ├── linuxrec.c
│   ├── Makefile
│   ├── readme.txt
│   └── speech_recognizer.cpp
└── ivw_sample
    ├── build.sh
    ├── ivw_sample.cpp
    └── readme.txt
3.1 SDK初始化参数 (ivw_record_sample.cpp)
  • appID、apiKey、apiSecret 和 workDir 为必填项

在这里插入图片描述

AIKIT_Configurator::builder()
      .app()      
         .appID("")
         .apiKey("")
         .apiSecret("")
         .workDir("./")          //示例为当前路径
        .auth()
         .ability("e867a88f2")
        .log()  
         .logLevel(LOG_LVL_INFO)
         .logPath("./");
 
int ret = AIKIT_Init();
if(ret != 0){
    printf("AIKIT_Init failed:%d\n",ret);
    goto exit;
}
3.2 编译
  • ivw_record_sample

    $ cd samples
    make			# 直接编译
    $ cd ../bin		# bin目录下会生成一个同名可执行文件 ivw_record_sample
    $ export LD_LIBRARY_PATH=../libs:$LD_LIBRARY_PATH   # 环境变量
    $ ./ivw_record_sample	#运行
    

    按提示操作就可以运行了,但我觉得选来选去每次都麻烦,作了一些修改

3.3 自定义唤醒词
  • 自定义添加/修改唤醒词

    $ cd PATH/bin/resource
    $ vim many-keywords.txt			#直接按照里面格式进行添加,也可以自己创建 .txt 添加唤醒词
    # 例,添加‘你好老许’ : ‘ 你好老许;nCM:100; ‘
    $ cat many-keywords.txt 		# 也支持添加多个唤醒词
    你好老许;nCM:100;
    
4. 代码修改
4.1 特定唤醒词唤醒(当监测到 ‘你好老许’ 时唤醒并播放提示音)

指定唤醒词好处,可以使用特定唤醒词执行不同命令;坏处,每次添加唤醒词代码需要改动;

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "speech_recognizer.h"

#include "aikit_biz_api.h"
#include "aikit_constant.h"
#include "aikit_biz_config.h"

using namespace std;
using namespace AIKIT;
static const char *ABILITY = "e867a88f2";


void OnOutput(AIKIT_HANDLE* handle, const AIKIT_OutputData* output){
   
    printf("OnOutput abilityID :%s\n",handle->abilityID);
    printf("OnOutput key:%s\n",output
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值