diff --git a/doc/~$需求规格说明书.docx b/doc/~$需求规格说明书.docx new file mode 100644 index 0000000..3b9942f Binary files /dev/null and b/doc/~$需求规格说明书.docx differ diff --git a/doc/软件需求规格说明书.docx b/doc/软件需求规格说明书.docx new file mode 100644 index 0000000..4b2c4d6 Binary files /dev/null and b/doc/软件需求规格说明书.docx differ diff --git a/src/manage/img/11.jpg b/src/manage/img/11.jpg new file mode 100644 index 0000000..9c9247b Binary files /dev/null and b/src/manage/img/11.jpg differ diff --git a/src/manage/img/22.jpg b/src/manage/img/22.jpg new file mode 100644 index 0000000..6b63407 Binary files /dev/null and b/src/manage/img/22.jpg differ diff --git a/src/manage/itt/ReadMe b/src/manage/itt/ReadMe new file mode 100644 index 0000000..8f57aec --- /dev/null +++ b/src/manage/itt/ReadMe @@ -0,0 +1,2 @@ +主要实现每1s读取一次img目录中的图片,并且识别的图片中的文字会存储到txt目录中, +另外,txt目录中设置了当存储的备份文件即历史识别后结构仅仅保留最后1m以来做记录器。 diff --git a/src/manage/itt/wenzhi.py b/src/manage/itt/wenzhi.py new file mode 100644 index 0000000..fc7078f --- /dev/null +++ b/src/manage/itt/wenzhi.py @@ -0,0 +1,99 @@ +import pytesseract +from PIL import Image +import sys +import os +import time +import datetime + + +def ensure_directories(): + # 确保存储输出文本的目录存在 + output_dir = 'txt' + if not os.path.exists(output_dir): + os.makedirs(output_dir) + +def ensure_pytesseract_installed(): + try: + # 尝试导入pytesseract以确认它已安装 + import pytesseract + except ImportError: + print("pytesseract库未安装。请运行'pip install pytesseract'来安装它。") + sys.exit(1) + +def ensure_tesseract_executable_configured(): + try: + # 尝试获取Tesseract的路径以确认它已配置 + pytesseract.pytesseract.tesseract_cmd + except AttributeError: + print("未配置Tesseract可执行文件的路径。请在pytesseract中设置tesseract_cmd。") + sys.exit(1) + +def image_to_text(image_path): + try: + # 打开图像文件 + img = Image.open(image_path) + except IOError: + print(f"无法打开图像文件:{image_path}") + return None + + try: + # 使用pytesseract进行文字识别 + text = pytesseract.image_to_string(img, lang='eng') + except Exception as e: + print(f"文字识别过程中发生错误:{e}") + return None + + return text + +def main(): + # 确保pytesseract库已安装 + ensure_pytesseract_installed() + + # 确保配置了Tesseract可执行文件的路径 + ensure_tesseract_executable_configured() + + # 确保输出目录存在 + ensure_directories() + + # 设置输出目录路径 + output_dir_path = 'txt' + + + # 主循环,每3秒处理一张图片 + while True: + # 获取当前时间,并格式化为文件名 + current_time = datetime.datetime.now().strftime("%Y%m%d%H%M%S") + image_filename = f"{current_time}.jpg" + #image_path = os.path.join('img', image_filename) + image_path = 'img/22.jpg' + output_file_path = os.path.join(output_dir_path, f"{current_time}.txt") + + # 检查图片是否存在 + if not os.path.exists(image_path): + print(f"图片 {image_path} 不存在,等待下一张...") + time.sleep(1) + continue + + # 调用image_to_text函数并将结果写入文件 + text = image_to_text(image_path) + if text: + with open(output_file_path, 'w', encoding='utf-8') as file: + file.write(text) + print(f"图片 {image_filename} 的识别结果已保存到 {output_file_path}") + else: + print(f"无法识别图片 {image_filename} 中的文字。") + + # 检查txt文件夹中的文件数量,如果超过60个,删除最早的文件 + files = os.listdir(output_dir_path) + if len(files) > 60: + # 对文件进行排序,以便找到最早的文件 + files.sort() + oldest_file_path = os.path.join(output_dir_path, files[0]) + os.remove(oldest_file_path) + print(f"已删除最早的文件:{oldest_file_path}") + + # 等待1秒 + time.sleep(1) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src/manage/log.txt b/src/manage/log.txt new file mode 100644 index 0000000..3342b69 --- /dev/null +++ b/src/manage/log.txt @@ -0,0 +1,242 @@ +2024年 07月 01日 星期一 21:13:13 CST: wenzhi.py 被停止, PID: 29387 +2024年 07月 01日 星期一 21:13:13 CST: tts.py 运行失败,退出状态码 1, PID: 29405 +2024年 07月 01日 星期一 21:13:18 CST: wenzhi.py 被停止, PID: 29408 +2024年 07月 01日 星期一 21:13:18 CST: tts.py 运行失败,退出状态码 1, PID: 29435 +2024年 07月 01日 星期一 21:13:23 CST: wenzhi.py 被停止, PID: 29456 +2024年 07月 01日 星期一 21:13:23 CST: tts.py 运行失败,退出状态码 1, PID: 29474 +2024年 07月 01日 星期一 21:14:26 CST: wenzhi.py 被停止, PID: 29817 +2024年 07月 01日 星期一 21:14:26 CST: tts.py 运行失败,退出状态码 1, PID: 29835 +2024年 07月 01日 星期一 21:14:31 CST: wenzhi.py 被停止, PID: 29838 +2024年 07月 01日 星期一 21:14:31 CST: tts.py 运行失败,退出状态码 1, PID: 29865 +2024年 07月 01日 星期一 21:16:08 CST: wenzhi.py 被停止, PID: 30373 +2024年 07月 01日 星期一 21:16:08 CST: tts.py 运行失败,退出状态码 1, PID: 30391 +2024年 07月 01日 星期一 21:16:13 CST: wenzhi.py 被停止, PID: 30412 +2024年 07月 01日 星期一 21:16:13 CST: tts.py 运行失败,退出状态码 1, PID: 30466 +2024年 07月 01日 星期一 21:16:18 CST: wenzhi.py 被停止, PID: 30469 +2024年 07月 01日 星期一 21:16:18 CST: tts.py 运行失败,退出状态码 1, PID: 30550 +2024年 07月 01日 星期一 21:16:42 CST: wenzhi.py 被停止, PID: 30664 +2024年 07月 01日 星期一 21:16:42 CST: tts.py 运行失败,退出状态码 1, PID: 30691 +2024年 07月 01日 星期一 21:16:47 CST: wenzhi.py 被停止, PID: 30694 +2024年 07月 01日 星期一 21:16:47 CST: tts.py 运行失败,退出状态码 1, PID: 30721 +2024年 07月 01日 星期一 21:16:52 CST: wenzhi.py 被停止, PID: 30733 +2024年 07月 01日 星期一 21:16:52 CST: tts.py 运行失败,退出状态码 1, PID: 30769 +2024年 07月 01日 星期一 21:16:57 CST: wenzhi.py 被停止, PID: 30781 +2024年 07月 01日 星期一 21:16:57 CST: tts.py 运行失败,退出状态码 1, PID: 30835 +2024年 07月 01日 星期一 21:17:02 CST: wenzhi.py 被停止, PID: 30838 +2024年 07月 01日 星期一 21:17:02 CST: tts.py 运行失败,退出状态码 1, PID: 30895 +2024年 07月 01日 星期一 21:19:05 CST: wenzhi.py 被停止, PID: 31525 +2024年 07月 01日 星期一 21:19:05 CST: tts.py 运行失败,退出状态码 1, PID: 31543 +2024年 07月 01日 星期一 21:19:10 CST: wenzhi.py 被停止, PID: 31546 +2024年 07月 01日 星期一 21:19:10 CST: tts.py 运行失败,退出状态码 1, PID: 31573 +2024年 07月 01日 星期一 21:20:16 CST: wenzhi.py 被停止, PID: 31924 +2024年 07月 01日 星期一 21:20:17 CST: tts.py 运行失败,退出状态码 1, PID: 31960 +2024年 07月 01日 星期一 21:20:22 CST: wenzhi.py 被停止, PID: 31981 +2024年 07月 01日 星期一 21:20:22 CST: tts.py 运行失败,退出状态码 1, PID: 32008 +2024年 07月 01日 星期一 21:20:27 CST: wenzhi.py 被停止, PID: 32029 +2024年 07月 01日 星期一 21:20:27 CST: tts.py 运行失败,退出状态码 1, PID: 32056 +2024年 07月 01日 星期一 21:20:32 CST: wenzhi.py 被停止, PID: 32059 +2024年 07月 01日 星期一 21:20:32 CST: tts.py 运行失败,退出状态码 1, PID: 32086 +2024年 07月 01日 星期一 21:20:37 CST: wenzhi.py 被停止, PID: 32125 +2024年 07月 01日 星期一 21:20:37 CST: tts.py 运行失败,退出状态码 1, PID: 32161 +2024年 07月 01日 星期一 21:20:42 CST: wenzhi.py 被停止, PID: 32191 +2024年 07月 01日 星期一 21:20:42 CST: tts.py 运行失败,退出状态码 1, PID: 32264 +2024年 07月 01日 星期一 21:20:47 CST: wenzhi.py 被停止, PID: 32267 +2024年 07月 01日 星期一 21:20:47 CST: tts.py 运行失败,退出状态码 1, PID: 32303 +2024年 07月 01日 星期一 21:20:52 CST: wenzhi.py 被停止, PID: 32306 +2024年 07月 01日 星期一 21:20:52 CST: tts.py 运行失败,退出状态码 1, PID: 32351 +2024年 07月 01日 星期一 21:20:57 CST: wenzhi.py 被停止, PID: 32354 +2024年 07月 01日 星期一 21:20:57 CST: tts.py 运行失败,退出状态码 1, PID: 32426 +2024年 07月 01日 星期一 23:05:26 CST: wenzhi.py 被停止, PID: 8301 +2024年 07月 01日 星期一 23:05:26 CST: tts.py 运行失败,退出状态码 1, PID: 8318 +2024年 07月 01日 星期一 23:05:28 CST: wenzhi.py 被停止, PID: 8322 +2024年 07月 01日 星期一 23:05:28 CST: tts.py 运行失败,退出状态码 1, PID: 8339 +2024年 07月 01日 星期一 23:05:30 CST: wenzhi.py 被停止, PID: 8352 +2024年 07月 01日 星期一 23:05:30 CST: tts.py 运行失败,退出状态码 1, PID: 8369 +2024年 07月 01日 星期一 23:05:32 CST: wenzhi.py 被停止, PID: 8373 +2024年 07月 01日 星期一 23:05:32 CST: tts.py 运行失败,退出状态码 1, PID: 8400 +2024年 07月 01日 星期一 23:05:34 CST: wenzhi.py 被停止, PID: 8422 +2024年 07月 01日 星期一 23:05:34 CST: tts.py 运行失败,退出状态码 1, PID: 8448 +2024年 07月 01日 星期一 23:09:24 CST: wenzhi.py 被停止, PID: 10042 +2024年 07月 01日 星期一 23:09:24 CST: tts.py 运行失败,退出状态码 1, PID: 10069 +2024年 07月 01日 星期一 23:09:26 CST: wenzhi.py 被停止, PID: 10073 +2024年 07月 01日 星期一 23:09:27 CST: tts.py 运行失败,退出状态码 1, PID: 10090 +2024年 07月 01日 星期一 23:09:29 CST: wenzhi.py 被停止, PID: 10121 +2024年 07月 01日 星期一 23:09:29 CST: tts.py 运行失败,退出状态码 1, PID: 10129 +2024年 07月 01日 星期一 23:09:31 CST: wenzhi.py 被停止, PID: 10178 +2024年 07月 01日 星期一 23:09:31 CST: tts.py 运行失败,退出状态码 1, PID: 10195 +2024年 07月 01日 星期一 23:09:33 CST: wenzhi.py 被停止, PID: 10208 +2024年 07月 01日 星期一 23:09:33 CST: tts.py 运行失败,退出状态码 1, PID: 10225 +2024年 07月 01日 星期一 23:09:35 CST: wenzhi.py 被停止, PID: 10229 +2024年 07月 01日 星期一 23:09:35 CST: tts.py 运行失败,退出状态码 1, PID: 10237 +2024年 07月 01日 星期一 23:09:37 CST: wenzhi.py 被停止, PID: 10241 +2024年 07月 01日 星期一 23:09:37 CST: tts.py 运行失败,退出状态码 1, PID: 10249 +2024年 07月 01日 星期一 23:09:39 CST: wenzhi.py 被停止, PID: 10289 +2024年 07月 01日 星期一 23:09:39 CST: tts.py 运行失败,退出状态码 1, PID: 10306 +2024年 07月 01日 星期一 23:09:41 CST: wenzhi.py 被停止, PID: 10310 +2024年 07月 01日 星期一 23:09:41 CST: tts.py 运行失败,退出状态码 1, PID: 10327 +2024年 07月 01日 星期一 23:09:43 CST: wenzhi.py 被停止, PID: 10340 +2024年 07月 01日 星期一 23:09:43 CST: tts.py 运行失败,退出状态码 1, PID: 10357 +2024年 07月 01日 星期一 23:09:45 CST: wenzhi.py 被停止, PID: 10379 +2024年 07月 01日 星期一 23:09:45 CST: tts.py 运行失败,退出状态码 1, PID: 10396 +2024年 07月 01日 星期一 23:13:21 CST: wenzhi.py 被停止, PID: 11686 +2024年 07月 01日 星期一 23:13:21 CST: tts.py 运行成功, PID: 11694 +2024年 07月 01日 星期一 23:13:23 CST: wenzhi.py 被停止, PID: 11698 +2024年 07月 01日 星期一 23:13:23 CST: tts.py 运行成功, PID: 11733 +2024年 07月 01日 星期一 23:14:23 CST: wenzhi.py 被停止, PID: 12133 +2024年 07月 01日 星期一 23:14:23 CST: tts.py 运行成功, PID: 12141 +2024年 07月 01日 星期一 23:14:25 CST: wenzhi.py 被停止, PID: 12154 +2024年 07月 01日 星期一 23:14:25 CST: tts.py 运行成功, PID: 12180 +2024年 07月 01日 星期一 23:16:13 CST: wenzhi.py 被停止, PID: 12910 +2024年 07月 01日 星期一 23:16:13 CST: tts.py 运行成功, PID: 12918 +2024年 07月 01日 星期一 23:16:15 CST: wenzhi.py 被停止, PID: 12940 +2024年 07月 01日 星期一 23:16:15 CST: tts.py 运行成功, PID: 12957 +2024年 07月 01日 星期一 23:16:17 CST: wenzhi.py 被停止, PID: 12961 +2024年 07月 01日 星期一 23:16:17 CST: tts.py 运行成功, PID: 12978 +2024年 07月 01日 星期一 23:16:19 CST: wenzhi.py 被停止, PID: 12982 +2024年 07月 01日 星期一 23:16:19 CST: tts.py 运行成功, PID: 12990 +2024年 07月 01日 星期一 23:16:21 CST: wenzhi.py 被停止, PID: 12994 +2024年 07月 01日 星期一 23:16:21 CST: tts.py 运行成功, PID: 13002 +2024年 07月 01日 星期一 23:16:23 CST: wenzhi.py 被停止, PID: 13024 +2024年 07月 01日 星期一 23:16:23 CST: tts.py 运行成功, PID: 13041 +2024年 07月 01日 星期一 23:16:25 CST: wenzhi.py 被停止, PID: 13054 +2024年 07月 01日 星期一 23:16:25 CST: tts.py 运行成功, PID: 13062 +2024年 07月 01日 星期一 23:16:27 CST: wenzhi.py 被停止, PID: 13075 +2024年 07月 01日 星期一 23:16:27 CST: tts.py 运行成功, PID: 13083 +2024年 07月 01日 星期一 23:17:10 CST: wenzhi.py 被停止, PID: 13388 +2024年 07月 01日 星期一 23:17:10 CST: tts.py 运行成功, PID: 13396 +2024年 07月 01日 星期一 23:17:12 CST: wenzhi.py 被停止, PID: 13400 +2024年 07月 01日 星期一 23:17:12 CST: tts.py 运行成功, PID: 13408 +2024年 07月 01日 星期一 23:17:23 CST: wenzhi.py 被停止, PID: 13502 +2024年 07月 01日 星期一 23:17:23 CST: tts.py 运行成功, PID: 13510 +2024年 07月 01日 星期一 23:17:25 CST: wenzhi.py 被停止, PID: 13514 +2024年 07月 01日 星期一 23:17:25 CST: tts.py 运行成功, PID: 13522 +2024年 07月 01日 星期一 23:17:27 CST: wenzhi.py 被停止, PID: 13526 +2024年 07月 01日 星期一 23:17:27 CST: tts.py 运行成功, PID: 13534 +2024年 07月 01日 星期一 23:17:59 CST: wenzhi.py 被停止, PID: 13762 +2024年 07月 01日 星期一 23:17:59 CST: tts.py 运行失败,退出状态码 1, PID: 13779 +2024年 07月 01日 星期一 23:18:01 CST: wenzhi.py 被停止, PID: 13783 +2024年 07月 01日 星期一 23:18:01 CST: tts.py 运行失败,退出状态码 1, PID: 13791 +2024年 07月 01日 星期一 23:18:03 CST: wenzhi.py 被停止, PID: 13795 +2024年 07月 01日 星期一 23:18:03 CST: tts.py 运行失败,退出状态码 1, PID: 13821 +2024年 07月 01日 星期一 23:18:05 CST: wenzhi.py 被停止, PID: 13825 +2024年 07月 01日 星期一 23:18:05 CST: tts.py 运行失败,退出状态码 1, PID: 13833 +2024年 07月 01日 星期一 23:18:07 CST: wenzhi.py 被停止, PID: 13837 +2024年 07月 01日 星期一 23:18:07 CST: tts.py 运行失败,退出状态码 1, PID: 13854 +2024年 07月 01日 星期一 23:18:09 CST: wenzhi.py 被停止, PID: 13867 +2024年 07月 01日 星期一 23:18:09 CST: tts.py 运行失败,退出状态码 1, PID: 13875 +2024年 07月 01日 星期一 23:18:11 CST: wenzhi.py 被停止, PID: 13879 +2024年 07月 01日 星期一 23:18:11 CST: tts.py 运行失败,退出状态码 1, PID: 13887 +2024年 07月 01日 星期一 23:18:13 CST: wenzhi.py 被停止, PID: 13891 +2024年 07月 01日 星期一 23:18:13 CST: tts.py 运行失败,退出状态码 1, PID: 13899 +2024年 07月 01日 星期一 23:18:15 CST: wenzhi.py 被停止, PID: 13903 +2024年 07月 01日 星期一 23:18:15 CST: tts.py 运行失败,退出状态码 1, PID: 13911 +2024年 07月 01日 星期一 23:18:17 CST: wenzhi.py 被停止, PID: 13915 +2024年 07月 01日 星期一 23:18:18 CST: tts.py 运行失败,退出状态码 1, PID: 13923 +2024年 07月 01日 星期一 23:18:20 CST: wenzhi.py 被停止, PID: 13927 +2024年 07月 01日 星期一 23:18:20 CST: tts.py 运行失败,退出状态码 1, PID: 13935 +2024年 07月 01日 星期一 23:18:22 CST: wenzhi.py 被停止, PID: 13939 +2024年 07月 01日 星期一 23:18:22 CST: tts.py 运行失败,退出状态码 1, PID: 13947 +2024年 07月 01日 星期一 23:18:24 CST: wenzhi.py 被停止, PID: 13960 +2024年 07月 01日 星期一 23:18:24 CST: tts.py 运行失败,退出状态码 1, PID: 13968 +2024年 07月 01日 星期一 23:18:26 CST: wenzhi.py 被停止, PID: 13972 +2024年 07月 01日 星期一 23:18:26 CST: tts.py 运行失败,退出状态码 1, PID: 13980 +2024年 07月 01日 星期一 23:18:28 CST: wenzhi.py 被停止, PID: 13984 +2024年 07月 01日 星期一 23:18:28 CST: tts.py 运行失败,退出状态码 1, PID: 13992 +2024年 07月 01日 星期一 23:18:30 CST: wenzhi.py 被停止, PID: 13996 +2024年 07月 01日 星期一 23:18:30 CST: tts.py 运行失败,退出状态码 1, PID: 14004 +2024年 07月 01日 星期一 23:18:32 CST: wenzhi.py 被停止, PID: 14017 +2024年 07月 01日 星期一 23:18:32 CST: tts.py 运行失败,退出状态码 1, PID: 14025 +2024年 07月 01日 星期一 23:18:34 CST: wenzhi.py 被停止, PID: 14029 +2024年 07月 01日 星期一 23:18:34 CST: tts.py 运行失败,退出状态码 1, PID: 14046 +2024年 07月 01日 星期一 23:18:36 CST: wenzhi.py 被停止, PID: 14050 +2024年 07月 01日 星期一 23:18:36 CST: tts.py 运行失败,退出状态码 1, PID: 14076 +2024年 07月 01日 星期一 23:18:38 CST: wenzhi.py 被停止, PID: 14080 +2024年 07月 01日 星期一 23:18:38 CST: tts.py 运行失败,退出状态码 1, PID: 14088 +2024年 07月 01日 星期一 23:18:40 CST: wenzhi.py 被停止, PID: 14092 +2024年 07月 01日 星期一 23:18:40 CST: tts.py 运行失败,退出状态码 1, PID: 14109 +2024年 07月 01日 星期一 23:18:42 CST: wenzhi.py 被停止, PID: 14113 +2024年 07月 01日 星期一 23:18:42 CST: tts.py 运行失败,退出状态码 1, PID: 14130 +2024年 07月 01日 星期一 23:18:44 CST: wenzhi.py 被停止, PID: 14134 +2024年 07月 01日 星期一 23:18:44 CST: tts.py 运行失败,退出状态码 1, PID: 14142 +2024年 07月 01日 星期一 23:18:46 CST: wenzhi.py 被停止, PID: 14146 +2024年 07月 01日 星期一 23:18:46 CST: tts.py 运行失败,退出状态码 1, PID: 14154 +2024年 07月 01日 星期一 23:18:48 CST: wenzhi.py 被停止, PID: 14167 +2024年 07月 01日 星期一 23:18:48 CST: tts.py 运行失败,退出状态码 1, PID: 14184 +2024年 07月 01日 星期一 23:18:50 CST: wenzhi.py 被停止, PID: 14197 +2024年 07月 01日 星期一 23:18:50 CST: tts.py 运行失败,退出状态码 1, PID: 14223 +2024年 07月 01日 星期一 23:18:52 CST: wenzhi.py 被停止, PID: 14227 +2024年 07月 01日 星期一 23:18:52 CST: tts.py 运行失败,退出状态码 1, PID: 14235 +2024年 07月 01日 星期一 23:18:54 CST: wenzhi.py 被停止, PID: 14248 +2024年 07月 01日 星期一 23:18:54 CST: tts.py 运行失败,退出状态码 1, PID: 14282 +2024年 07月 01日 星期一 23:18:56 CST: wenzhi.py 被停止, PID: 14296 +2024年 07月 01日 星期一 23:18:56 CST: tts.py 运行失败,退出状态码 1, PID: 14313 +2024年 07月 01日 星期一 23:18:58 CST: wenzhi.py 被停止, PID: 14334 +2024年 07月 01日 星期一 23:18:58 CST: tts.py 运行失败,退出状态码 1, PID: 14361 +2024年 07月 01日 星期一 23:19:00 CST: wenzhi.py 被停止, PID: 14374 +2024年 07月 01日 星期一 23:19:00 CST: tts.py 运行失败,退出状态码 1, PID: 14391 +2024年 07月 01日 星期一 23:19:02 CST: wenzhi.py 被停止, PID: 14395 +2024年 07月 01日 星期一 23:19:02 CST: tts.py 运行失败,退出状态码 1, PID: 14403 +2024年 07月 01日 星期一 23:19:04 CST: wenzhi.py 被停止, PID: 14425 +2024年 07月 01日 星期一 23:19:04 CST: tts.py 运行失败,退出状态码 1, PID: 14433 +2024年 07月 01日 星期一 23:19:06 CST: wenzhi.py 被停止, PID: 14446 +2024年 07月 01日 星期一 23:19:07 CST: tts.py 运行失败,退出状态码 1, PID: 14463 +2024年 07月 01日 星期一 23:19:09 CST: wenzhi.py 被停止, PID: 14485 +2024年 07月 01日 星期一 23:19:09 CST: tts.py 运行失败,退出状态码 1, PID: 14502 +2024年 07月 01日 星期一 23:19:11 CST: wenzhi.py 被停止, PID: 14515 +2024年 07月 01日 星期一 23:19:11 CST: tts.py 运行失败,退出状态码 1, PID: 14532 +2024年 07月 01日 星期一 23:19:13 CST: wenzhi.py 被停止, PID: 14536 +2024年 07月 01日 星期一 23:19:13 CST: tts.py 运行失败,退出状态码 1, PID: 14544 +2024年 07月 01日 星期一 23:19:15 CST: wenzhi.py 被停止, PID: 14548 +2024年 07月 01日 星期一 23:19:15 CST: tts.py 运行失败,退出状态码 1, PID: 14574 +2024年 07月 01日 星期一 23:19:17 CST: wenzhi.py 被停止, PID: 14578 +2024年 07月 01日 星期一 23:19:17 CST: tts.py 运行失败,退出状态码 1, PID: 14586 +2024年 07月 01日 星期一 23:19:19 CST: wenzhi.py 被停止, PID: 14599 +2024年 07月 01日 星期一 23:19:19 CST: tts.py 运行失败,退出状态码 1, PID: 14616 +2024年 07月 01日 星期一 23:19:21 CST: wenzhi.py 被停止, PID: 14620 +2024年 07月 01日 星期一 23:19:21 CST: tts.py 运行失败,退出状态码 1, PID: 14646 +2024年 07月 01日 星期一 23:19:23 CST: wenzhi.py 被停止, PID: 14650 +2024年 07月 01日 星期一 23:19:23 CST: tts.py 运行失败,退出状态码 1, PID: 14658 +2024年 07月 01日 星期一 23:19:25 CST: wenzhi.py 被停止, PID: 14671 +2024年 07月 01日 星期一 23:19:25 CST: tts.py 运行失败,退出状态码 1, PID: 14679 +2024年 07月 01日 星期一 23:19:27 CST: wenzhi.py 被停止, PID: 14692 +2024年 07月 01日 星期一 23:19:27 CST: tts.py 运行失败,退出状态码 1, PID: 14709 +2024年 07月 01日 星期一 23:19:29 CST: wenzhi.py 被停止, PID: 14713 +2024年 07月 01日 星期一 23:19:29 CST: tts.py 运行失败,退出状态码 1, PID: 14721 +2024年 07月 01日 星期一 23:19:31 CST: wenzhi.py 被停止, PID: 14735 +2024年 07月 01日 星期一 23:19:31 CST: tts.py 运行失败,退出状态码 1, PID: 14743 +2024年 07月 01日 星期一 23:19:33 CST: wenzhi.py 被停止, PID: 14756 +2024年 07月 01日 星期一 23:19:33 CST: tts.py 运行失败,退出状态码 1, PID: 14773 +2024年 07月 01日 星期一 23:19:35 CST: wenzhi.py 被停止, PID: 14777 +2024年 07月 01日 星期一 23:19:35 CST: tts.py 运行失败,退出状态码 1, PID: 14785 +2024年 07月 01日 星期一 23:19:37 CST: wenzhi.py 被停止, PID: 14798 +2024年 07月 01日 星期一 23:19:37 CST: tts.py 运行失败,退出状态码 1, PID: 14815 +2024年 07月 01日 星期一 23:19:39 CST: wenzhi.py 被停止, PID: 14819 +2024年 07月 01日 星期一 23:19:39 CST: tts.py 运行失败,退出状态码 1, PID: 14836 +2024年 07月 01日 星期一 23:19:41 CST: wenzhi.py 被停止, PID: 14840 +2024年 07月 01日 星期一 23:19:41 CST: tts.py 运行失败,退出状态码 1, PID: 14848 +2024年 07月 01日 星期一 23:19:43 CST: wenzhi.py 被停止, PID: 14852 +2024年 07月 01日 星期一 23:19:43 CST: tts.py 运行失败,退出状态码 1, PID: 14860 +2024年 07月 01日 星期一 23:19:45 CST: wenzhi.py 被停止, PID: 14864 +2024年 07月 01日 星期一 23:19:45 CST: tts.py 运行失败,退出状态码 1, PID: 14872 +2024年 07月 01日 星期一 23:19:47 CST: wenzhi.py 被停止, PID: 14885 +2024年 07月 01日 星期一 23:19:47 CST: tts.py 运行失败,退出状态码 1, PID: 14893 +2024年 07月 01日 星期一 23:19:49 CST: wenzhi.py 被停止, PID: 14897 +2024年 07月 01日 星期一 23:19:49 CST: tts.py 运行失败,退出状态码 1, PID: 14905 +2024年 07月 01日 星期一 23:19:51 CST: wenzhi.py 被停止, PID: 14909 +2024年 07月 01日 星期一 23:19:51 CST: tts.py 运行失败,退出状态码 1, PID: 14926 +2024年 07月 01日 星期一 23:19:53 CST: wenzhi.py 被停止, PID: 14948 +2024年 07月 01日 星期一 23:19:53 CST: tts.py 运行失败,退出状态码 1, PID: 14956 +2024年 07月 01日 星期一 23:19:55 CST: wenzhi.py 被停止, PID: 14969 +2024年 07月 01日 星期一 23:19:55 CST: tts.py 运行失败,退出状态码 1, PID: 14977 +2024年 07月 01日 星期一 23:19:58 CST: wenzhi.py 被停止, PID: 14981 +2024年 07月 01日 星期一 23:19:58 CST: tts.py 运行失败,退出状态码 1, PID: 15007 +2024年 07月 01日 星期一 23:20:00 CST: wenzhi.py 被停止, PID: 15020 +2024年 07月 01日 星期一 23:20:00 CST: tts.py 运行失败,退出状态码 1, PID: 15037 +2024年 07月 01日 星期一 23:20:02 CST: wenzhi.py 被停止, PID: 15041 +2024年 07月 01日 星期一 23:20:02 CST: tts.py 运行失败,退出状态码 1, PID: 15049 +2024年 07月 01日 星期一 23:20:04 CST: wenzhi.py 被停止, PID: 15053 +2024年 07月 01日 星期一 23:20:04 CST: tts.py 运行失败,退出状态码 1, PID: 15061 +2024年 07月 01日 星期一 23:20:06 CST: wenzhi.py 被停止, PID: 15067 +2024年 07月 01日 星期一 23:20:06 CST: tts.py 运行失败,退出状态码 1, PID: 15075 +2024年 07月 01日 星期一 23:20:08 CST: wenzhi.py 被停止, PID: 15079 +2024年 07月 01日 星期一 23:20:08 CST: tts.py 运行失败,退出状态码 1, PID: 15105 diff --git a/src/manage/repted.sh b/src/manage/repted.sh new file mode 100644 index 0000000..724dae8 --- /dev/null +++ b/src/manage/repted.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# repted.sh +while true; do + # 在后台运行itt目录中的wenzhi.py脚本并获取其PID + python3 itt/wenzhi.py & + wenzhi_pid=$! + + # 等待一段时间,让wenzhi.py开始执行 + sleep 1 + + # 检查wenzhi.py是否还在运行 + if kill -0 $wenzhi_pid 2>/dev/null; then + # wenzhi.py仍在运行,尝试停止它 + kill $wenzhi_pid + wait $wenzhi_pid + echo "$(date): wenzhi.py 被停止, PID: $wenzhi_pid" >> log.txt + else + # wenzhi.py已经停止,记录日志 + echo "$(date): wenzhi.py 已经停止, PID: $wenzhi_pid" >> log.txt + fi + + # 在后台运行tts目录中的tts.py脚本并获取其PID + python3 tts/tts.py & + tts_pid=$! + + # 等待tts.py脚本结束以获取其退出状态 + wait $tts_pid + tts_exit_status=$? + + # 检查tts.py脚本是否成功运行 + if [ $tts_exit_status -eq 0 ]; then + echo "$(date): tts.py 运行成功, PID: $tts_pid" >> log.txt + else + echo "$(date): tts.py 运行失败,退出状态码 $tts_exit_status, PID: $tts_pid" >> log.txt + fi + + # 等待一段时间后再重复这个过程 + sleep 1 +done diff --git a/src/manage/tts/trans.py b/src/manage/tts/trans.py new file mode 100644 index 0000000..b926776 --- /dev/null +++ b/src/manage/tts/trans.py @@ -0,0 +1,69 @@ +import numpy as np +from sklearn.model_selection import train_test_split +from sklearn.preprocessing import OneHotEncoder +from keras.models import Sequential +from keras.layers import Dense, Embedding, Flatten +from keras.preprocessing.sequence import pad_sequences +from keras.utils import to_categorical +import re + +# 文本清洗函数 +def clean_text(text): + # 使用正则表达式去除非标准字符 + cleaned_text = re.sub(r'[^a-zA-Z0-9\s]', '', text.lower()) + return cleaned_text + +# 读取文本文件 +def read_text_file(file_path): + with open(file_path, 'r', encoding='utf-8') as f: + return f.read() + +# 数据准备 +def prepare_data(text, max_sequence_length=10): + words = set(clean_text(text).split()) + word2index = {word: i for i, word in enumerate(words, 1)} + index2word = {i: word for word, i in word2index.items()} + + sentences = text.split('. ') + X, y = [], [] + for sentence in sentences: + cleaned_sentence = clean_text(sentence) + tokens = [word2index[word] for word in cleaned_sentence.split() if word in word2index] + for i in range(1, len(tokens)): + X.append(tokens[:-i]) + y.append(tokens[i]) + + # 使用pad_sequences处理变长序列 + X = pad_sequences(X, maxlen=max_sequence_length, padding='pre', truncating='post') + y = to_categorical(np.array(y), num_classes=len(word2index)) + return X, y, word2index, index2word + +# 读取文本文件并准备数据 +text = read_text_file('input.txt') # 假设输入文件名为input.txt +X, y, word2index, index2word = prepare_data(text) + +# 划分训练集和测试集 +X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) + +# 构建NNLM模型(这里使用Embedding层来捕获词汇之间的相似性) +model = Sequential() +model.add(Embedding(input_dim=len(word2index) + 1, output_dim=32, input_length=max_sequence_length)) +model.add(Flatten()) +model.add(Dense(128, activation='relu')) +model.add(Dense(len(word2index), activation='softmax')) + +model.compile(optimizer='adam', loss='categorical_crossentropy') + +# 训练模型 +model.fit(np.array([x for x in X_train]), y_train, epochs=10, batch_size=32) + +# 预测 +predictions = model.predict([x for x in X_test]) +predicted_words = [np.argmax(pred) for pred in predictions] +predicted_sentences = [' '.join(index2word[word] for word in [sentence[0]] + [predicted_words[i] for i, _ in enumerate(sentence[1:]) if i < len(predicted_words)]) + for sentence in X_test] + +# 将预测结果写入文本文件 +with open('output.txt', 'w', encoding='utf-8') as f: + for sentence in predicted_sentences: + f.write(sentence + '\n') \ No newline at end of file diff --git a/src/manage/tts/tts.py b/src/manage/tts/tts.py new file mode 100644 index 0000000..8ae8441 --- /dev/null +++ b/src/manage/tts/tts.py @@ -0,0 +1,76 @@ +import subprocess +import os +import datetime +from datetime import timedelta +import re + +def speak_text_from_file(file_path, voice='zh', speed=150, pitch=50, output_file=None): + """ + 从文件中读取文本并使用espeak将其转换为语音。 + + :param file_path: 文本文件的路径 + :param voice: 使用的声音(例如 'zh' 用于中文) + :param speed: 语速(默认为 150) + :param pitch: 音调(默认为 50) + :param output_file: 如果指定,将语音输出保存为WAV文件 + """ + with open(file_path, 'r', encoding='utf-8') as file: + text = file.read() + + # 构建espeak命令 + cmd = ['espeak', '-v', voice, '-s', str(speed), '-p', str(pitch)] + if output_file: + cmd.extend(['-w', output_file]) + else: + # 如果没有指定输出文件,则直接播放语音 + pass # 这里可以添加其他选项,如音量调整等 + + # 使用stdin将文本传递给espeak + try: + proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') + proc.communicate(input=text) + + if proc.returncode != 0: + # 获取并打印错误信息 + error_message = proc.stderr.read() + print(f"Error executing espeak: {error_message}") + except Exception as e: + print(f"An error occurred: {e}") + +# 获取当前文件夹路径 +current_dir = os.getcwd() + +# 获取父文件夹路径 +parent_dir = os.path.dirname(current_dir) + +specific_folder_name = "txt" + +specific_folder_path = os.path.join(current_dir, specific_folder_name) + +# 列出当前文件夹中的所有txt文件 +txt_files = [f for f in os.listdir(specific_folder_path) if f.endswith('.txt')] + +# 提取文件名中的数字,并找出最大的数字 +max_number = -1 +max_file = None +for txt_file in txt_files: + # 使用正则表达式提取文件名中的数字 + match = re.search(r'^(\d+)\.txt$', txt_file) + if match: + file_number = int(match.group(1)) + if file_number > max_number: + max_number = file_number + max_file = txt_file + +# 检查是否找到了数字命名最大的txt文件 +if max_file: + file_path = os.path.join(current_dir, max_file) + # 调用函数来朗读文本文件 + speak_text_from_file(file_path, voice='zh', speed=140, pitch=55) + + # 如果你想要将语音保存为WAV文件,可以这样做: + output_wav_file = 'output/output.wav' # WAV文件的输出路径 + speak_text_from_file(file_path, voice='zh', speed=140, pitch=55, output_file=output_wav_file) +else: + print("没有找到数字命名最大的txt文件。") + print(specific_folder_path) \ No newline at end of file diff --git a/src/manage/txt/20240701231806.txt b/src/manage/txt/20240701231806.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231806.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231808.txt b/src/manage/txt/20240701231808.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231808.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231810.txt b/src/manage/txt/20240701231810.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231810.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231813.txt b/src/manage/txt/20240701231813.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231813.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231815.txt b/src/manage/txt/20240701231815.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231815.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231817.txt b/src/manage/txt/20240701231817.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231817.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231819.txt b/src/manage/txt/20240701231819.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231819.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231821.txt b/src/manage/txt/20240701231821.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231821.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231823.txt b/src/manage/txt/20240701231823.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231823.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231825.txt b/src/manage/txt/20240701231825.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231825.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231827.txt b/src/manage/txt/20240701231827.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231827.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231829.txt b/src/manage/txt/20240701231829.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231829.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231831.txt b/src/manage/txt/20240701231831.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231831.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231833.txt b/src/manage/txt/20240701231833.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231833.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231835.txt b/src/manage/txt/20240701231835.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231835.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231837.txt b/src/manage/txt/20240701231837.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231837.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231839.txt b/src/manage/txt/20240701231839.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231839.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231841.txt b/src/manage/txt/20240701231841.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231841.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231843.txt b/src/manage/txt/20240701231843.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231843.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231845.txt b/src/manage/txt/20240701231845.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231845.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231847.txt b/src/manage/txt/20240701231847.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231847.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231849.txt b/src/manage/txt/20240701231849.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231849.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231851.txt b/src/manage/txt/20240701231851.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231851.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231853.txt b/src/manage/txt/20240701231853.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231853.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231855.txt b/src/manage/txt/20240701231855.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231855.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231857.txt b/src/manage/txt/20240701231857.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231857.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231859.txt b/src/manage/txt/20240701231859.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231859.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231901.txt b/src/manage/txt/20240701231901.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231901.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231904.txt b/src/manage/txt/20240701231904.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231904.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231906.txt b/src/manage/txt/20240701231906.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231906.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231908.txt b/src/manage/txt/20240701231908.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231908.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231910.txt b/src/manage/txt/20240701231910.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231910.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231912.txt b/src/manage/txt/20240701231912.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231912.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231914.txt b/src/manage/txt/20240701231914.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231914.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231916.txt b/src/manage/txt/20240701231916.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231916.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231918.txt b/src/manage/txt/20240701231918.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231918.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231920.txt b/src/manage/txt/20240701231920.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231920.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231922.txt b/src/manage/txt/20240701231922.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231922.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231924.txt b/src/manage/txt/20240701231924.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231924.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231926.txt b/src/manage/txt/20240701231926.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231926.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231928.txt b/src/manage/txt/20240701231928.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231928.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231930.txt b/src/manage/txt/20240701231930.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231930.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231932.txt b/src/manage/txt/20240701231932.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231932.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231934.txt b/src/manage/txt/20240701231934.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231934.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231936.txt b/src/manage/txt/20240701231936.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231936.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231938.txt b/src/manage/txt/20240701231938.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231938.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231940.txt b/src/manage/txt/20240701231940.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231940.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231942.txt b/src/manage/txt/20240701231942.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231942.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231944.txt b/src/manage/txt/20240701231944.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231944.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231946.txt b/src/manage/txt/20240701231946.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231946.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231948.txt b/src/manage/txt/20240701231948.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231948.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231951.txt b/src/manage/txt/20240701231951.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231951.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231953.txt b/src/manage/txt/20240701231953.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231953.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231955.txt b/src/manage/txt/20240701231955.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231955.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231957.txt b/src/manage/txt/20240701231957.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231957.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701231959.txt b/src/manage/txt/20240701231959.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701231959.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701232001.txt b/src/manage/txt/20240701232001.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701232001.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701232003.txt b/src/manage/txt/20240701232003.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701232003.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701232005.txt b/src/manage/txt/20240701232005.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701232005.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/manage/txt/20240701232007.txt b/src/manage/txt/20240701232007.txt new file mode 100644 index 0000000..b7bd227 --- /dev/null +++ b/src/manage/txt/20240701232007.txt @@ -0,0 +1,4 @@ +English + +X is + \ No newline at end of file diff --git a/src/sdk/README.md b/src/sdk/README.md deleted file mode 100644 index 0f19198..0000000 --- a/src/sdk/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# asr-linux-cpp-demo -## 简介 - -Linux C++ SDK 仅有在线长语音功能,包含在线语义。没有任何离线功能。 - - - -- 仅支持x64 linux 操作系统, g++ 4.8 以上版本 - -在centos 4 6 7 及ubuntu 14.04, g++ 4.8 版本测试通过 - -**SDK内部限制10个线程并发,即最多支持10个音频的实时识别。 ** - - - -## 运行 - -sample目录下有三个实例工程 - -sample/asr 运行 sh build_and_run.sh -sample/asrDemo2 下 run目录中运行 sh build_and_run.sh 。同时也是为Clion工程 -sample/asrDemo-srt 阅读该目录下的readme文件,再运行 - -## 完整文档 - -http://ai.baidu.com/docs#/ASR-Linux-SDK/top - -## 项目地址 - -https://github.com/Baidu-AIP/asr-linux-cpp-demo diff --git a/src/sdk/changelog.txt b/src/sdk/changelog.txt deleted file mode 100644 index 511665b..0000000 --- a/src/sdk/changelog.txt +++ /dev/null @@ -1,2 +0,0 @@ -3.0.0.30628d440-V1 -1. ѵƽ̨֧֣LMID \ No newline at end of file diff --git a/src/sdk/clean.sh b/src/sdk/clean.sh deleted file mode 100644 index 759d19c..0000000 --- a/src/sdk/clean.sh +++ /dev/null @@ -1,6 +0,0 @@ -cd sample -cd asr && make clean && rm core main *.log -cd .. -cd asrDemo2/run && make clean -cd ../.. -cd asrDemo-srt && rm -rf run/* diff --git a/src/sdk/include/ASR/bds_ASRDefines.hpp b/src/sdk/include/ASR/bds_ASRDefines.hpp deleted file mode 100644 index 566c6a5..0000000 --- a/src/sdk/include/ASR/bds_ASRDefines.hpp +++ /dev/null @@ -1,234 +0,0 @@ -// -// bds_ASRDefines.hpp -// SDKTester -// -// Created by baidu on 16/2/23. -// Copyright © 2016年 baidu. All rights reserved. -// - -#ifndef bds_ASRDefines_h -#define bds_ASRDefines_h - -#include -//#include "bds_int_types.h" -#include -namespace bds { - -#pragma mark - 设定采样率 -typedef enum TBDVoiceRecognitionRecordSampleRateFlags -{ - EVoiceRecognitionRecordSampleRateAuto = 0, - EVoiceRecognitionRecordSampleRate8K, - EVoiceRecognitionRecordSampleRate16K, -} TBDVoiceRecognitionRecordSampleRateFlags; - -#pragma mark - 语音识别类型 -typedef enum TBDVoiceRecognitionProperty -{ - EVoiceRecognitionPropertyMusic = 10001, // 音乐 - EVoiceRecognitionPropertyVideo = 10002, // 视频 - EVoiceRecognitionPropertyApp = 10003, // 应用 - EVoiceRecognitionPropertyWeb = 10004, // web - EVoiceRecognitionPropertySearch = 10005, // 热词 - EVoiceRecognitionPropertyEShopping = 10006, // 电商&购物 - EVoiceRecognitionPropertyHealth = 10007, // 健康&母婴 - EVoiceRecognitionPropertyCall = 10008, // 打电话 - EVoiceRecognitionPropertySong = 10009, // 录歌识别 - EVoiceRecognitionPropertyShake = 10010, // 摇一摇拾台 - EVoiceRecognitionPropertyMedicalCare = 10052, // 医疗 - EVoiceRecognitionPropertyCar = 10053, // 汽车 - EVoiceRecognitionPropertyCatering = 10054, // 娱乐餐饮 - EVoiceRecognitionPropertyFinanceAndEconomics = 10055, // 财经 - EVoiceRecognitionPropertyGame = 10056, // 游戏 - EVoiceRecognitionPropertyCookbook = 10057, // 菜谱 - EVoiceRecognitionPropertyAssistant = 10058, // 助手 - EVoiceRecognitionPropertyRecharge = 10059, // 话费充值 - EVoiceRecognitionPropertyMap = 10060, // 地图 - EVoiceRecognitionPropertyInput = 20000, // 输入 - // 离线垂类 - EVoiceRecognitionPropertyContacts = 100014, // 联系人指令 - EVoiceRecognitionPropertySetting = 100016, // 手机设置 - EVoiceRecognitionPropertyTVInstruction = 100018, // 电视指令 - EVoiceRecognitionPropertyPlayerInstruction = 100019, // 播放器指令 - EVoiceRecognitionPropertyRadio = 100020, // 收音机 -} TBDVoiceRecognitionProperty; - -#pragma mark - 设置识别语言 -typedef enum TBDVoiceRecognitionLanguage -{ - EVoiceRecognitionLanguageChinese = 0, - EVoiceRecognitionLanguageCantonese, - EVoiceRecognitionLanguageEnglish, - EVoiceRecognitionLanguageSichuanDialect, -} TBDVoiceRecognitionLanguage; - -#pragma mark - 语音识别请求资源类型 -typedef enum TBDVoiceRecognitionProtocol -{ - EPROTOCOL_DEFAULT = 0, - EPROTOCOL_SEARCH_NBEST = 1, - EPROTOCOL_INPUT_NBEST_PROTOCOL = 2, - EPROTOCOL_POST_PROTOCOL = 101, - EPROTOCOL_WISE_PROTOCOL = 300, - EPROTOCOL_WISE_TEXT_PROTOCOL = 301, - EPROTOCOL_AUDIO_DA_PROTOCOL = 302, - EPROTOCOL_NLU_PROTOCOL = 303, - EPROTOCOL_NLU_TEXT_PROTOCOL = 304, - EPROTOCOL_WISE_NLU_PROTOCOL = 305, - EPROTOCOL_TALK_PROTOCOL = 306, - EPROTOCOL_SEARCH_MUSIC_PROTOCOL = 1000, -} TBDVoiceRecognitionProtocol; - -#pragma mark - 调试日志级别 -typedef enum TBDVoiceRecognitionDebugLogLevel -{ - EVRDebugLogLevelOff = 0, - EVRDebugLogLevelFatal = 1, - EVRDebugLogLevelError = 2, - EVRDebugLogLevelWarning = 3, - EVRDebugLogLevelInformation = 4, - EVRDebugLogLevelDebug = 5, - EVRDebugLogLevelTrace = 6 -} TBDVoiceRecognitionDebugLogLevel; - -#pragma mark - 语音识别状态 -typedef enum TBDVoiceRecognitionClientWorkStatus -{ - EVoiceRecognitionClientWorkStatusStartWorkIng, // 识别工作开始,开始采集及处理数据 - EVoiceRecognitionClientWorkStatusStart, // 检测到用户开始说话 - EVoiceRecognitionClientWorkStatusEnd, // 本地声音采集结束,等待识别结果返回并结束录音 - EVoiceRecognitionClientWorkStatusNewRecordData, // 录音数据回调 - EVoiceRecognitionClientWorkStatusFlushData, // 连续上屏 - EVoiceRecognitionClientWorkStatusFinish, // 语音识别功能完成,服务器返回正确结果 - EVoiceRecognitionClientWorkStatusMeterLevel, // 当前音量回调 - EVoiceRecognitionClientWorkStatusCancel, // 用户取消 - EVoiceRecognitionClientWorkStatusError, // 发生错误 - /* 离线引擎状态 */ - EVoiceRecognitionClientWorkStatusLoaded, // 离线引擎加载完成 - EVoiceRecognitionClientWorkStatusUnLoaded, // 离线引擎卸载完成 - /* CHUNK状态 */ - EVoiceRecognitionClientWorkStatusChunkThirdData, // CHUNK: 识别结果中的第三方数据 - EVoiceRecognitionClientWorkStatusChunkVPRes, // CHUNK: 声纹会议返回信息 vp_res - EVoiceRecognitionClientWorkStatusChunkNlu, // CHUNK: 识别结果中的语义结果 - EVoiceRecognitionClientWorkStatusChunkEnd, // CHUNK: 识别过程结束 - /* LOG */ - EVoiceRecognitionClientWorkStatusFeedback, // Feedback: 识别过程反馈的打点数据 - /* Only for iOS */ - EVoiceRecognitionClientWorkStatusRecorderEnd, // 录音机关闭,页面跳转需检测此时间,规避状态条 (iOS) - /* LONG SPEECH END */ - EVoiceRecognitionClientWorkStatusLongSpeechEnd // 长语音结束状态 -} TBDVoiceRecognitionClientWorkStatus; - -#pragma mark - 语音识别策略 -typedef enum TBDVoiceRecognitionStrategy -{ - EVR_STRATEGY_ONLINE = 0, // 在线识别 - EVR_STRATEGY_OFFLINE, // 离线识别 - EVR_STRATEGY_ONLINE_PRI, // 在线优先 - EVR_STRATEGY_OFFLINE_PRI, // 离线优先 - EVR_STRATEGY_BOTH, // 并行模式 -} TBDVoiceRecognitionStrategy; - -#pragma mark - 语音识别离线引擎类型 -typedef enum TBDVoiceRecognitionOfflineEngineType -{ - EVR_OFFLINE_ENGINE_INPUT = 0, // 离线引擎输入法模式 - EVR_OFFLINE_ENGINE_NAVI, // 离线引擎导航模式 - EVR_OFFLINE_ENGINE_GRAMMER, // 离线引擎语法模式 -} TBDVoiceRecognitionOfflineEngineType; - -#pragma mark - 识别结果类型 -typedef enum TBDVoiceRecognitionResultType -{ - EVR_RESULT_TYPE_ERROR = -1, // Error code - EVR_RESULT_TYPE_EMPTY = 0, // Empty reply - EVR_RESULT_TYPE_PARTIAL = 1, // Partial result - EVR_RESULT_TYPE_NBEST = 2, // Nbest result - EVR_RESULT_TYPE_CN = 3, // CN result - EVR_RESULT_TYPE_RESOURCE = 4, // NLU & resource result - EVR_RESULT_TYPE_THIRD = 5, // CHUNK: Third party data - EVR_RESULT_TYPE_FINISH = 6, // CHUNK: Finish - EVR_RESULT_TYPE_END = 7, // CHUNK: End - EVR_RESULT_TYPE_VP_RES = 8, // vp_res -} TBDVoiceRecognitionResultType; - -#pragma mark - 网络类型 -typedef enum TBDVoiceRecognitionNetworkType -{ - EVR_NETWORK_TYPE_NO = 0, - EVR_NETWORK_TYPE_2G, - EVR_NETWORK_TYPE_3G, - EVR_NETWORK_TYPE_4G, - EVR_NETWORK_TYPE_WIFI, -} TBDVoiceRecognitionNetworkType; - -#pragma mark - 语音压缩类型 -typedef enum TBDVoiceRecognitionAudioCompressionType -{ - EVR_AUDIO_COMPRESSION_MIN = 0, - EVR_AUDIO_COMPRESSION_PCM = 1, - EVR_AUDIO_COMPRESSION_BV32 = 2, - EVR_AUDIO_COMPRESSION_AMR = 3, - EVR_AUDIO_COMPRESSION_MAX = 4, -} TBDVoiceRecognitionAudioCompressionType; - -#pragma mark - 语音识别错误通知状态分类 -typedef enum TVoiceRecognitionClientErrorDomain -{ - EVRClientErrorDomainRecord = 10, // 录音设备出错 - EVRClientErrorDomainVAD = 20, // 语音数据处理过程出错 - EVRClientErrorDomainOnline = 30, // 在线识别引擎出错 - EVRClientErrorDomainLocalNetwork = 31, // 本地网络联接出错 - EVRClientErrorDomainHTTP = 32, // HTTP协议错误 - EVRClientErrorDomainServer = 33, // 服务器返回错误 - EVRClientErrorDomainOffline = 34, // 离线引擎返回错误 - EVRClientErrorDomainCommon = 40, // 其他错误 -} TVoiceRecognitionClientErrorDomain; - -#pragma mark - 语音识别错误通知状态 -typedef enum TVoiceRecognitionClientErrorCode -{ - EVRClientErrorCodeRecoderException = (EVRClientErrorDomainRecord << 16) | (0x0000FFFF & 1), // 录音设备异常 - EVRClientErrorCodeRecoderNoPermission = (EVRClientErrorDomainRecord << 16) | (0x0000FFFF & 2), // 无录音权限 - EVRClientErrorCodeRecoderUnAvailable = (EVRClientErrorDomainRecord << 16) | (0x0000FFFF & 3), // 录音设备不可用 - EVRClientErrorCodeInterruption = (EVRClientErrorDomainRecord << 16) | (0x0000FFFF & 4), // 录音中断 - - EVRClientErrorCodeVADException = (EVRClientErrorDomainVAD << 16) | (0x0000FFFF & 1), // 前端库异常 - EVRClientErrorCodeNoSpeech = (EVRClientErrorDomainVAD << 16) | (0x0000FFFF & 2), // 用户未说话 - EVRClientErrorCodeShort = (EVRClientErrorDomainVAD << 16) | (0x0000FFFF & 3), // 用户说话声音太短 - - EVRClientErrorCodeOnlineExceptioin = (EVRClientErrorDomainOnline << 16) | (0x0000FFFF & 1), // 在线识别引擎异常 - EVRClientErrorCodeOnlineNetworkUnavailable = (EVRClientErrorDomainOnline << 16) | (0x0000FFFF & 2), // 网络不可用 - EVRClientErrorCodeOnlineTokenFailed = (EVRClientErrorDomainOnline << 16) | (0x0000FFFF & 3), // 获取token失败 - EVRClientErrorCodeOnlineResolveUrlFailed = (EVRClientErrorDomainOnline << 16) | (0x0000FFFF & 4), // 解析url失败 - EVRClientErrorCodeLocalTimeout = (EVRClientErrorDomainLocalNetwork << 16) | (0x0000FFFF & 1), // 请求超时 - - EVRClientErrorCodeServerParamError = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3001), // 协议参数错误 - EVRClientErrorCodeServerRecognError = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3002), // 识别过程出错 - EVRClientErrorCodeServerNoFindResult = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3003), // 没有找到匹配结果 - EVRClientErrorCodeServerAppNameUnknownError = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3004), // AppnameUnkown错误 - EVRClientErrorCodeServerSpeechQualityProblem = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3005), // 声音不符合识别要求 - EVRClientErrorCodeServerSpeechTooLong = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3006), // 语音过长 - EVRClientErrorCodeServerSpeechParamsUnknow = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3008), // 上行参数未知,(可能是gzip解压失败) - EVRClientErrorCodeServerSpeechNoUploadLink = (EVRClientErrorDomainServer << 16) | (0x0000FFFF & -3011), // 只有下行链接没有上行链接 - - EVRClientErrorCodeCommonBusy = (EVRClientErrorDomainCommon << 16) | (0x0000FFFF & 4095), // 识别器忙 - EVRClientErrorCodeCommonPropertyListInvalid = (EVRClientErrorDomainCommon << 16) | (0x0000FFFF & 2), // 垂类设置有误 - EVRClientErrorCodeCommonEnqueueError = (EVRClientErrorDomainCommon << 16) | (0x0000FFFF & 3) // 语音数据enqueue失败 -} TVoiceRecognitionClientErrorCode; - -#pragma mark -- INTERNAL DEFINES - - -#pragma mark - 语音识别模式 -typedef enum TBDVoiceRecognitionMode { - EVR_MODE_MULTI_SENTENCE = 0, - EVR_MODE_SINGLE_SENTENCE, - EVR_MODE_MUSIC, - EVR_MODE_SHAKE, -} TBDVoiceRecognitionMode; - -} - -#endif /* bds_ASRDefines_h */ - diff --git a/src/sdk/include/ASR/bds_WakeupDefines.hpp b/src/sdk/include/ASR/bds_WakeupDefines.hpp deleted file mode 100644 index de11f0d..0000000 --- a/src/sdk/include/ASR/bds_WakeupDefines.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// -// bds_WakeupDefines.hpp -// BDASRCore -// -// Created by baidu on 16/5/20. -// Copyright © 2016年 baidu. All rights reserved. -// - -#ifndef bds_WakeupDefines_hpp -#define bds_WakeupDefines_hpp - -namespace bds { - -#pragma mark - 唤醒引擎状态 -typedef enum TWakeupEngineWorkStatus -{ - EWakeupEngineWorkStatusStarted, // 引擎开始工作 - EWakeupEngineWorkStatusStopped, // 引擎关闭完成 - EWakeupEngineWorkStatusLoaded, // 唤醒引擎加载完成 - EWakeupEngineWorkStatusUnLoaded, // 唤醒引擎卸载完成 - EWakeupEngineWorkStatusTriggered, // 命中唤醒词 - EWakeupEngineWorkStatusError, // 引擎发生错误 -} TWakeupEngineWorkStatus; - -#pragma mark - 唤醒引擎错误分类 -typedef enum TWakeupEngineErrorDomain -{ - EWakeupEngineErrorDomainRecord = 10, // 录音设备出错 - EWakeupEngineErrorDomainEngine = 38, // 录音设备出错 -} TWakeupEngineErrorDomain; - -#pragma mark - 唤醒引擎错误状态 -typedef enum TWakeupEngineErrorCode -{ - EWakeupEngineRecoderException = (EWakeupEngineErrorDomainRecord << 16) | (0x0000FFFF & 1), // 录音设备异常 - EWakeupEngineRecoderNoPermission = (EWakeupEngineErrorDomainRecord << 16) | (0x0000FFFF & 2), // 无录音权限 - EWakeupEngineRecoderUnAvailable = (EWakeupEngineErrorDomainRecord << 16) | (0x0000FFFF & 3), // 录音设备不可用 - EWakeupEngineRecoderInterruption = (EWakeupEngineErrorDomainRecord << 16) | (0x0000FFFF & 4), // 录音中断 - - EWakeupEngineExceptioin = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 1), // 唤醒引擎异常 - EWakeupEngineNoLicense = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 2), // 无授权文件 - EWakeupEngineLicenseInvalid = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 3), // 授权文件异常 - EWakeupEngineWakeupWordsInvalid = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 4), // 唤醒次异常 - EWakeupEngineDatFileInvalid = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 5), // 模型文件异常 - EWakeupEngineInitializeFailed = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 6), // 引擎初始化失败 - EWakeupEngineAllocMemFailed = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 7), // 内存分配失败 - EWakeupEngineResetFailed = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 8), // 引擎重置失败 - EWakeupEngineFreeFailed = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 9), // 引擎释放失败 - EWakeupEngineArchiNotSupportted = (EWakeupEngineErrorDomainEngine << 16) | (0x0000FFFF & 10), // 引擎不支持该架构 -} TWakeupEngineErrorCode; - -} - -#endif /* bds_WakeupDefines_hpp */ diff --git a/src/sdk/include/ASR/bds_asr_key_definitions.hpp b/src/sdk/include/ASR/bds_asr_key_definitions.hpp deleted file mode 100644 index 4b9660b..0000000 --- a/src/sdk/include/ASR/bds_asr_key_definitions.hpp +++ /dev/null @@ -1,581 +0,0 @@ -#ifndef _BD_ASR_DEFINITIONS_H_ -#define _BD_ASR_DEFINITIONS_H_ - -#include - -namespace bds { -/* - * SDKType definition to load ASR SDK from - * BDSpeechSDK::get_instance(const std::string &SDKType, std::string &outErrorDescription); - */ - extern const std::string SDK_TYPE_ASR; - - /*================================ Message names for using ASR SDK ===============================*/ - extern const std::string ASR_CMD_CONFIG; - extern const std::string ASR_CMD_START; - extern const std::string ASR_CMD_PUSH_AUDIO; - extern const std::string ASR_CMD_STOP; - extern const std::string ASR_CMD_CANCEL; - extern const std::string ASR_CMD_KWS_LOAD; - extern const std::string ASR_CMD_KWS_UNLOAD; - extern const std::string BDS_COMMAND_SET_WRITABLE_LIBRARY_DATA_PATH; - - /*=============================== Message names for Events from ASR ==============================*/ - extern const std::string asr_callback_name; - - extern const std::string CALLBACK_ASR_STATUS; - extern const std::string CALLBACK_ASR_RESULT; - extern const std::string CALLBACK_ASR_LEVEL; - extern const std::string CALLBACK_ERROR_DESC; - extern const std::string CALLBACK_ERROR_CODE; - extern const std::string CALLBACK_ERROR_DOMAIN; - extern const std::string CALLBACK_ERROR_SERIAL_NUM; - - /*================================ ASR SDK parameter keys ===============================*/ - /* - * ASR_PARAM_KEY_CHUNK_KEY - * Value explanation: Chunk协议授权字段 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_CHUNK_KEY; - - /* - * ASR_PARAM_KEY_CUID - * Value explanation: CUID - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_CUID; - - /* - * ASR_PARAM_KEY_CHUNK_PARAM - * Value explanation: Chunk协议透传字段 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_CHUNK_PARAM; - - /* - * ASR_PARAM_KEY_CHUNK_ENABLE - * Value explanation: Chunk协议开关 - * Value type: int - * Valid value: Enable (1) or Disable (0) - * Default value: 0 - */ - extern const std::string ASR_PARAM_KEY_CHUNK_ENABLE; - - /* - * ASR_PARAM_KEY_ENABLE_LONG_SPEECH - * Value explanation: 长语音开关 - * Value type: bool - * Valid value: Enable (1) or Disable (0) - * Default value: 0 - */ - extern const std::string ASR_PARAM_KEY_ENABLE_LONG_SPEECH; - - extern const std::string BDS_PARAM_KEY_WRITABLE_LIBRARY_DATA_PATH; - -/* - * ASR_PARAM_KEY_SAVE_AUDIO_ENABLE - * Value explanation: ASR 保存音频文件开关 - * Value type: bool - * Default value: false - */ -extern const std::string ASR_PARAM_KEY_SAVE_AUDIO_ENABLE; - -/* - * ASR_PARAM_KEY_SAVE_AUDIO_PATH - * Value explanation: ASR 保存音频文件路径 - * Value type: string - * Default value: "./sdk_save_audio.d" - */ -extern const std::string ASR_PARAM_KEY_SAVE_AUDIO_PATH; - -/*================================ Params with Command ===============================*/ - /* - * ASR_PARAM_KEY_REALTIME_DATA - * Value explanation: 实时透传参数,随命令同步发送 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_REALTIME_DATA; - -/*================================ Debug ===============================*/ - /* - * COMMON_PARAM_KEY_DEBUG_LOG_LEVEL - * Value explanation: 指定调试日志级别 - * Value type: TBDVoiceRecognitionDebugLogLevel (int) - * Valid value: Be listed in enum TBDVoiceRecognitionDebugLogLevel - * Default value: EVRDebugLogLevelOff - */ - extern const std::string COMMON_PARAM_KEY_DEBUG_LOG_LEVEL; - -/*================================ AUDIO ===============================*/ - /* - * MIC_PARAM_KEY_AUDIO_FILE_PATH - * Value explanation: 设置音频文件路径(数据源) - * Value type: std::string - * Default value: - - */ - extern const std::string MIC_PARAM_KEY_AUDIO_FILE_PATH; - - /* - * MIC_PARAM_KEY_NEED_CACHE - * Value explanation: Need cached data in recorder. - * Value type: int - * Value requirement: Optional - * Default value: 0 - */ - extern const std::string MIC_PARAM_KEY_NEED_CACHE; - - /* - * MIC_PARAM_KEY_DISABLE_AUDIO_OPERATION - * Value explanation: Disable sdk audio operation (Set audio session disactive). - * Value type: int - * Value requirement: Optional - * Default value: 0 - */ - extern const std::string MIC_PARAM_KEY_DISABLE_AUDIO_OPERATION; - -/*================================ BASIC ===============================*/ - /* - * ASR_PARAM_KEY_SDK_VERSION - * Value explanation: SDK version - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_SDK_VERSION; - - /* - * ASR_PARAM_KEY_START_TONE - * Value explanation: 录音开始提示音 - * Value type: int - * Valid value: Enable (1) or Disable (0) - * Default value: 0 - */ - extern const std::string ASR_PARAM_KEY_START_TONE; - - /* - * ASR_PARAM_KEY_STRATEGY - * Value explanation: 语音识别策略 - * Value type: TBDVoiceRecognitionStrategy (int) - * Valid value: Be listed in enum TBDVoiceRecognitionStrategy - * Default value: EVR_STRATEGY_ONLINE - */ - extern const std::string ASR_PARAM_KEY_STRATEGY; - - /* - * ASR_PARAM_KEY_SAMPLE_RATE - * Value explanation: 设置录音采样率,自动模式根据当前网络情况自行调整 - * Value type: TVoiceRecognitionRecordSampleRateFlags (int) - * Valid value: Be listed in enum TVoiceRecognitionRecordSampleRateFlags - * Default value: EVoiceRecognitionRecordSampleRate16K - */ - extern const std::string ASR_PARAM_KEY_SAMPLE_RATE; - -/*================================ VAD-MFE ===============================*/ - /* - * ASR_PARAM_KEY_MAX_SPEECH_PAUSE - * Value explanation: 设置切分门限 - * Value type: float (帧数,每帧大小为10ms) - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_MAX_SPEECH_PAUSE; - - /* - * ASR_PARAM_KEY_MAX_WAIT_DURATION - * Value explanation: 设置最大等待语音时间 - * Value type: float (该值为帧数,每帧大小为10ms) - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_MAX_WAIT_DURATION; - - /* - * ASR_PARAM_KEY_MFE_DNN_DAT_FILE - * Value explanation: 设置MFE模型文件 - * Value type: string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_MFE_DNN_DAT_FILE; - - /* - * ASR_PARAM_KEY_MFE_CMVN_DAT_FILE - * Value explanation: 设置MFE CMVN文件路径 - * Value type: string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_MFE_CMVN_DAT_FILE; - -/*================================ SERVER FUNCTIONS ===============================*/ - /* - * ASR_PARAM_KEY_DISABLE_PUNCTUATION - * Value explanation: 是否关闭标点 - * Value type: int - * Valid Value: Disable (1) or Not Disable (0) - * Default value: 0 - */ - extern const std::string ASR_PARAM_KEY_DISABLE_PUNCTUATION; - - /* - * ASR_PARAM_KEY_ENABLE_SERVER_VAD - * Value explanation: 服务器端VAD - * Value type: int - * Valid Value: Enable (1) or Disable (0) - * Default value: 1 - * 注意:这个参数不管用,控制不了服务端的VAD,老版本的SDK才可以 - */ - extern const std::string ASR_PARAM_KEY_ENABLE_SERVER_VAD; - - /* - * ASR_PARAM_KEY_ENABLE_CONTACTS - * Value explanation: 开启通讯录识别功能,将优先返回通讯录识别结果,需事先上传通讯录 - * Value type: int - * Valid Value: Enable (1) or Disable (0) - * Default value: 0 - */ - extern const std::string ASR_PARAM_KEY_ENABLE_CONTACTS; - - /* - * ASR_PARAM_KEY_ENABLE_EARLY_RETURN - * Value explanation: 服务端开启提前返回,即允许服务端在未收到客户端发送的结束标志前提前结束识别过程 - * Value type: int - * Valid Values: Enable (1) or Disable (0) - * Default value: 1 - */ - extern const std::string ASR_PARAM_KEY_ENABLE_EARLY_RETURN; - - -/*================================ SERVER ===============================*/ - /* - * ASR_PARAM_KEY_API_SECRET_KEY - * Value explanation: 设置SECRET_KEY - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_SECRET_KEY; - - /* - * ASR_PARAM_KEY_SERVER_URL - * Value explanation: 设置服务器地址 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_SERVER_URL; - - /* - * ASR_PARAM_KEY_BROWSER_UA - * Value explanation: 设置浏览器标识(Http request header),资源返回时会根据UA适配 - * Value type: std::string - * Default value: -(可通过[UIWebView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"]获取) - */ - extern const std::string ASR_PARAM_KEY_BROWSER_USER_AGENT; - - /* - * ASR_PARAM_KEY_APP_ID - * Value explanation: 设置APP_ID - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_APP_ID; - - /* - * ASR_PARAM_KEY_LMID - * Value explanation: 设置LMID - * Value type: int - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_LMID; - - /* - * ASR_PARAM_KEY_VP_PARAMS - * Value explanation: 设置vp_params - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_VP_PARAMS; - - /* - * ASR_PARAM_KEY_API_KEY - * Value explanation: 设置API_KEY - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_API_KEY; - -/*================================ Recognition ===============================*/ - /* - * ASR_PARAM_KEY_PROPERTY_LIST - * Value explanation: 设置识别类型列表,输入法不可与其他类型复合 - * Value type: std::string(JSON array) - * Default value: {"property_list":[EVoiceRecognitionPropertySearch]} - - * NOTE: Give a JSON string containing "property_list" key. The value for this key - * should be a json array of integers.\ - * - *Example: To pass in EVoiceRecognitionPropertyMusic - * and EVoiceRecognitionPropertyVideo the JSON should be as follows: - * {"property_list":[10001,10002]} - */ - extern const std::string ASR_PARAM_KEY_PROPERTY_LIST; - - /* - * ASR_PARAM_KEY_PRODUCT_ID - * Value explanation: 设置产品ID - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_PRODUCT_ID; - - /* - * ASR_PARAM_KEY_CITY_ID - * Value explanation: 设置城市ID,仅对地图识别类型有效 - * Value type: int - * Default value: 1(全国) - */ - extern const std::string ASR_PARAM_KEY_CITY_ID; - - /* - * ASR_PARAM_KEY_PROTOCOL - * Value explanation: 设置协议类型 - * Value type: TBDVoiceRecognitionProtocol (int) - * Valid value: Be listed in enum TBDVoiceRecognitionProtocol - * Default value: EPROTOCOL_DEFAULT - */ - extern const std::string ASR_PARAM_KEY_PROTOCOL; - - /* - * ASR_PARAM_KEY_LANGUAGE - * Value explanation: 设置识别语言 - * Value type: TBDVoiceRecognitionLanguage (int) - * Valid value: Be listed in enum TBDVoiceRecognitionLanguage - * Default value: EVoiceRecognitionLanguageChinese - */ - extern const std::string ASR_PARAM_KEY_LANGUAGE; - - /* - * ASR_PARAM_KEY_ENABLE_NLU - * Value explanation: 开启语义解析,将返回包含语音的json串 - * Value type: int - * Valid value: Enable (1) or Disable (0) - * Default value: 0 - */ - extern const std::string ASR_PARAM_KEY_ENABLE_NLU; - - /* - * ASR_PARAM_KEY_ENABLE_LOCAL_VAD - * Value explanation: 是否需要对录音数据进行端点检测 - * Value type: int - * Valid value: Enable (1) or Disable (0) - * Default value: 1 - */ - extern const std::string ASR_PARAM_KEY_ENABLE_LOCAL_VAD; - - /* - * ASR_PARAM_KEY_ENABLE_MODEL_VAD - * Value explanation: 是否使用modelVAD - * Value type: int - * Valid value: Enable (1) or Disable (0) - * Default value: 0 - */ - extern const std::string ASR_PARAM_KEY_ENABLE_MODEL_VAD; - - /* - * ASR_PARAM_KEY_MODEL_VAD_DAT_FILE - * Value explanation: modelVAD所需资源文件 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_MODEL_VAD_DAT_FILE; - - /* - * ASR_PARAM_KEY_COMPRESSION_TYPE - * Value explanation: 录音数据压缩算法 - * Value type: TBDVoiceRecognitionAudioCompressionType (int) - * Valid value: Be listed in enum TBDVoiceRecognitionAudioCompressionType - * Default value: EVR_AUDIO_COMPRESSION_BV32 - */ - extern const std::string ASR_PARAM_KEY_COMPRESSION_TYPE; - - /* - * ASR_PARAM_KEY_ENABLE_DRC - * Value explanation: 是否进行车载环境下的噪声消除 - * Value type: int - * Valid value: Enable (1) or Disable (0) - * Default value: 1 - */ - extern const std::string ASR_PARAM_KEY_ENABLE_DRC; - -/*================================ 扩展参数 ===============================*/ - /* - * ASR_PARAM_KEY_PAM - * Value explanation: 扩展参数,多轮对话需要的信息 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_PAM; - - /* - * ASR_PARAM_KEY_STC - * Value explanation: 扩展参数,统计信息 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_STC; - - /* - * ASR_PARAM_KEY_LTP - * Value explanation: 扩展参数,轻应用参数(uid) - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_LTP; - - /* - * ASR_PARAM_KEY_TXT - * Value explanation: 扩展参数,上传文本,如果设置了该字段,将略过语音输入和识别阶段 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_TXT; - - /* - * ASR_PARAM_KEY_BUA - * Value explanation: 浏览器标识, use for wise - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_BUA; - -/*================================ Configuration for contract with server ===============================*/ - /* - * ASR_PARAM_KEY_NETWORK_STATUS - * Value explanation: 当前网络状态 - * Value type: TBDVoiceRecognitionNetworkType (int) - * Valid value: Be listed in enum TBDVoiceRecognitionNetworkType - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_NETWORK_STATUS; - - /* - * ASR_PARAM_KEY_APP - * Value explanation: App name - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_APP; - - /* - * ASR_PARAM_KEY_PLATFORM - * Value explanation: Platform - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_PLATFORM; - - /* - * ASR_PARAM_KEY_COK - * Value explanation: Cookie, use for wise - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_COK; - - /* - * ASR_PARAM_KEY_PU - * Value explanation: Pu, use for wise - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_PU; - - /* - * ASR_PARAM_KEY_FRM - * Value explanation: From, use for wise - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_FRM; - - /* - * ASR_PARAM_KEY_RSV - * Value explanation: Reserve, use for wise - * Value type: std::string (json) - * Default value: - - * Note: Give a json formatted string containing string parameters with keys. - * Example: To pass in 2 parameters (reserved_1 and reserved_2 with values "value 1" and "value 2") - * pass following json string. - * {"reserved_1":"value 1","reserved_2":"value 2"} - */ - extern const std::string ASR_PARAM_KEY_RSV; - -/*================================ Offline Engine Verify ===============================*/ - /* - * OFFLINE_PARAM_KEY_APP_CODE - * Value explanation: 离线授权所需APPCODE - * Value type: std::string - * Default value: - - */ - extern const std::string OFFLINE_PARAM_KEY_APP_CODE; - - /* - * OFFLINE_PARAM_KEY_LICENSE_FILE_PATH - * Value explanation: 离线授权文件路径 - * Value type: std::string - * Default value: - - */ - extern const std::string OFFLINE_PARAM_KEY_LICENSE_FILE_PATH; - -/*================================ Offline Engine KWS ===============================*/ - /* - * ASR_PARAM_KEY_OFFLINE_ENGINE_TYPE - * Value explanation: 离线识别引擎类型 - * Value type: TBDVoiceRecognitionOfflineEngineType (int) - * Valid value: Be listed in enum TBDVoiceRecognitionOfflineEngineType - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_TYPE; - - /* - * ASR_PARAM_KEY_OFFLINE_ENGINE_DAT_FILE_PATH - * Value explanation: 离线识别资源文件路径 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_DAT_FILE_PATH; - - /* - * ASR_PARAM_KEY_OFFLINE_ENGINE_GRAMMER_FILE_PATH - * Value explanation: 离线识别语法文件路径 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_GRAMMER_FILE_PATH; - - /* - * ASR_PARAM_KEY_OFFLINE_ENGINE_GRAMMER_SLOT - * Value explanation: 语法模式离线语法槽 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_GRAMMER_SLOT; - - /* - * ASR_PARAM_KEY_OFFLINE_ENGINE_WAKEUP_WORDS_FILE_PATH - * Value explanation: 唤醒词文件路径,使用了唤醒并使用离线识别的情况下需要设置,其他情况请忽略该参数 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_WAKEUP_WORDS_FILE_PATH; - - /* - * ASR_PARAM_KEY_OFFLINE_ENGINE_TRIGGERED_WAKEUP_WORD - * Value explanation: 当前触发唤醒词,唤醒后立即调用识别的情况下配置,其他情况请忽略该参数 - * Value type: std::string - * Default value: - - */ - extern const std::string ASR_PARAM_KEY_OFFLINE_ENGINE_TRIGGERED_WAKEUP_WORD; - extern const std::string PARAM_TYPE_MAX_ASR_INSTANCE_NUM; -} - -#endif diff --git a/src/sdk/include/ASR/bds_wakeup_key_definitions.hpp b/src/sdk/include/ASR/bds_wakeup_key_definitions.hpp deleted file mode 100644 index adfc526..0000000 --- a/src/sdk/include/ASR/bds_wakeup_key_definitions.hpp +++ /dev/null @@ -1,137 +0,0 @@ -// -// bds_WakeupParameters.hpp -// BDASRCore -// -// Created by baidu on 16/5/19. -// Copyright © 2016年 baidu. All rights reserved. -// - -#ifndef bds_WakeupParameters_hpp -#define bds_WakeupParameters_hpp - -#include - -namespace bds { -/* - * SDKType definition to load Wakeup SDK from - * BDSpeechSDK::get_instance(const std::string &SDKType, std::string &outErrorDescription); - */ -extern const std::string SDK_TYPE_WAKEUP; - -/*================================ Message names for using Wakeup SDK ===============================*/ - -extern const std::string WAK_CMD_CONFIG; -extern const std::string WAK_CMD_START; -extern const std::string WAK_CMD_PUSH_AUDIO; -extern const std::string WAK_CMD_STOP; -extern const std::string WAK_CMD_LOAD_ENGINE; -extern const std::string WAK_CMD_UNLOAD_ENGINE; -extern const std::string BDS_COMMAND_SET_WRITABLE_LIBRARY_DATA_PATH; -extern const std::string BDS_COMMAND_GET_EVENT_MANAGER_VERSION; - -/*============================= Message names for events from Wakeup SDK ============================*/ -extern const std::string wakeup_callback_name; - -extern const std::string CALLBACK_WAK_STATUS; -extern const std::string CALLBACK_WAK_RESULT; -extern const std::string CALLBACK_ERROR_DESC; -extern const std::string CALLBACK_ERROR_DOMAIN; -extern const std::string CALLBACK_ERROR_CODE; -extern const std::string BDS_CALLBACK_EVENT_MANAGER_VERSION; - -/*================================ Wakeup command parameters ===============================*/ - -#pragma mark - Debug - -/* - * COMMON_PARAM_KEY_DEBUG_LOG_LEVEL - * Value explanation: 指定调试日志级别 - * Value type: TBDVoiceRecognitionDebugLogLevel (int) - * Default value: EVRDebugLogLevelOff - */ -extern const std::string COMMON_PARAM_KEY_DEBUG_LOG_LEVEL; - -#pragma mark - Offline Engine Verify - -/* - * OFFLINE_PARAM_KEY_APP_CODE - * Value explanation: 离线授权所需APPCODE - * Value type: std::string - * Default value: - - */ -extern const std::string OFFLINE_PARAM_KEY_APP_CODE; - -/* - * OFFLINE_PARAM_KEY_LICENSE_FILE_PATH - * Value explanation: 离线授权文件路径 - * Value type: std::string - * Default value: - - */ -extern const std::string OFFLINE_PARAM_KEY_LICENSE_FILE_PATH; - -/* - * OFFLINE_PARAM_KEY_APP_NAME - * Value explanation: 离线授权所需APPNAME (Linux) - * Value type: std::string - * Default value: - - */ -extern const std::string OFFLINE_PARAM_KEY_APP_NAME; - -/* - * OFFLINE_PARAM_KEY_CUID - * Value explanation: 离线授权所需CUID (Android) - * Value type: std::string - * Default value: - - */ -extern const std::string OFFLINE_PARAM_KEY_CUID; - -/* - * OFFLINE_PARAM_KEY_JNI_CONTEXT - * Value explanation: 离线授权所需JNI_CONTEXT (Android) - * Value type: std::string - * Default value: - - */ -extern const std::string OFFLINE_PARAM_KEY_JNI_CONTEXT; - - -#pragma mark - Offline Engine Wakeup - -/* - * WP_PARAM_KEY_ENABLE_DNN_WAKEUP - * Value explanation: 使用DNN唤醒,功耗低 - * Value type: bool - * Default value: false - */ -extern const std::string WP_PARAM_KEY_ENABLE_DNN_WAKEUP; - -/* - * WP_PARAM_KEY_WAKEUP_WORDS - * Value explanation: 唤醒词列表 - * Value type: std::vector - * Value type: std::string (json format list of words, UTF-8 encoded, list key "words") - * Default value: - - * Example: std::string("{\"words\":[\"小度你好\",\"百度你好\"]}") - */ -extern const std::string WP_PARAM_KEY_WAKEUP_WORDS; - -/* - * WP_PARAM_KEY_WAKEUP_WORDS_FILE_PATH - * Value explanation: 唤醒词文件路径 - * Value type: std::string - * Default value: - - */ -extern const std::string WP_PARAM_KEY_WAKEUP_WORDS_FILE_PATH; - -/* - * WP_PARAM_KEY_WAKEUP_DAT_FILE_PATH - * Value explanation: 唤醒引擎模型文件路径 - * Value type: std::string - * Default value: - - */ -extern const std::string WP_PARAM_KEY_WAKEUP_DAT_FILE_PATH; - -extern const std::string BDS_PARAM_KEY_WRITABLE_LIBRARY_DATA_PATH; - -} - -#endif /* bds_WakeupParameters_hpp */ diff --git a/src/sdk/include/BDSSDKMessage.hpp b/src/sdk/include/BDSSDKMessage.hpp deleted file mode 100644 index c76e007..0000000 --- a/src/sdk/include/BDSSDKMessage.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * - * Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved - * - **************************************************************************/ - -/** - * @file BDSSDKMessage.hpp - * @author Vaino(lappivaeinoe@baidu.com) - * @date 2016/10/26 17:51:32 - * @brief Message container to pass commands to SDK and receive events/callbacks from the SDK - * - **/ - -#ifndef _BDS_SDK_MESSAGE_HPP_ -#define _BDS_SDK_MESSAGE_HPP_ -#include -#include -#include - -namespace bds { - - extern const std::string DATA_CHUNK; - - class BDSSDKMessageImpl; - class BDSSDKMessage{ - public: - BDSSDKMessage(const std::string &p_name); - BDSSDKMessage(); - BDSSDKMessage(const BDSSDKMessage &m); - virtual BDSSDKMessage& operator=(const BDSSDKMessage &m); - - std::string name; - /* - char* data; - unsigned int length; - */ - virtual ~BDSSDKMessage(); - - /* Set parameters to message */ - void set_parameter(const std::string &key, const std::string &value); - void set_parameter(const std::string &key, int value); - void set_parameter(const std::string &key, float value); - void set_parameter(const std::string &key, const char* value, int valueLen); - void set_parameter(const std::string &key, const std::vector &value); - - /* Get keys for parameters set to message */ - std::vector string_param_keys(); - std::vector int_param_keys(); - std::vector float_param_keys(); - std::vector char_param_keys(); - std::vector vector_param_keys(); - - /* Get parameters from message */ - bool get_parameter(const std::string &key, std::string &outValue); - bool get_parameter(const std::string &key, int &outValue); - bool get_parameter(const std::string &key, float &outValue); - bool get_parameter(const std::string &key, const char* &outValue, int &outValueLen); - bool get_parameter(const std::string &key, std::vector &outValue); - private: - BDSSDKMessageImpl* _impl; - friend class BDSSDKMessageImpl; - }; -} - -#endif diff --git a/src/sdk/include/BDSpeechSDK.hpp b/src/sdk/include/BDSpeechSDK.hpp deleted file mode 100644 index 55d6076..0000000 --- a/src/sdk/include/BDSpeechSDK.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * - * Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved - * - **************************************************************************/ - -/** - * @file BDSpeechSDK.hpp - * @author Vaino(lappivaeinoe@baidu.com) - * @date 2016/10/26 17:52:07 - * @brief Main interface for speech SDK for Linux. - * - **/ - -#ifndef _BDS_SPEECH_SDK_HPP_ -#define _BDS_SPEECH_SDK_HPP_ - -#include -#include "BDSSDKMessage.hpp" - -namespace bds { - class BDSpeechSDK{ - public: - static BDSpeechSDK* get_instance(const std::string &SDKType, std::string &outErrorDescription); - virtual void set_event_listener(void(*listener)(BDSSDKMessage&,void*), void* userParam) = 0; - static void release_instance(BDSpeechSDK* instance); - - virtual bool post(BDSSDKMessage &message, std::string &outErrorDescription) = 0; - /* - * Cleanup for closing the program. - * This function will clean up some globals and makes sure that - * everything has been stopped before returning. - * Call is needed only when the whole program is about to shut down - * Not calling this function before returning from main() function of the program may lead to a crash due to async nature of release_instance() functions. - */ - static void do_cleanup(); - - static void open_log_file(const char *logFileName, int fileSize = 0); - static void close_log_file(); - static std::string get_sdk_version(); - - static int set_global_param(const std::string& param_type, void* value, std::string &outErrorDescription); - protected: - BDSpeechSDK(); - virtual ~BDSpeechSDK(); - }; -} - -#endif diff --git a/src/sdk/lib/libBDSpeechSDK.a b/src/sdk/lib/libBDSpeechSDK.a deleted file mode 100644 index acb41e4..0000000 Binary files a/src/sdk/lib/libBDSpeechSDK.a and /dev/null differ diff --git a/src/sdk/resources/asr_resource/bds_easr_basic_model.dat b/src/sdk/resources/asr_resource/bds_easr_basic_model.dat deleted file mode 100644 index 826c81f..0000000 Binary files a/src/sdk/resources/asr_resource/bds_easr_basic_model.dat and /dev/null differ diff --git a/src/sdk/resources/asr_resource/bds_easr_dnn_wakeup_model.dat b/src/sdk/resources/asr_resource/bds_easr_dnn_wakeup_model.dat deleted file mode 100644 index f6dfb59..0000000 Binary files a/src/sdk/resources/asr_resource/bds_easr_dnn_wakeup_model.dat and /dev/null differ diff --git a/src/sdk/resources/asr_resource/bds_easr_gramm.dat b/src/sdk/resources/asr_resource/bds_easr_gramm.dat deleted file mode 100644 index 7eda192..0000000 --- a/src/sdk/resources/asr_resource/bds_easr_gramm.dat +++ /dev/null @@ -1 +0,0 @@ -%7B%0A%20%20%20%20%22version%22%3A%20%220.1%22%2C%0A%20%20%20%20%22slots%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22name%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%E5%BC%A0%E4%B8%89%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%E6%9D%8E%E5%9B%9B%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%E7%8E%8B%E4%BA%94%22%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22appname%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%E5%BE%AE%E4%BF%A1%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%E7%9F%AD%E4%BF%A1%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%E8%AE%A1%E7%AE%97%E5%99%A8%22%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22msgbody%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22.%2B%22%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22rules%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22telephone.call%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E6%89%93%E7%94%B5%E8%AF%9D%E7%BB%99%3Cname%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E6%89%93%E7%94%B5%E8%AF%9D%E7%BB%99(%E5%BC%A0%E4%B8%89%7C%E6%9D%8E%E5%9B%9B%7C%E7%8E%8B%E4%BA%94)%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E6%89%93%E7%BB%99%3Cname%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E6%89%93%E7%BB%99(%E5%BC%A0%E4%B8%89%7C%E6%9D%8E%E5%9B%9B%7C%E7%8E%8B%E4%BA%94)%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E5%91%BC%E5%8F%AB%3Cname%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E5%91%BC%E5%8F%AB(%E5%BC%A0%E4%B8%89%7C%E6%9D%8E%E5%9B%9B%7C%E7%8E%8B%E4%BA%94)%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E7%BB%99%3Cname%3E%E6%89%93%E7%94%B5%E8%AF%9D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E7%BB%99(%E5%BC%A0%E4%B8%89%7C%E6%9D%8E%E5%9B%9B%7C%E7%8E%8B%E4%BA%94)%E6%89%93%E7%94%B5%E8%AF%9D%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22contacts.view%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E6%9F%A5%E7%9C%8B%3Cname%3E%E7%9A%84%E7%94%B5%E8%AF%9D%E5%8F%B7%E7%A0%81%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E6%9F%A5%E7%9C%8B(%E5%BC%A0%E4%B8%89%7C%E6%9D%8E%E5%9B%9B%7C%E7%8E%8B%E4%BA%94)%E7%9A%84%E7%94%B5%E8%AF%9D%E5%8F%B7%E7%A0%81%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E6%9F%A5%E7%9C%8B%3Cname%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E6%9F%A5%E7%9C%8B(%E5%BC%A0%E4%B8%89%7C%E6%9D%8E%E5%9B%9B%7C%E7%8E%8B%E4%BA%94)%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22contacts.create%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E6%96%B0%E5%BB%BA%E8%81%94%E7%B3%BB%E4%BA%BA%3Cname%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E6%96%B0%E5%BB%BA%E8%81%94%E7%B3%BB%E4%BA%BA(%E5%BC%A0%E4%B8%89%7C%E6%9D%8E%E5%9B%9B%7C%E7%8E%8B%E4%BA%94)%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22contacts.remove%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E5%88%A0%E9%99%A4%3Cname%3E%E7%9A%84%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8F%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E5%88%A0%E9%99%A4(%E5%BC%A0%E4%B8%89%7C%E6%9D%8E%E5%9B%9B%7C%E7%8E%8B%E4%BA%94)%E7%9A%84%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8F%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22message.view%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E6%9F%A5%E7%9C%8B%E6%9C%AA%E8%AF%BB%E7%9F%AD%E4%BF%A1%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E6%9F%A5%E7%9C%8B%E6%9C%AA%E8%AF%BB%E7%9F%AD%E4%BF%A1%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22message.send%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E5%8F%91%E7%9F%AD%E4%BF%A1%E7%BB%99%3Cname%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E5%8F%91%E7%9F%AD%E4%BF%A1%E7%BB%99(%E5%BC%A0%E4%B8%89%7C%E6%9D%8E%E5%9B%9B%7C%E7%8E%8B%E4%BA%94)%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E5%8F%91%E7%9F%AD%E4%BF%A1%E7%BB%99%3Cname%3E%E5%86%85%E5%AE%B9%E6%98%AF%3Cmsgbody%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E5%8F%91%E7%9F%AD%E4%BF%A1%E7%BB%99(%E5%BC%A0%E4%B8%89%7C%E6%9D%8E%E5%9B%9B%7C%E7%8E%8B%E4%BA%94)%E5%86%85%E5%AE%B9%E6%98%AF(.%2B)%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22name%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22msgbody%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22app.open%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E6%89%93%E5%BC%80%3Cappname%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E6%89%93%E5%BC%80(%E5%BE%AE%E4%BF%A1%7C%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE%7C%E7%9F%AD%E4%BF%A1%7C%E8%AE%A1%E7%AE%97%E5%99%A8)%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22appname%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E5%90%AF%E5%8A%A8%3Cappname%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E5%90%AF%E5%8A%A8(%E5%BE%AE%E4%BF%A1%7C%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE%7C%E7%9F%AD%E4%BF%A1%7C%E8%AE%A1%E7%AE%97%E5%99%A8)%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22appname%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22app.search%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E6%90%9C%E7%B4%A2%3Cappname%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E6%90%9C%E7%B4%A2(%E5%BE%AE%E4%BF%A1%7C%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE%7C%E7%9F%AD%E4%BF%A1%7C%E8%AE%A1%E7%AE%97%E5%99%A8)%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22appname%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22app.download%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22origin%22%3A%20%22%E4%B8%8B%E8%BD%BD%3Cappname%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22pattern%22%3A%20%22%5E%E4%B8%8B%E8%BD%BD(%E5%BE%AE%E4%BF%A1%7C%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE%7C%E7%9F%AD%E4%BF%A1%7C%E8%AE%A1%E7%AE%97%E5%99%A8)%24%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22groups%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22appname%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22grammar%22%3A%20%22%3Cname%3E%20%3D%20%E5%BC%A0%E4%B8%89%7C%20%5Cn%E6%9D%8E%E5%9B%9B%7C%20%5Cn%E7%8E%8B%E4%BA%94%3B%5Cn%3Cappname%3E%20%3D%20%E5%BE%AE%E4%BF%A1%7C%20%5Cn%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE%7C%20%5Cn%E7%9F%AD%E4%BF%A1%7C%20%5Cn%E8%AE%A1%E7%AE%97%E5%99%A8%3B%5Cn%3Cmsgbody%3E%20%3D%20%E8%AF%8D%E6%9D%A1%E9%BB%98%E8%AE%A4%E5%80%BC%3B%5Cn%3Cauto_create_node%3E%20%3D%20%E6%9F%A5%E7%9C%8B%E6%9C%AA%E8%AF%BB%E7%9F%AD%E4%BF%A1%3B%5Cn%3C_wakeup%3E%20%3D%20%E5%94%A4%E9%86%92%E8%AF%8D%E5%8D%A0%E4%BD%8D%E7%AC%A6%3B%5Cn%5Cn%5Cn_SCENE_ID_%200%5Cn%5Cn(%20%3Cauto_create_node%3E%20)%5Cn%5Cn(%20%3C_wakeup%3E%3Cauto_create_node%3E%20)%5Cn%5Cn(%20%E6%89%93%E7%94%B5%E8%AF%9D%E7%BB%99%3Cname%3E%20)%5Cn(%20%3C_wakeup%3E%E6%89%93%E7%94%B5%E8%AF%9D%E7%BB%99%3Cname%3E%20)%5Cn(%20%E6%89%93%E7%BB%99%3Cname%3E%20)%5Cn(%20%3C_wakeup%3E%E6%89%93%E7%BB%99%3Cname%3E%20)%5Cn(%20%E5%91%BC%E5%8F%AB%3Cname%3E%20)%5Cn(%20%3C_wakeup%3E%E5%91%BC%E5%8F%AB%3Cname%3E%20)%5Cn(%20%E7%BB%99%3Cname%3E%E6%89%93%E7%94%B5%E8%AF%9D%20)%5Cn(%20%3C_wakeup%3E%E7%BB%99%3Cname%3E%E6%89%93%E7%94%B5%E8%AF%9D%20)%5Cn(%20%E6%9F%A5%E7%9C%8B%3Cname%3E%E7%9A%84%E7%94%B5%E8%AF%9D%E5%8F%B7%E7%A0%81%20)%5Cn(%20%3C_wakeup%3E%E6%9F%A5%E7%9C%8B%3Cname%3E%E7%9A%84%E7%94%B5%E8%AF%9D%E5%8F%B7%E7%A0%81%20)%5Cn(%20%E6%9F%A5%E7%9C%8B%3Cname%3E%20)%5Cn(%20%3C_wakeup%3E%E6%9F%A5%E7%9C%8B%3Cname%3E%20)%5Cn(%20%E6%96%B0%E5%BB%BA%E8%81%94%E7%B3%BB%E4%BA%BA%3Cname%3E%20)%5Cn(%20%3C_wakeup%3E%E6%96%B0%E5%BB%BA%E8%81%94%E7%B3%BB%E4%BA%BA%3Cname%3E%20)%5Cn(%20%E5%88%A0%E9%99%A4%3Cname%3E%E7%9A%84%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8F%20)%5Cn(%20%3C_wakeup%3E%E5%88%A0%E9%99%A4%3Cname%3E%E7%9A%84%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8F%20)%5Cn(%20%E5%8F%91%E7%9F%AD%E4%BF%A1%E7%BB%99%3Cname%3E%20)%5Cn(%20%3C_wakeup%3E%E5%8F%91%E7%9F%AD%E4%BF%A1%E7%BB%99%3Cname%3E%20)%5Cn(%20%E5%8F%91%E7%9F%AD%E4%BF%A1%E7%BB%99%3Cname%3E%E5%86%85%E5%AE%B9%E6%98%AF%3Cmsgbody%3E%20)%5Cn(%20%3C_wakeup%3E%E5%8F%91%E7%9F%AD%E4%BF%A1%E7%BB%99%3Cname%3E%E5%86%85%E5%AE%B9%E6%98%AF%3Cmsgbody%3E%20)%5Cn(%20%E6%89%93%E5%BC%80%3Cappname%3E%20)%5Cn(%20%3C_wakeup%3E%E6%89%93%E5%BC%80%3Cappname%3E%20)%5Cn(%20%E5%90%AF%E5%8A%A8%3Cappname%3E%20)%5Cn(%20%3C_wakeup%3E%E5%90%AF%E5%8A%A8%3Cappname%3E%20)%5Cn(%20%E6%90%9C%E7%B4%A2%3Cappname%3E%20)%5Cn(%20%3C_wakeup%3E%E6%90%9C%E7%B4%A2%3Cappname%3E%20)%5Cn(%20%E4%B8%8B%E8%BD%BD%3Cappname%3E%20)%5Cn(%20%3C_wakeup%3E%E4%B8%8B%E8%BD%BD%3Cappname%3E%20)%5Cn%22%2C%0A%20%20%20%20%22origin_slots%22%3A%20%22name%20%3D%20%E5%BC%A0%E4%B8%89%2C%20%E6%9D%8E%E5%9B%9B%2C%20%E7%8E%8B%E4%BA%94%5Cnappname%20%3D%20%E5%BE%AE%E4%BF%A1%2C%20%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE%2C%20%E7%9F%AD%E4%BF%A1%2C%20%E8%AE%A1%E7%AE%97%E5%99%A8%5Cnmsgbody%20%3D%20*%22%2C%0A%20%20%20%20%22origin_rules%22%3A%20%22telephone.call%20%20%20%20%20%3D%20%E6%89%93%E7%94%B5%E8%AF%9D%E7%BB%99%3Cname%3E%2C%20%E6%89%93%E7%BB%99%3Cname%3E%2C%20%E5%91%BC%E5%8F%AB%3Cname%3E%2C%E7%BB%99%3Cname%3E%E6%89%93%E7%94%B5%E8%AF%9D%5Cncontacts.view%20%20%20%20%20%3D%20%E6%9F%A5%E7%9C%8B%3Cname%3E%E7%9A%84%E7%94%B5%E8%AF%9D%E5%8F%B7%E7%A0%81%2C%20%E6%9F%A5%E7%9C%8B%3Cname%3E%5Cncontacts.create%20%20%3D%20%E6%96%B0%E5%BB%BA%E8%81%94%E7%B3%BB%E4%BA%BA%3Cname%3E%5Cncontacts.remove%3D%20%E5%88%A0%E9%99%A4%3Cname%3E%E7%9A%84%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8F%5Cnmessage.view%20%20%20%20%20%3D%20%E6%9F%A5%E7%9C%8B%E6%9C%AA%E8%AF%BB%E7%9F%AD%E4%BF%A1%5Cnmessage.send%20%20%20%20%3D%20%E5%8F%91%E7%9F%AD%E4%BF%A1%E7%BB%99%3Cname%3E%2C%20%E5%8F%91%E7%9F%AD%E4%BF%A1%E7%BB%99%3Cname%3E%E5%86%85%E5%AE%B9%E6%98%AF%3Cmsgbody%3E%5Cnapp.open%20%20%20%20%20%20%20%20%20%20%20%20%3D%20%E6%89%93%E5%BC%80%3Cappname%3E%2C%20%E5%90%AF%E5%8A%A8%3Cappname%3E%5Cnapp.search%20%20%20%20%20%20%20%20%20%3D%20%E6%90%9C%E7%B4%A2%3Cappname%3E%5Cnapp.download%20%20%20%20%3D%20%E4%B8%8B%E8%BD%BD%3Cappname%3E%22%0A%7D \ No newline at end of file diff --git a/src/sdk/resources/asr_resource/bds_easr_input_model.dat b/src/sdk/resources/asr_resource/bds_easr_input_model.dat deleted file mode 100644 index bc34a05..0000000 Binary files a/src/sdk/resources/asr_resource/bds_easr_input_model.dat and /dev/null differ diff --git a/src/sdk/resources/asr_resource/bds_easr_mfe_cmvn.dat b/src/sdk/resources/asr_resource/bds_easr_mfe_cmvn.dat deleted file mode 100644 index 342b96f..0000000 --- a/src/sdk/resources/asr_resource/bds_easr_mfe_cmvn.dat +++ /dev/null @@ -1,54 +0,0 @@ -vec 26 -1.485246e+01 -1.579741e+01 -1.663629e+01 -1.698390e+01 -1.708107e+01 -1.745045e+01 -1.752832e+01 -1.758490e+01 -1.746364e+01 -1.743286e+01 -1.744198e+01 -1.735617e+01 -1.735499e+01 -1.730315e+01 -1.726894e+01 -1.729055e+01 -1.728198e+01 -1.718504e+01 -1.712417e+01 -1.710584e+01 -1.715915e+01 -1.723995e+01 -1.730050e+01 -1.728485e+01 -1.728487e+01 -1.729697e+01 -vec 26 -2.764144e-01 -2.703758e-01 -2.584008e-01 -2.514187e-01 -2.496835e-01 -2.436650e-01 -2.391809e-01 -2.393867e-01 -2.416821e-01 -2.443231e-01 -2.473226e-01 -2.507182e-01 -2.540205e-01 -2.566869e-01 -2.590701e-01 -2.611003e-01 -2.630226e-01 -2.658522e-01 -2.699072e-01 -2.724641e-01 -2.723619e-01 -2.699174e-01 -2.670183e-01 -2.660550e-01 -2.658852e-01 -2.637595e-01 diff --git a/src/sdk/resources/asr_resource/bds_easr_mfe_dnn.dat b/src/sdk/resources/asr_resource/bds_easr_mfe_dnn.dat deleted file mode 100644 index 956531a..0000000 Binary files a/src/sdk/resources/asr_resource/bds_easr_mfe_dnn.dat and /dev/null differ diff --git a/src/sdk/resources/asr_resource/bds_easr_wakeup_words.dat b/src/sdk/resources/asr_resource/bds_easr_wakeup_words.dat deleted file mode 100644 index 06ef067..0000000 --- a/src/sdk/resources/asr_resource/bds_easr_wakeup_words.dat +++ /dev/null @@ -1 +0,0 @@ -fAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZBfAEYGGtEYXgB_ZB \ No newline at end of file diff --git a/src/sdk/resources/asr_resource/bds_license.dat b/src/sdk/resources/asr_resource/bds_license.dat deleted file mode 100644 index 7eb96b2..0000000 --- a/src/sdk/resources/asr_resource/bds_license.dat +++ /dev/null @@ -1 +0,0 @@ -66af2eef7a9e6cf37646e6a0c9c0abcbb2149789b4a8c5532796731a694e7254b2f9c4815e0dd162633078eec0e09d31d88485feb9c9980c7d47bd98b0cb413e749e35f7751fa6dc05efe64003bbf8e1c145e4c9b1a625e268cb9bca9b123f7c13992c4a751a85bf356019726c17197279b637d6868a5fe93a59b54cedf4d60d844782908589335de28e5fe6eeba404ee827431a2ee60edaf013c2ca14ba062a2e8e3ee99ec7664a48e646e216a1e7267971fdad4d14f14dda1912723e87408cb244ac92321f6abf04df4a6bf6c2a05a0aecd4d307ed10c461a109315a7bf0b8dd2870d59c4e8ea1b5395fa15da2a4f3f7081cc6bb8543b8f4e240838eb41290 \ No newline at end of file diff --git a/src/sdk/resources/asr_resource/chuangmi/bds_easr_dnn_wakeup_model.dat b/src/sdk/resources/asr_resource/chuangmi/bds_easr_dnn_wakeup_model.dat deleted file mode 100644 index 2318dc4..0000000 Binary files a/src/sdk/resources/asr_resource/chuangmi/bds_easr_dnn_wakeup_model.dat and /dev/null differ diff --git a/src/sdk/resources/asr_resource/end2end_wakeup_far.dat b/src/sdk/resources/asr_resource/end2end_wakeup_far.dat deleted file mode 100644 index 22709e4..0000000 Binary files a/src/sdk/resources/asr_resource/end2end_wakeup_far.dat and /dev/null differ diff --git a/src/sdk/resources/asr_resource/global.cmvn b/src/sdk/resources/asr_resource/global.cmvn deleted file mode 100644 index 342b96f..0000000 --- a/src/sdk/resources/asr_resource/global.cmvn +++ /dev/null @@ -1,54 +0,0 @@ -vec 26 -1.485246e+01 -1.579741e+01 -1.663629e+01 -1.698390e+01 -1.708107e+01 -1.745045e+01 -1.752832e+01 -1.758490e+01 -1.746364e+01 -1.743286e+01 -1.744198e+01 -1.735617e+01 -1.735499e+01 -1.730315e+01 -1.726894e+01 -1.729055e+01 -1.728198e+01 -1.718504e+01 -1.712417e+01 -1.710584e+01 -1.715915e+01 -1.723995e+01 -1.730050e+01 -1.728485e+01 -1.728487e+01 -1.729697e+01 -vec 26 -2.764144e-01 -2.703758e-01 -2.584008e-01 -2.514187e-01 -2.496835e-01 -2.436650e-01 -2.391809e-01 -2.393867e-01 -2.416821e-01 -2.443231e-01 -2.473226e-01 -2.507182e-01 -2.540205e-01 -2.566869e-01 -2.590701e-01 -2.611003e-01 -2.630226e-01 -2.658522e-01 -2.699072e-01 -2.724641e-01 -2.723619e-01 -2.699174e-01 -2.670183e-01 -2.660550e-01 -2.658852e-01 -2.637595e-01 diff --git a/src/sdk/resources/asr_resource/hmm_wakeup_far.dat b/src/sdk/resources/asr_resource/hmm_wakeup_far.dat deleted file mode 100644 index 2a98822..0000000 Binary files a/src/sdk/resources/asr_resource/hmm_wakeup_far.dat and /dev/null differ diff --git a/src/sdk/resources/asr_resource/vad.dnn b/src/sdk/resources/asr_resource/vad.dnn deleted file mode 100644 index 956531a..0000000 Binary files a/src/sdk/resources/asr_resource/vad.dnn and /dev/null differ diff --git a/src/sdk/sample/asr/.BDSpeechSDK2.supp.swp b/src/sdk/sample/asr/.BDSpeechSDK2.supp.swp deleted file mode 100644 index 2c84309..0000000 Binary files a/src/sdk/sample/asr/.BDSpeechSDK2.supp.swp and /dev/null differ diff --git a/src/sdk/sample/asr/BDS_Ident.dat b/src/sdk/sample/asr/BDS_Ident.dat deleted file mode 100644 index 676ec20..0000000 --- a/src/sdk/sample/asr/BDS_Ident.dat +++ /dev/null @@ -1 +0,0 @@ -79bb1333ee01a55a5e1f51286d7c4bc4 \ No newline at end of file diff --git a/src/sdk/sample/asr/Makefile b/src/sdk/sample/asr/Makefile deleted file mode 100644 index 020441a..0000000 --- a/src/sdk/sample/asr/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -## asr Makefile ## -CC=g++ -#AR=ar - -#FILE_NAME=$(src) -FILE_NAME=src/main.cpp -INC_PATH= -I../../include\ - -I../../include/ASR\ - -SRC_PATH=./src -OBJ_PATH=. -TARGET=$(basename $(FILE_NAME)) -LIB_PATH=../../lib -EXTERN_PATH=../../extern/lib -TARGET_PATH=./ - -CPPFLAGS1=-Wall -O0 -fPIC -g -D__LINUX__ -Wno-unknown-pragmas -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -CPPFLAGS= $(CPPFLAGS1) $(LIB_PATH)/libBDSpeechSDK.a $(EXTERN_PATH)/libcurl.a $(EXTERN_PATH)/libiconv.a $(EXTERN_PATH)/libz.a $(EXTERN_PATH)/libssl.a $(EXTERN_PATH)/libcrypto.a $(EXTERN_PATH)/libuuid.a -lrt -ldl -lpthread -SRC_FILE=$(shell cd $(SRC_PATH)&&echo *.cpp) -SRC:=$(foreach n,$(SRC_FILE),$(SRC_PATH)/$(n)) - -OBJ_FILE=$(SRC_FILE:.cpp=.o) -OBJ:=$(foreach n,$(OBJ_FILE),$(OBJ_PATH)/$(n)) - -DEP_FILE=$(SRC_FILE:.cpp=.d) -DEP:=$(foreach n,$(DEP_FILE),$(OBJ_PATH)/$(n)) - -$(TARGET):$(SRC) - $(CC) -o $(TARGET) ./$(FILE_NAME) $(INC_PATH) $(CPPFLAGS) - -mv $@ $(TARGET_PATH) -clean: - -rm -f $(OBJ) - -rm -f $(TARGET) - -cleanall: - -rm -f $(OBJ) - -rm -f $(TARGET) - - diff --git a/src/sdk/sample/asr/README.md b/src/sdk/sample/asr/README.md deleted file mode 100644 index cfd15f5..0000000 --- a/src/sdk/sample/asr/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# ASR demo - - - -简单地并发测试sdk,测试pcm目录下的音频, 原始音频目前仅支持16k采样率 - - - -测试成功后,可以修改 asr_set_config_params内的设置参数 \ No newline at end of file diff --git a/src/sdk/sample/asr/asr.log b/src/sdk/sample/asr/asr.log deleted file mode 100644 index e69de29..0000000 diff --git a/src/sdk/sample/asr/build_and_run.sh b/src/sdk/sample/asr/build_and_run.sh deleted file mode 100644 index 457cd0c..0000000 --- a/src/sdk/sample/asr/build_and_run.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -make && echo && echo "build success, wait 3s to run" && sleep 3 && ./main diff --git a/src/sdk/sample/asr/main b/src/sdk/sample/asr/main deleted file mode 100644 index 962f525..0000000 Binary files a/src/sdk/sample/asr/main and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/0.pcm b/src/sdk/sample/asr/pcm/0.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asr/pcm/0.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/1.pcm b/src/sdk/sample/asr/pcm/1.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asr/pcm/1.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/16k-0.pcm b/src/sdk/sample/asr/pcm/16k-0.pcm deleted file mode 100644 index 0501041..0000000 Binary files a/src/sdk/sample/asr/pcm/16k-0.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/16k-1.pcm b/src/sdk/sample/asr/pcm/16k-1.pcm deleted file mode 100644 index 199d30e..0000000 Binary files a/src/sdk/sample/asr/pcm/16k-1.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/2.pcm b/src/sdk/sample/asr/pcm/2.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asr/pcm/2.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/3.pcm b/src/sdk/sample/asr/pcm/3.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asr/pcm/3.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/4.pcm b/src/sdk/sample/asr/pcm/4.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asr/pcm/4.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/5.pcm b/src/sdk/sample/asr/pcm/5.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asr/pcm/5.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/6.pcm b/src/sdk/sample/asr/pcm/6.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asr/pcm/6.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/7.pcm b/src/sdk/sample/asr/pcm/7.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asr/pcm/7.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/8.pcm b/src/sdk/sample/asr/pcm/8.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asr/pcm/8.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/8k-0.pcm b/src/sdk/sample/asr/pcm/8k-0.pcm deleted file mode 100644 index 01f9ad6..0000000 Binary files a/src/sdk/sample/asr/pcm/8k-0.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/pcm/9.pcm b/src/sdk/sample/asr/pcm/9.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asr/pcm/9.pcm and /dev/null differ diff --git a/src/sdk/sample/asr/src/main.cpp b/src/sdk/sample/asr/src/main.cpp deleted file mode 100644 index ea65da3..0000000 --- a/src/sdk/sample/asr/src/main.cpp +++ /dev/null @@ -1,430 +0,0 @@ -#include -#include -#include -#include -#include - -//SDK interface -#include "BDSpeechSDK.hpp" -#include "bds_ASRDefines.hpp" -#include "bds_asr_key_definitions.hpp" - -using namespace std; - -/** - * 0. demo不用修改任何代码,可以直接运行。测试成功后请进行以下步骤 - * 1. 请修改asr_set_config_params 函数,配置您的参数。 - * 2. THREAD_NUM 修改同时进行的识别线程, - * 3. 测试完毕后,请确认修改asr_set_start_params里面app参数 - */ - -char audio_dir[256] = "./pcm"; // 与THREAD_NUM一起决定测试的文件名 -const int THREAD_NUM = 1; // 测试的线程数,最大不能超过10 -pthread_t thread_ids[THREAD_NUM]; // 线程信息 -pthread_mutex_t thread_mutexes[THREAD_NUM]; // 锁信息,用于同步SDK内部回调线程和用户的调用线程的asr_finish_tags -bool asr_finish_tags[THREAD_NUM] = {0}; //线程是否结束识别 -int thread_sequeces[THREAD_NUM] = {0}; -char file_names[THREAD_NUM][256]; // 每个线程识别的文件名 - -/** - * 格式化时间 - */ -std::string get_gmt_time() { - struct timeval tv; - gettimeofday(&tv, NULL); - - struct tm current_time; - localtime_r(&tv.tv_sec, ¤t_time); - - int year = (1900 + current_time.tm_year); - int month = (1 + current_time.tm_mon); - int day = current_time.tm_mday; - int hour = current_time.tm_hour; - int minute = current_time.tm_min; - int sec = current_time.tm_sec; - int msec = (int) (tv.tv_usec / 1000); - - char time_ch_buf[128] = {0}; - snprintf(time_ch_buf, sizeof(time_ch_buf) / sizeof(char), "%d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day, - hour, minute, sec, msec); - return std::string(time_ch_buf); -} - -/** - * 请根据文档说明设置参数 - */ -void asr_set_config_params(bds::BDSSDKMessage &cfg_params) { - //const bds::TBDVoiceRecognitionDebugLogLevel sdk_log_level = bds::EVRDebugLogLevelTrace; - const bds::TBDVoiceRecognitionDebugLogLevel sdk_log_level = bds::EVRDebugLogLevelOff; // 关闭详细日志 - - // app_id app_key app_secret 请测试成功后替换为您在网页上申请的appId appKey和appSecret - const std::string app_id = "10555002"; - const std::string chunk_key = "jhRA15uv8Lvd4r9qbtmOODMv"; - const std::string secret_key = "f0a12f8261e1121861a1cd3f4ed02f68"; - - const std::string product_id = "15362"; - // const std::string product_id = "1536";// 普通话搜索模型:1536,普通话搜索模型+语义理解 15361, 普通话输入法模型(有逗号) 1537 , 8001 8002 - - cfg_params.name = bds::ASR_CMD_CONFIG; - - cfg_params.set_parameter(bds::ASR_PARAM_KEY_APP_ID, app_id); - - // 自训练平台上线模型的调用参数,与product_id 8001 或 8002连用。 - // cfg_params.set_parameter(bds::ASR_PARAM_KEY_LMID, 1068); // 设为 product_id = 8002 - - cfg_params.set_parameter(bds::ASR_PARAM_KEY_CHUNK_KEY, chunk_key); - - cfg_params.set_parameter(bds::ASR_PARAM_KEY_PRODUCT_ID, product_id); - cfg_params.set_parameter(bds::COMMON_PARAM_KEY_DEBUG_LOG_LEVEL, sdk_log_level); - - // float vad_pause_frames = 30; //设置vad语句静音切分门限(帧), 30帧 = 300ms - // cfg_params.set_parameter(bds::ASR_PARAM_KEY_MAX_SPEECH_PAUSE, vad_pause_frames); - - - // cfg_params.set_parameter(bds::ASR_PARAM_KEY_SAVE_AUDIO_ENABLE, 1); //是否存识别的音频 - // cfg_params.set_parameter(bds::ASR_PARAM_KEY_SAVE_AUDIO_PATH, "sdk_save_audio.d"); //存音频的路径 - - cfg_params.set_parameter(bds::ASR_PARAM_KEY_ENABLE_LONG_SPEECH, 1); // 强制固定值 - cfg_params.set_parameter(bds::ASR_PARAM_KEY_CHUNK_ENABLE, 1); // 强制固定值 - const std::string mfe_dnn_file_path = "../../resources/asr_resource/bds_easr_mfe_dnn.dat"; // bds_easr_mfe_dnn.dat文件路径 - const std::string mfe_cmvn_file_path = "../../resources/asr_resource/bds_easr_mfe_cmvn.dat"; // bds_easr_mfe_cmvn.dat文件路径 - cfg_params.set_parameter(bds::ASR_PARAM_KEY_MFE_DNN_DAT_FILE, mfe_dnn_file_path); // 强制固定值 - cfg_params.set_parameter(bds::ASR_PARAM_KEY_MFE_CMVN_DAT_FILE, mfe_cmvn_file_path); // 强制固定值 - cfg_params.set_parameter(bds::ASR_PARAM_KEY_COMPRESSION_TYPE, bds::EVR_AUDIO_COMPRESSION_PCM); - // cfg_params.set_parameter(bds::ASR_PARAM_KEY_COMPRESSION_TYPE, bds::EVR_AUDIO_COMPRESSION_BV32); // 有损压缩, 可能遇见音频压缩问题 - -} - -// 设置启动参数 -void asr_set_start_params(bds::BDSSDKMessage &start_params) { - const std::string app = "YourOwnName"; - - start_params.name = bds::ASR_CMD_START; - start_params.set_parameter(bds::ASR_PARAM_KEY_APP, app); - start_params.set_parameter(bds::ASR_PARAM_KEY_PLATFORM, "linux"); //固定值 - start_params.set_parameter(bds::ASR_PARAM_KEY_SDK_VERSION, "LINUX TEST"); //固定值 -} - -/** - * @param file_path IN 文件路径 - * @param push_cmd IN 固定值 bds::ASR_CMD_PUSH_AUDIO - * @param sdk BDSpeechSDK - * @param thread_seq demo里的线程编号 用于获取如asr_finish_tags[thread_seq]线程相关的信息 - */ -int asr_online_pushaudio(const char *file_path, const std::string &push_cmd, bds::BDSpeechSDK *sdk, int thread_seq) { - const int audio_buf_len = 320; // 建议320字节一个包 - const double per_send_seconds = 0.01; //320字节 ,16000采样率 sleep 10ms, sleep时间与包大小成正比 - char audio_buf[audio_buf_len]; - - FILE *err_output_file = stderr; - - FILE *fp = fopen(file_path, "rb"); - - if (!fp) { - fprintf(err_output_file, "open audio data failed\n"); - return 1; - } - - std::string err_msg; - bds::BDSSDKMessage push_params; - push_params.name = push_cmd; - - bool asr_finished = false; - - while (!feof(fp) && !asr_finished) { - size_t read_cnt = fread(audio_buf, 1, audio_buf_len, fp); - if (read_cnt > 0) { - push_params.set_parameter(bds::DATA_CHUNK, audio_buf, (int) read_cnt); - // printf("[%s]push_audio data, size %ld\n", get_gmt_time().c_str(), read_cnt); - if (!sdk->post(push_params, err_msg)) { - fprintf(err_output_file, "push audio data failed for %s\n", err_msg.c_str()); - } - //考虑到解码器的识别速度,此处的sleep必不可少,否则影响识别 - usleep(static_cast(per_send_seconds * 1000 * 1000)); - } - - pthread_mutex_lock(&thread_mutexes[thread_seq]); - asr_finished = asr_finish_tags[thread_seq]; - pthread_mutex_unlock(&thread_mutexes[thread_seq]); - } - - //告诉sdk,后续不会再post音频数据 , 注意这个调用之后需要紧接着调用asr_online_stop - push_params.set_parameter(bds::DATA_CHUNK, audio_buf, 0); - printf("[%s]push_audio finish\n", get_gmt_time().c_str()); - if (!sdk->post(push_params, err_msg)) { - fprintf(err_output_file, "push audio data failed for %s\n", err_msg.c_str()); - } - - fclose(fp); - return 0; -} - -/** - * SDK 识别过程中的回调,注意回调产生在SDK内部的线程中,并非调用线程。 - * @param message IN SDK的回调信息 - * @param user_arg IN 用户设置set_event_listener的第二个参数 - * - */ -void asr_output_callback(bds::BDSSDKMessage &message, void *user_arg) { - int thread_seq = *(int *) user_arg; - FILE *err_output_file = stderr; - - if (message.name != bds::asr_callback_name) { - fprintf(err_output_file, "shouldn't call\n"); - return; - } - - int status = 0; - - if (!message.get_parameter(bds::CALLBACK_ASR_STATUS, status)) { - fprintf(err_output_file, "get status failed\n"); - return; - } - - FILE *result_output_file = stdout; - const char *time = get_gmt_time().c_str(); - switch (status) { - case bds::EVoiceRecognitionClientWorkStatusStartWorkIng: { - fprintf(result_output_file, "[%s]识别工作开始\n", time); - fflush(result_output_file); - break; - } - - case bds::EVoiceRecognitionClientWorkStatusStart: { // 一句话开始 - fprintf(result_output_file, "[%s]检测到开始说话\n", time); - fflush(result_output_file); - break; - } - - case bds::EVoiceRecognitionClientWorkStatusEnd: { // 一句话结束 - fprintf(result_output_file, "[%s]检测到说话结束\n", time); - fflush(result_output_file); - break; - } - - case bds::EVoiceRecognitionClientWorkStatusFlushData: { // 连续上屏,中间结果 - std::string json_result; - message.get_parameter(bds::CALLBACK_ASR_RESULT, json_result); - fprintf(result_output_file, "[%s]patial result: %s\n", time, json_result.c_str()); - fflush(result_output_file); - break; - } - - case bds::EVoiceRecognitionClientWorkStatusFinish: { //一句话的最终结果 - std::string json_result; - message.get_parameter(bds::CALLBACK_ASR_RESULT, json_result); - fprintf(result_output_file, "[%s]final result: %s\n", time, json_result.c_str()); - fflush(result_output_file); - break; - } - - case bds::EVoiceRecognitionClientWorkStatusChunkNlu: { //语义解析 - const char *buf; - int len = 0; - message.get_parameter(bds::DATA_CHUNK, buf, len); - fprintf(result_output_file, "[%s]nlu result:", time); - for (int i = 0; i < len; ++i) { - fprintf(result_output_file, "%c", buf[i]); - } - fprintf(result_output_file, "\n"); - fflush(result_output_file); - break; - } - - //case bds::EVoiceRecognitionClientWorkStatusChunkThirdData: { //第三方结果 - // const char* buf; - // int len = 0; - // message.get_parameter(bds::DATA_CHUNK, buf, len); - // //第三方结果未必是文本字符串,所以以%s打印未必有意义 - // fprintf(result_output_file, "third final result len[%d]\n", len); - // //for (int i = 0; i < len; ++i) fprintf(result_output_file, "%c", buf[i]); - // fprintf(result_output_file, "\n"); - // fflush(result_output_file); - // break; - //} - - case bds::EVoiceRecognitionClientWorkStatusLongSpeechEnd: { - // 长语音结束状态 该实例处于空闲状态 - pthread_mutex_lock(&thread_mutexes[thread_seq]); - asr_finish_tags[thread_seq] = true; - fprintf(result_output_file, "识别完成\n"); - fflush(result_output_file); - pthread_mutex_unlock(&thread_mutexes[thread_seq]); - break; - } - - case bds::EVoiceRecognitionClientWorkStatusError: { - // 产生错误 该实例处于空闲状态 - int err_code = 0; - int err_domain = 0; - std::string err_desc; - message.get_parameter(bds::CALLBACK_ERROR_CODE, err_code); - message.get_parameter(bds::CALLBACK_ERROR_DOMAIN, err_domain); - message.get_parameter(bds::CALLBACK_ERROR_DESC, err_desc); - - std::string sn; - message.get_parameter(bds::CALLBACK_ERROR_SERIAL_NUM, sn); - - pthread_mutex_lock(&thread_mutexes[thread_seq]); - asr_finish_tags[thread_seq] = true; - fprintf(result_output_file, - "[%s]识别出错, err_code: %d, err_domain: %d,\ - err_desc: %s, sn: %s\n", - get_gmt_time().c_str(), err_code, err_domain, err_desc.c_str(), sn.c_str()); - fflush(result_output_file); - pthread_mutex_unlock(&thread_mutexes[thread_seq]); - break; - } - - case bds::EVoiceRecognitionClientWorkStatusCancel: { - // 用户取消 该实例处于空闲状态 - pthread_mutex_lock(&thread_mutexes[thread_seq]); - asr_finish_tags[thread_seq] = true; - fprintf(result_output_file, "[%s]用户取消\n", get_gmt_time().c_str()); - fflush(result_output_file); - pthread_mutex_unlock(&thread_mutexes[thread_seq]); - break; - } - case bds::EVoiceRecognitionClientWorkStatusNewRecordData: - case bds::EVoiceRecognitionClientWorkStatusMeterLevel: - break; - default: { - fprintf(result_output_file, "其它状态%d\n", status); - break; - } - - //bds::EVoiceRecognitionClientWorkStatusChunkEnd : { // CHUNK: 识别过程结束 - //bds::EVoiceRecognitionClientWorkStatusChunkNlu, // CHUNK: 识别结果中的语义结果 - } -} - -/** - * 释放SDK - */ -void asr_online_release(bds::BDSpeechSDK *sdk) { - bds::BDSpeechSDK::release_instance(sdk); -} - -/** - * 发送停止命令 - */ -int asr_online_stop(bds::BDSpeechSDK *sdk) { - FILE *err_output_file = stderr; - std::string err_msg; - bds::BDSSDKMessage stop_params; - stop_params.name = bds::ASR_CMD_STOP; - - if (!sdk->post(stop_params, err_msg)) { - fprintf(err_output_file, "stop sdk failed for %s\n", err_msg.c_str()); - return 1; - } - - return 0; -} - -static void *asr_thread(void *arg) { - int thread_seq = *(int *) arg; - char *file_name = file_names[thread_seq]; - FILE *err_output_file = stderr; - fprintf(stdout, "Will recognize file: %s\n", file_name); - - fprintf(stdout, "sdk version :%s\n", bds::BDSpeechSDK::get_sdk_version().c_str()); - /* 0 设置日志文件路径,如不设置默认输出到stderr */ - bds::BDSpeechSDK::open_log_file("asr.log", 25); // 与BDSpeechSDK::close_log_file();配对使用。 - // 25 表示 日志文件大小约25*512k, 超过后SDK新建一个日志文件,旧日志文件覆盖到"asr.log.bak" - - /* 1 获取sdk实例 */ - std::string err_msg; - bds::BDSpeechSDK *sdk = bds::BDSpeechSDK::get_instance(bds::SDK_TYPE_ASR, err_msg); - - if (!sdk) { - fprintf(err_output_file, "thread %d, get sdk failed for %s\n", thread_seq, err_msg.c_str()); - return NULL; - } - - /* 2 设置输出回调 */ - sdk->set_event_listener(&asr_output_callback, (void *) &thread_seq); - - /* 3 设置并发送sdk配置参数 */ - bds::BDSSDKMessage cfg_params; - asr_set_config_params(cfg_params); - - if (!sdk->post(cfg_params, err_msg)) { - fprintf(err_output_file, "thread %d, init sdk failed for %s\n", thread_seq, err_msg.c_str()); - bds::BDSpeechSDK::release_instance(sdk); - return NULL; - } - - /* 4 设置并发送sdk启动参数 */ - bds::BDSSDKMessage start_params; - asr_set_start_params(start_params); - - if (!sdk->post(start_params, err_msg)) { - fprintf(err_output_file, "thread %d, start sdk failed for %s\n", thread_seq, err_msg.c_str()); - bds::BDSpeechSDK::release_instance(sdk); - return NULL; - } - - /* 5 传输音频数据 */ - int ret = asr_online_pushaudio(file_name, bds::ASR_CMD_PUSH_AUDIO, sdk, thread_seq); - - if (ret) { - fprintf(err_output_file, "thread %d, push audio failed\n", thread_seq); - asr_online_stop(sdk); - bds::BDSpeechSDK::release_instance(sdk); - return NULL; - } - - /* 6 发送停止传输音频数据标记 */ - asr_online_stop(sdk); - - /* 7 等待识别结束 */ - bool asr_finished = false; - - while (!asr_finished) { - usleep(10000); - pthread_mutex_lock(&thread_mutexes[thread_seq]); - asr_finished = asr_finish_tags[thread_seq]; - pthread_mutex_unlock(&thread_mutexes[thread_seq]); - } - - /* 8 关闭日志 ,如果之前调用过 open_log_file */ - bds::BDSpeechSDK::close_log_file(); - - /* 8 释放sdk */ - asr_online_release(sdk); - - fprintf(stdout, "[%s]thread[%d] finish\n", get_gmt_time().c_str(), thread_seq); - fflush(stdout); - return NULL; -} - -int main(int argc, char **argv) { - FILE *err_output_file = stderr; - - for (int i = 0; i < THREAD_NUM; ++i) { - thread_sequeces[i] = i; - pthread_mutex_init(&thread_mutexes[i], NULL); - snprintf(file_names[i], 256, "%s/16k-%d.pcm", audio_dir, i); - // 新线程中开启每个文件的识别 - int32_t ret = pthread_create(&thread_ids[i], NULL, asr_thread, - static_cast(thread_sequeces + i)); // thread_sequeces[i]的指针 - if (ret != 0) { - fprintf(err_output_file, "create thread failed[%d]\n", ret); - return 1; - } - } - - for (int i = 0; i < THREAD_NUM; ++i) { - int ret = pthread_join(thread_ids[i], NULL); // 等待所有线程结束 - - if (ret != 0) { - fprintf(err_output_file, "join thread failed[%d]\n", ret); - return 1; - } - } - - //所有任务结束,清理线程池 - bds::BDSpeechSDK::do_cleanup(); - return 0; -} diff --git a/src/sdk/sample/asr/valgrind.sh b/src/sdk/sample/asr/valgrind.sh deleted file mode 100644 index bd7cc39..0000000 --- a/src/sdk/sample/asr/valgrind.sh +++ /dev/null @@ -1,2 +0,0 @@ -#~/bin/sh -valgrind diff --git a/src/sdk/sample/asrDemo-srt/.idea/.name b/src/sdk/sample/asrDemo-srt/.idea/.name deleted file mode 100644 index fb52a5f..0000000 --- a/src/sdk/sample/asrDemo-srt/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -asrDemo_srt \ No newline at end of file diff --git a/src/sdk/sample/asrDemo-srt/.idea/asrDemo-srt.iml b/src/sdk/sample/asrDemo-srt/.idea/asrDemo-srt.iml deleted file mode 100644 index f08604b..0000000 --- a/src/sdk/sample/asrDemo-srt/.idea/asrDemo-srt.iml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/src/sdk/sample/asrDemo-srt/.idea/codeStyles/Project.xml b/src/sdk/sample/asrDemo-srt/.idea/codeStyles/Project.xml deleted file mode 100644 index 30aa626..0000000 --- a/src/sdk/sample/asrDemo-srt/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/sdk/sample/asrDemo-srt/.idea/codeStyles/codeStyleConfig.xml b/src/sdk/sample/asrDemo-srt/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index a55e7a1..0000000 --- a/src/sdk/sample/asrDemo-srt/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/sdk/sample/asrDemo-srt/.idea/misc.xml b/src/sdk/sample/asrDemo-srt/.idea/misc.xml deleted file mode 100644 index 79b3c94..0000000 --- a/src/sdk/sample/asrDemo-srt/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/sdk/sample/asrDemo-srt/.idea/modules.xml b/src/sdk/sample/asrDemo-srt/.idea/modules.xml deleted file mode 100644 index ca26241..0000000 --- a/src/sdk/sample/asrDemo-srt/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/src/sdk/sample/asrDemo-srt/.idea/workspace.xml b/src/sdk/sample/asrDemo-srt/.idea/workspace.xml deleted file mode 100644 index 53fbea4..0000000 --- a/src/sdk/sample/asrDemo-srt/.idea/workspace.xml +++ /dev/null @@ -1,543 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - eof - sleep - asr_resource - SECRT - _controller - waiting_to - std::endl - RETURN_RECOG_FINISH_OK - _Predicate - _is_finished - mutex - - - $PROJECT_DIR$ - $PROJECT_DIR$/src - - - - - - - - - true - DEFINITION_ORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1520928319000 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/sdk/sample/asrDemo2/CMakeLists.txt b/src/sdk/sample/asrDemo2/CMakeLists.txt deleted file mode 100644 index cb348d7..0000000 --- a/src/sdk/sample/asrDemo2/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -set(CMAKE_VERBOSE_MAKEFILE on) -set(CMAKE_BUILD_TYPE DEBUG) -project(asrDemo2) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -O0 -fPIC -D__LINUX__ -Wno-unknown-pragmas -D_GLIBCXX_USE_CXX11_ABI=0 -Wno-unused-function") -file(GLOB SOURCE_FILES "src/*.c*" "src/*/*.cpp") - -include_directories(../../extern/include ../../include ../../include/ASR) -link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../lib ${CMAKE_CURRENT_SOURCE_DIR}/../../extern/lib) -add_executable(asrDemo2 ${SOURCE_FILES}) -target_link_libraries(asrDemo2 BDSpeechSDK curl iconv z ssl crypto uuid rt dl pthread) \ No newline at end of file diff --git a/src/sdk/sample/asrDemo2/README.md b/src/sdk/sample/asrDemo2/README.md deleted file mode 100644 index 6c710bc..0000000 --- a/src/sdk/sample/asrDemo2/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# ASR demo 2 - -对sdk做出封装示例 - -测试成功后,可以修改 yours_main.cpp 内static void set_config(bds::BDSSDKMessage &cfg_params)内的设置参数 diff --git a/src/sdk/sample/asrDemo2/pcm/0.pcm b/src/sdk/sample/asrDemo2/pcm/0.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/0.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/1.pcm b/src/sdk/sample/asrDemo2/pcm/1.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/1.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/10.pcm b/src/sdk/sample/asrDemo2/pcm/10.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/10.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/11.pcm b/src/sdk/sample/asrDemo2/pcm/11.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/11.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/16k-0.pcm b/src/sdk/sample/asrDemo2/pcm/16k-0.pcm deleted file mode 100644 index 0501041..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/16k-0.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/16k-1.pcm b/src/sdk/sample/asrDemo2/pcm/16k-1.pcm deleted file mode 100644 index 199d30e..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/16k-1.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/2.pcm b/src/sdk/sample/asrDemo2/pcm/2.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/2.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/3.pcm b/src/sdk/sample/asrDemo2/pcm/3.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/3.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/4.pcm b/src/sdk/sample/asrDemo2/pcm/4.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/4.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/5.pcm b/src/sdk/sample/asrDemo2/pcm/5.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/5.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/6.pcm b/src/sdk/sample/asrDemo2/pcm/6.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/6.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/7.pcm b/src/sdk/sample/asrDemo2/pcm/7.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/7.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/8.pcm b/src/sdk/sample/asrDemo2/pcm/8.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/8.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/8k-0.pcm b/src/sdk/sample/asrDemo2/pcm/8k-0.pcm deleted file mode 100644 index 01f9ad6..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/8k-0.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/pcm/9.pcm b/src/sdk/sample/asrDemo2/pcm/9.pcm deleted file mode 100644 index 4003d5f..0000000 Binary files a/src/sdk/sample/asrDemo2/pcm/9.pcm and /dev/null differ diff --git a/src/sdk/sample/asrDemo2/run/Makefile b/src/sdk/sample/asrDemo2/run/Makefile deleted file mode 100644 index 9f7eae8..0000000 --- a/src/sdk/sample/asrDemo2/run/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -CC=g++ -#gcc -shared -Wl,--allow-multiple-definition -Wl,--whole-archive libBDSpeechSDK.a -Wl,--no-whole-archive -o libBDSpeechSDK.so -INC_PATH = -I../../../include\ - -I../../../include/ASR\ - -I./include -# 程序名称 -TARGET = asrDemo -# cpp hpp源代码路径 -SRC_PATH = ../src - -# .o 临时目录 -OBJ_PATH = obj - -# 编译 libasrdemo.a -CFLAGS_LIB = $(INC_PATH) -std=c++11 -fPIC -g -O0 -Wall -Wno-unknown-pragmas -D__LINUX__ -D_GLIBCXX_USE_CXX11_ABI=0 -LIB_SOURCE = $(wildcard $(SRC_PATH)/asrdemo/*.cpp) -LIB_OBJECT = $(patsubst %.cpp,$(OBJ_PATH)/asrdemo/%.o,$(notdir $(LIB_SOURCE))) - -# 编译 demo -CFLAGS_DEMO = $(INC_PATH) -std=c++11 -fPIC -g -O0 -Wall -Wno-unknown-pragmas -Wno-unused-function -D__LINUX__ -D_GLIBCXX_USE_CXX11_ABI=0 -DEMO_SOURCE = $(wildcard $(SRC_PATH)/yours_*.cpp) -DEMO_OBJECT = $(patsubst %.cpp,$(OBJ_PATH)/%.o,$(notdir $(DEMO_SOURCE))) - -# .a 库 -COMMON_LIBS = -lrt -ldl -lpthread -LIBS = -lBDSpeechSDK -lcurl -liconv -lz -lssl -lcrypto -luuid $(COMMON_LIBS) -OPT_LIBS_EXT=-L../../../lib -L../../../extern/lib -LIB_P=lib - - -$(TARGET):init lib/libasrdemo.a lib/libasrdemoall.so $(DEMO_OBJECT) -#使用lib/libasrdemo.a -#$(CC) $(DEMO_OBJECT) -o $(TARGET) $(OPT_LIBS_EXT) -L$(LIB_P) $(LIBS) -lasrdemo -#使用lib/libasrdemo.so - $(CC) $(DEMO_OBJECT) -o $(TARGET) -L$(LIB_P) -Wl,-rpath,$(LIB_P) -lasrdemoall -lrt -ldl -lpthread - @echo - @echo "Build Success" - @echo "Type : ./$(TARGET)" - -init: - mkdir -p $(OBJ_PATH)/asrdemo -# lib 目录 libasrdemoall.so - mkdir -p lib -# 头文件 目录 - mkdir -p include/asrdemo - cp $(SRC_PATH)/asrdemo/*.h* include/asrdemo - -lib/libasrdemo.a:init $(LIB_OBJECT) - ar cr lib/libasrdemo.a $(LIB_OBJECT) -lib/libasrdemoall.so:init $(LIB_OBJECT) - $(CC) -shared -fPIC -g $(LIB_OBJECT) $(OPT_LIBS_EXT) $(LIBS) -o lib/libasrdemoall.so - -$(OBJ_PATH)/asrdemo/%.o:$(SRC_PATH)/asrdemo/%.cpp - $(CC) $(CFLAGS_LIB) -c $< -o $@ -$(OBJ_PATH)/yours_%.o:$(SRC_PATH)/yours_%.cpp - $(CC) $(CFLAGS_DEMO) -c $< -o $@ -clean: - -rm -rf lib include $(OBJ_PATH) $(TARGET) BDS_Ident.dat asrdemo.log *.so diff --git a/src/sdk/sample/asrDemo2/run/build_and_run.sh b/src/sdk/sample/asrDemo2/run/build_and_run.sh deleted file mode 100644 index 14b3c1d..0000000 --- a/src/sdk/sample/asrDemo2/run/build_and_run.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -rm asrDemo core core.* -make clean && make && echo "build success, wait 3s to run" && sleep 3 && ./asrDemo - diff --git a/src/sdk/sample/asrDemo2/script/backup_log.sh b/src/sdk/sample/asrDemo2/script/backup_log.sh deleted file mode 100644 index f693db7..0000000 --- a/src/sdk/sample/asrDemo2/script/backup_log.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# asrdemo.log超过大小后,自动重命名为asrdemo.log.bak。本脚本自动重命名asrdemo.log.bak。 -# crontab运行的间隔根据实际测试结果调整。注意不要两次运行的间隔过长,导致asrdemo.log.bak获取不到。 -# 按照open_log_file第二个参数,即 -LOG_NAME="asrdemo.log.bak" -base_path=$(cd `dirname $0`; pwd) -run_path="${base_path}/../run" -now=$(date "+%Y%m%d_%H%M%S") -file_name="${run_path}/${LOG_NAME}" -if [ -f "${file_name}" ]; then - set -x - mv "${file_name}" "${file_name}.$now" -else - echo skip; -fi diff --git a/src/sdk/sample/asrDemo2/src/asrdemo/AsrdemoController.cpp b/src/sdk/sample/asrDemo2/src/asrdemo/AsrdemoController.cpp deleted file mode 100644 index 6722b74..0000000 --- a/src/sdk/sample/asrDemo2/src/asrdemo/AsrdemoController.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* - * BdSpeech.cpp - * - * Created on: Dec 12, 2017 - * Author: fu - */ -#include "AsrdemoController.hpp" -#include - -namespace asrdemo { - -#define CHECK_ERROR_THEN_RETURN(MSG) do{\ - if (_has_error) {\ - error_msg = MSG;\ - error_msg += ": ";\ - error_msg += _error_msg;\ - release();\ - return false;\ - }\ -}while(0); - -AsrdemoController::AsrdemoController(const std::string &app_name, const std::string &resource_path, - ResultListener &listener) : - _app_name(app_name), _resource_path(resource_path), _listener(listener), _is_configed(false), - _has_error(false) { - _sdk = bds::BDSpeechSDK::get_instance(bds::SDK_TYPE_ASR, _error_msg); - if (_sdk == nullptr) { - _has_error = true; - _error_msg = "BDSpeechSDK is NULL;"; - } - _push_params.name = bds::ASR_CMD_PUSH_AUDIO; -} - -AsrdemoController::~AsrdemoController() { - release(); -} - -bool AsrdemoController::config(bds::BDSSDKMessage &config_params, std::string &error_msg) { - if (_is_configed) { - _has_error = true; - _error_msg = "bd_speech_control_impl has already initialized"; - } - if (_is_finished || _sdk == nullptr){ - _has_error = true; - _error_msg = "bd_speech_control_impl has already initialized"; - } - CHECK_ERROR_THEN_RETURN("sdk is finished"); - _sdk->set_event_listener(&AsrdemoController::output_callback, (void *)this); - CHECK_ERROR_THEN_RETURN("BDSpeechSDK init ERROR"); - set_config_params(config_params); - CHECK_ERROR_THEN_RETURN("set_config_params ERROR"); - set_start_params(); - CHECK_ERROR_THEN_RETURN("set_start_params ERROR"); - - _is_configed = true; - return true; -} - -bool AsrdemoController::post_audio_data(const char *audio_buf, int audio_buf_len, std::string &error_msg) { - if (_is_finished){ - error_msg = " sdk is finished and released"; - return false; - } - _push_params.set_parameter(bds::DATA_CHUNK, audio_buf, audio_buf_len); - _has_error = !_sdk->post(_push_params, _error_msg); - CHECK_ERROR_THEN_RETURN("post_audio_data ERROR"); - return true; -} - -bool AsrdemoController::post_data_finish_and_stop(std::string &error_msg) { - if (!post_audio_data(NULL, 0, error_msg)) { - return false; - } - return stop(error_msg); -} - -bool AsrdemoController::cancel(std::string &error_msg) { - if (_is_finished){ - error_msg = " sdk is finished and released"; - return false; - } - bds::BDSSDKMessage cancel_params; - cancel_params.name = bds::ASR_CMD_CANCEL; - _has_error = !_sdk->post(cancel_params, _error_msg); - CHECK_ERROR_THEN_RETURN("post_audio_data ERROR"); - return true; -} - -bool AsrdemoController::stop(std::string &error_msg) { - if (_is_finished){ - error_msg = " sdk is finished and released"; - return false; - } - bds::BDSSDKMessage stop_params; - stop_params.name = bds::ASR_CMD_STOP; - _has_error = !_sdk->post(stop_params, _error_msg); - CHECK_ERROR_THEN_RETURN("post_audio_data ERROR"); - return true; -} - -void AsrdemoController::output_callback(bds::BDSSDKMessage &message, void *user_arg) { - if (message.name != bds::asr_callback_name) { - std::cerr << " message.name not correct:" + message.name << std::endl; - return; - } - int status = 0; - - if (!message.get_parameter(bds::CALLBACK_ASR_STATUS, status)) { - std::cerr << " message get status failed:" << std::endl; - return; - } - - AsrdemoController *controller = (AsrdemoController *) user_arg; - switch (status){ - case bds::EVoiceRecognitionClientWorkStatusCancel: - case bds::EVoiceRecognitionClientWorkStatusError: - case bds::EVoiceRecognitionClientWorkStatusLongSpeechEnd: - controller->release(); - break; - } - controller->_listener.output_callback(message, status); - -} - -void AsrdemoController::set_config_params(bds::BDSSDKMessage &config_params) { - config_params.name = bds::ASR_CMD_CONFIG; - std::string temp_str; - - // 校验必填字段 - const std::string required_string_fields[] = {bds::ASR_PARAM_KEY_APP_ID, - bds::ASR_PARAM_KEY_CHUNK_KEY, - bds::ASR_PARAM_KEY_SECRET_KEY, - bds::ASR_PARAM_KEY_PRODUCT_ID}; - std::string key; - for (int i = 0; i != sizeof(required_string_fields) / sizeof(std::string); ++i) { - key = required_string_fields[i]; - if (!config_params.get_parameter(key, temp_str)) { - _has_error = true; - _error_msg = key + " is not set "; - return; - } - } - - // 强制设置字段 - config_params.set_parameter(bds::ASR_PARAM_KEY_CHUNK_ENABLE, 1); - config_params.set_parameter(bds::ASR_PARAM_KEY_ENABLE_LONG_SPEECH, 1); - - // 补填字段 - if (!config_params.get_parameter(bds::ASR_PARAM_KEY_MFE_DNN_DAT_FILE, temp_str)) { - config_params.set_parameter(bds::ASR_PARAM_KEY_MFE_DNN_DAT_FILE, - _resource_path + "bds_easr_mfe_dnn.dat"); - } - if (!config_params.get_parameter(bds::ASR_PARAM_KEY_MFE_CMVN_DAT_FILE, temp_str)) { - config_params.set_parameter(bds::ASR_PARAM_KEY_MFE_CMVN_DAT_FILE, - _resource_path + "bds_easr_mfe_cmvn.dat"); - } - if (!config_params.get_parameter(bds::ASR_PARAM_KEY_COMPRESSION_TYPE, temp_str)) { - config_params.set_parameter(bds::ASR_PARAM_KEY_COMPRESSION_TYPE, - bds::EVR_AUDIO_COMPRESSION_PCM); - } - int tmp_int; - if (!config_params.get_parameter(bds::COMMON_PARAM_KEY_DEBUG_LOG_LEVEL, tmp_int)) { - config_params.set_parameter(bds::COMMON_PARAM_KEY_DEBUG_LOG_LEVEL, - bds::EVRDebugLogLevelTrace); - } - _has_error = !_sdk->post(config_params, _error_msg); -} - -void AsrdemoController::set_start_params() { - bds::BDSSDKMessage start_params; - start_params.name = bds::ASR_CMD_START; - start_params.set_parameter(bds::ASR_PARAM_KEY_APP, _app_name); - start_params.set_parameter(bds::ASR_PARAM_KEY_PLATFORM, "linux"); - start_params.set_parameter(bds::ASR_PARAM_KEY_SDK_VERSION, "LINUX TEST"); - _has_error = !_sdk->post(start_params, _error_msg); -} - -void AsrdemoController::release() { - std::lock_guard lk(_finish_mutex); - _is_finished = true; - if (_sdk != nullptr) { - bds::BDSpeechSDK::release_instance(_sdk); - _sdk = nullptr; // 注意 如果多次调用release方法,注意 _sdk的读取需要线程同步 - } -} - - -#undef CHECK_ERROR_THEN_RETURN - -} /* namespace asrdemo */ diff --git a/src/sdk/sample/asrDemo2/src/asrdemo/AsrdemoController.hpp b/src/sdk/sample/asrDemo2/src/asrdemo/AsrdemoController.hpp deleted file mode 100644 index 53cabca..0000000 --- a/src/sdk/sample/asrDemo2/src/asrdemo/AsrdemoController.hpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * BdSpeech.hpp - * - * Created on: Dec 12, 2017 - * Author: fu - */ - -#ifndef ASRDEMO_ASRDEMO_CONTROLLER_HPP_ -#define ASRDEMO_ASRDEMO_CONTROLLER_HPP_ - -#include -#include -#include - - -#include "BDSpeechSDK.hpp" -#include "BDSSDKMessage.hpp" -#include "bds_ASRDefines.hpp" -#include "bds_asr_key_definitions.hpp" - -#include "common.h" -#include "ResultListener.hpp" - -namespace asrdemo { - -class AsrdemoController { -public: - /** - * @param app_name IN 您自己的定义的程序名称,可能用于之后服务端的排查 - * @param resource_path IN 含有bds_easr_mfe_cmvn.dat和bds_easr_mfe_dnn.dat这两个文件的目录 - * @param listener IN ResultListener实例,含有您处理结果的业务逻辑 - */ - AsrdemoController(const std::string &app_name, const std::string &resource_path, ResultListener &listener); - - virtual ~AsrdemoController(); - - /** - * 配置参数。具体参数见在线文档 ,参数列表:输入参数列表:ASR_CMD_CONFIG一节 - * - * @param config_params IN - * @param error_msg OUT 错误消息 - * @return 是否成功 不成功时错误消息在error_msg输出 - */ - bool config(bds::BDSSDKMessage &config_params, std::string &error_msg); - - /** - * 推送音频数据,建议320字节(audio_buf_len = 320) - * - * @param audio_buf IN 二进制音频数据 - * @param audio_buf_len - */ - bool post_audio_data(const char *audio_buf, int audio_buf_len, std::string &error_msg); - - /** - * 音频流结束时调用 - */ - bool post_data_finish_and_stop(std::string &error_msg); - - /** - * 取消调用 - */ - bool cancel(std::string &error_msg); - - - /** - * 打开日志文件 - * - * logFileName IN 日志文件路径 - * fileSize IN 实际日志文件大小为 512K*fileSize, 超过后自动重命名并覆盖之前的“logFileName".bak文件 - */ - static void open_log_file(const char *logFileName, int fileSize = 0) { - bds::BDSpeechSDK::open_log_file(logFileName, fileSize); - } - - /** - * 关闭日志文件,与open_log_file配对使用 - */ - static void close_log_file() { - bds::BDSpeechSDK::close_log_file(); - } - - /** - * 不再需要SDK识别时,释放所有资源 - */ - static void do_cleanup() { - bds::BDSpeechSDK::do_cleanup(); - } - -protected: - /** - * 用于post_data_finish_and_stop - */ - bool stop(std::string &error_msg); - - /** - * 用于output_callback ,释放识别实例 - */ - void release(); - - /** - * 收到SDK的3个空闲状态返回,认为识别过程结束 - */ - static void output_callback(bds::BDSSDKMessage &message, void *user_arg); - -private: - const std::string _app_name; - const std::string _resource_path; - // 用户自己的回调逻辑 - ResultListener &_listener; - - bool _is_configed; - std::atomic_bool _is_finished = ATOMIC_VAR_INIT(false); - std::mutex _finish_mutex; - - // 调用SDK出错 - bool _has_error; - std::string _error_msg; - - bds::BDSpeechSDK *_sdk; - bds::BDSSDKMessage _push_params; - - // 设置配置参数 - void set_config_params(bds::BDSSDKMessage &config_params); - - // 设置启动参数 - void set_start_params(); - DISALLOW_COPY_AND_ASSIGN(AsrdemoController); -}; -}/* namespace asrdemo */ - -#endif /* ASRDEMO_ASRDEMO_BDSPEECHCONTROL_HPP_ */ diff --git a/src/sdk/sample/asrDemo2/src/asrdemo/ResultListener.cpp b/src/sdk/sample/asrDemo2/src/asrdemo/ResultListener.cpp deleted file mode 100644 index b53acae..0000000 --- a/src/sdk/sample/asrDemo2/src/asrdemo/ResultListener.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * asrdemo_ResultListener.cpp - * - * Created on: Dec 13, 2017 - * Author: fu - */ - -#include "ResultListener.hpp" -#include - -namespace asrdemo { - -ResultListener::ResultListener() { - //std::cout<< "result_listener constructor"< -#include "BDSSDKMessage.hpp" -#include "bds_ASRDefines.hpp" -#include "bds_asr_key_definitions.hpp" - -namespace asrdemo { - -class ResultListener { -public: - ResultListener(); - - virtual ~ResultListener(); - - virtual void output_callback(bds::BDSSDKMessage &message, int status); - -protected: - - /** - * 识别开始 EVoiceRecognitionClientWorkStatusStartWorkIng - */ - virtual void on_start_working(); - - /** - * 检查到一句话开始 EVoiceRecognitionClientWorkStatusStart - */ - virtual void on_start(); - - /** - * 检查到一句话结束 EVoiceRecognitionClientWorkStatusEnd - */ - virtual void on_end(); - - /** - * 临时识别结果 - * - * json IN 含有临时结果的json EVoiceRecognitionClientWorkStatusFlushData - */ - virtual void on_flush_data(const std::string &json); - - /** - * 一句话识别结束。 EVoiceRecognitionClientWorkStatusFinish - * 未开启长语音时,表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - * - * json IN 含有最终结果的json - */ - virtual void on_finish(const std::string &json) = 0; - - /** - * 语义理解结果 - * - * json IN 含有最终结果的json EVoiceRecognitionClientWorkStatusChunkNlu - */ - virtual void on_nlu(const std::string &json); - - /** - * 长语音识别结束,(长语音 = 多个“一句话”的识别过程) EVoiceRecognitionClientWorkStatusLongSpeechEnd - * 表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - */ - virtual void on_long_speech_end(); - - /** - * 识别出错 EVoiceRecognitionClientWorkStatusError - * 表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - * - * err_domain IN 错误领域 - * err_code IN 具体错误码 - * err_desc IN 错误描述 - * sn IN 一句话的识别过程中的logId - */ - virtual void on_error(int err_domain, int err_code, const std::string &err_desc, const std::string &sn) = 0; - - /** - * 识别被用户取消 EVoiceRecognitionClientWorkStatusCancel - * 表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - */ - virtual void on_cancel(); - - virtual void on_last_status(int status); -}; - -} /* namespace asrdemo */ - -#endif /* ASRDEMO_RESULTLISTENER_HPP_ */ diff --git a/src/sdk/sample/asrDemo2/src/asrdemo/StatusListener.cpp b/src/sdk/sample/asrDemo2/src/asrdemo/StatusListener.cpp deleted file mode 100644 index 9d108bb..0000000 --- a/src/sdk/sample/asrDemo2/src/asrdemo/StatusListener.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// -// Created by fu on 3/13/18. -// - -#include "StatusListener.hpp" -namespace asrdemo { -void StatusListener::on_last_status(int status){ - finished = true; -} -bool StatusListener::is_finished() const{ - - return finished; -} -} \ No newline at end of file diff --git a/src/sdk/sample/asrDemo2/src/asrdemo/StatusListener.hpp b/src/sdk/sample/asrDemo2/src/asrdemo/StatusListener.hpp deleted file mode 100644 index 9c0d1e5..0000000 --- a/src/sdk/sample/asrDemo2/src/asrdemo/StatusListener.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// -// Created by fu on 3/13/18. -// - -#ifndef ASRDEMO_ASRDEMO_STATUSLISTENER_HPP -#define ASRDEMO_ASRDEMO_STATUSLISTENER_HPP - -#include -#include "ResultListener.hpp" - -namespace asrdemo { -/** - * @brief 在ResultListener基础上增加判断识别是否结束 - */ -class StatusListener : public ResultListener { -public: - virtual void on_last_status(int status); - virtual bool is_finished() const; -private: - std::atomic_bool finished = ATOMIC_VAR_INIT(false); -}; - -} -#endif diff --git a/src/sdk/sample/asrDemo2/src/asrdemo/Util.cpp b/src/sdk/sample/asrDemo2/src/asrdemo/Util.cpp deleted file mode 100644 index 860c9c2..0000000 --- a/src/sdk/sample/asrDemo2/src/asrdemo/Util.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * common_Util.cpp - * - * Created on: Dec 13, 2017 - * Author: fu - */ - -#include "Util.hpp" -#include -#include -#include -#include - -namespace asrdemo { -template -static void print_values(bds::BDSSDKMessage ¶ms, std::vector &keys, - Type tmp_value, std::stringstream &stream) { - std::string k; - for (std::vector::iterator it = keys.begin(); it != keys.end(); ++it) { - k = (*it); - params.get_parameter(k, tmp_value); - - stream << k << "=" << tmp_value << "; "; - } - stream << std::endl; -} - -std::string Util::params_to_string(bds::BDSSDKMessage ¶ms) { - std::stringstream stream; - if (!params.name.empty()) { - stream << "name: " << params.name << std::endl; - } - std::vector param_keys = params.string_param_keys(); - if (param_keys.size() > 0) { - stream << "string: "; - std::string tmp_value; - print_values(params, param_keys, tmp_value, stream); - } - param_keys = params.int_param_keys(); - if (param_keys.size() > 0) { - stream << "int: "; - int tmp_value = 0; - print_values(params, param_keys, tmp_value, stream); - } - - param_keys = params.float_param_keys(); - if (param_keys.size() > 0) { - stream << "float: "; - float tmp_value = 0; - print_values(params, param_keys, tmp_value, stream); - } - - return stream.str(); -} - -uint64_t Util::current_timestamp() { - std::chrono::milliseconds ms = std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch() - ); - return ms.count(); -} - -std::string Util::get_gmt_time() { - struct timeval tv; - gettimeofday(&tv, NULL); - - struct tm current_time; - localtime_r(&tv.tv_sec, ¤t_time); - - int year = (1900 + current_time.tm_year); - int month = (1 + current_time.tm_mon); - int day = current_time.tm_mday; - int hour = current_time.tm_hour; - int minute = current_time.tm_min; - int sec = current_time.tm_sec; - int msec = (int) (tv.tv_usec / 1000); - - char time_ch_buf[128] = {0}; - snprintf(time_ch_buf, sizeof(time_ch_buf) / sizeof(char), - "%d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day, hour, minute, sec, msec); - return std::string(time_ch_buf); -} - -uint64_t Util::cal_speech_duration_ms(int bytes, int sample_rate) { - const int sample_point_bytes = 2; - int duration_ms = bytes / (sample_point_bytes * sample_rate / 1000); - return duration_ms; -} - -uint64_t Util::cal_speech_8k_duration_ms(int bytes) { - return Util::cal_speech_duration_ms(bytes, 8000); -} - -uint64_t Util::cal_speech_16k_duration_ms(int bytes) { - return Util::cal_speech_duration_ms(bytes, 16000); -} -} /* namespace asrdemo */ diff --git a/src/sdk/sample/asrDemo2/src/asrdemo/Util.hpp b/src/sdk/sample/asrDemo2/src/asrdemo/Util.hpp deleted file mode 100644 index 7223f6f..0000000 --- a/src/sdk/sample/asrDemo2/src/asrdemo/Util.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * common_Util.hpp - * - * Created on: Dec 13, 2017 - * Author: fu - */ - -#ifndef ASRDEMO_UTIL_HPP_ -#define ASRDEMO_UTIL_HPP_ - -#include -#include -#include - -#include "BDSSDKMessage.hpp" - -namespace asrdemo { - -class Util { -public: - /** - * 转为 BDSSDKMessage 为可见的字符串 - */ - static std::string params_to_string(bds::BDSSDKMessage ¶ms); - - /** - * 当前的timestamp 毫秒 - */ - static uint64_t current_timestamp(); - - /** - * 8k采样率的原始音频对应的时长 毫秒 - */ - static uint64_t cal_speech_8k_duration_ms(int bytes); - - /** - * 16k采样率的原始音频对应的时长 毫秒 - */ - static uint64_t cal_speech_16k_duration_ms(int bytes); - - /** - * 当前时间字符串 - */ - static std::string get_gmt_time(); - -private: - /** - * 原始音频对应的时长 - */ - static uint64_t cal_speech_duration_ms(int bytes, int sample_rate); -}; - -} /* namespace asrdemo */ - -#endif /* ASRDEMO_UTIL_HPP_ */ diff --git a/src/sdk/sample/asrDemo2/src/asrdemo/common.h b/src/sdk/sample/asrDemo2/src/asrdemo/common.h deleted file mode 100644 index 3cc24b7..0000000 --- a/src/sdk/sample/asrDemo2/src/asrdemo/common.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * asrdemo_common.hpp - * - * Created on: Dec 12, 2017 - * Author: fu - */ - -#ifndef ASRDEMO_COMMON_ -#define ASRDEMO_COMMON_ - - -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&); \ - TypeName& operator=(const TypeName&) - -#endif /* ASRDEMO_COMMON_ */ diff --git a/src/sdk/sample/asrDemo2/src/yours_PrintResultListener.cpp b/src/sdk/sample/asrDemo2/src/yours_PrintResultListener.cpp deleted file mode 100644 index 1a1ae9a..0000000 --- a/src/sdk/sample/asrDemo2/src/yours_PrintResultListener.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * asrdemo_PrintResultListener.cpp - * - * Created on: Dec 15, 2017 - * Author: fu - */ - -#include "yours_PrintResultListener.hpp" -#include -#include -#include "asrdemo/Util.hpp" - -namespace yours { - -PrintResultListener::PrintResultListener(const std::string &prefix) : - asrdemo::StatusListener(), _prefix(prefix) { - write_log("PrintResultListener constructor"); - -} - -PrintResultListener::~PrintResultListener() { - write_log("PrintResultListener DeConstructor"); -} - -/** - * 识别开始 - */ -void PrintResultListener::on_start_working() { - write_log("开始识别"); -} - -/** - * 检查到一句话开始 - */ -void PrintResultListener::on_start() { - write_log("检测到一句话开始"); -} - -/** - * 检查到一句话结束 - */ -void PrintResultListener::on_end() { - write_log("检测到一句话结束"); -} - -/** - * 临时识别结果 - * - * json IN 含有临时结果的json - */ -void PrintResultListener::on_flush_data(const std::string &json) { - write_log("临时结果:" + json); -} - -/** - * 一句话识别结束。 - * 未开启长语音时,表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - * - * json IN 含有最终结果的json - */ -void PrintResultListener::on_finish(const std::string &json) { - write_log("识别结果:" + json); -} - -void PrintResultListener::on_nlu(const std::string &json) { - write_log("语义理解结果:" + json); -} - -/** - * 长语音识别结束,(长语音 = 多个“一句话”的识别过程) - * 表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - */ -void PrintResultListener::on_long_speech_end() { - write_log("长语音结束"); -} - -/** - * 识别出错 - * 表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - * - * err_domain IN 错误领域 - * err_code IN 具体错误码 - * err_desc IN 错误描述 - * sn IN 一句话的识别过程中的logId - */ -void PrintResultListener::on_error(int err_domain, int err_code, const std::string &err_desc, const std::string &sn) { - std::ostringstream oss; - oss << "识别错误, err_domain=" << err_domain << " ;err_code=" << err_code << " ;err_desc=" << err_desc << " ;sn= " - << sn; - write_log(oss.str()); -} - -/** - * 识别被用户取消 - * 表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - */ -void PrintResultListener::on_cancel() { - write_log("用户取消"); -} - -void PrintResultListener::write_log(const std::string str) const { - std::cout.flush(); - std::ostringstream os; - os << "[" << asrdemo::Util::get_gmt_time() << "][" << _prefix << "] :" << str << std::endl; - std::cout << os.str(); -} - -} /* namespace asrdemo */ diff --git a/src/sdk/sample/asrDemo2/src/yours_PrintResultListener.hpp b/src/sdk/sample/asrDemo2/src/yours_PrintResultListener.hpp deleted file mode 100644 index 92e4464..0000000 --- a/src/sdk/sample/asrDemo2/src/yours_PrintResultListener.hpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * asrdemo_PrintResultListener.h - * - * Created on: Dec 15, 2017 - * Author: fu - */ - -#ifndef YOURS_PRINTRESULTLISTENER_HPP_ -#define YOURS_PRINTRESULTLISTENER_HPP_ - -#include -#include "asrdemo/common.h" -#include "asrdemo/StatusListener.hpp" - -namespace yours { - -class PrintResultListener : public asrdemo::StatusListener { -public: - /** - * prefix IN 打印日志使用 - */ - PrintResultListener(const std::string &prefix); - - virtual ~PrintResultListener(); - -protected: - /** - * 识别开始 - */ - virtual void on_start_working(); - - /** - * 检查到一句话开始 - */ - virtual void on_start(); - - /** - * 检查到一句话结束 - */ - virtual void on_end(); - - /** - * 临时识别结果 - * - * json IN 含有临时结果的json - */ - virtual void on_flush_data(const std::string &json); - - /** - * 一句话识别结束。 - * 未开启长语音时,表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - * - * json IN 含有最终结果的json - */ - virtual void on_finish(const std::string &json); - - /** - * 语义理解结果 - * - * json IN 含有最终结果的json - */ - virtual void on_nlu(const std::string &json); - - /** - * 长语音识别结束,(长语音 = 多个“一句话”的识别过程) - * 表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - */ - virtual void on_long_speech_end(); - - /** - * 识别出错 - * 表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - * - * err_domain IN 错误领域 - * err_code IN 具体错误码 - * err_desc IN 错误描述 - * sn IN 一句话的识别过程中的logId - */ - virtual void on_error(int err_domain, int err_code, const std::string &err_desc, const std::string &sn); - - /** - * 识别被用户取消 - * 表示整个识别过程结束,BDSpeechSDK实例处于空闲状态 - */ - virtual void on_cancel(); - -private: - const std::string _prefix; - - void write_log(const std::string str) const; - DISALLOW_COPY_AND_ASSIGN(PrintResultListener); -}; - -} /* namespace asrdemo */ - -#endif /* YOURS_PRINTRESULTLISTENER_HPP_ */ diff --git a/src/sdk/sample/asrDemo2/src/yours_main.cpp b/src/sdk/sample/asrDemo2/src/yours_main.cpp deleted file mode 100644 index 066e1b0..0000000 --- a/src/sdk/sample/asrDemo2/src/yours_main.cpp +++ /dev/null @@ -1,293 +0,0 @@ -//============================================================================ -// Name : asrdemo2.cpp -// Author : -// Version : -// Copyright : Your copyright notice -// Description : Hello World in C++, Ansi-style -//============================================================================ - -#include -#include -#include -#include -#include -#include "yours_PrintResultListener.hpp" -#include "asrdemo/AsrdemoController.hpp" -#include "asrdemo/Util.hpp" - -using namespace std; - -/** - * 0. demo不用修改任何代码,可以直接运行。测试成功后请进行以下步骤 - * 1. 请修改set_config 函数,配置您的参数。 - * 2. 在main函数中选择recog_one_file进行单文件识别,或者recog_multi_files同时识别多个文件。 - * - * 8k 采样率不再支持 - */ - - -static void set_config(bds::BDSSDKMessage &cfg_params) { - // app_id app_key app_secret 请测试成功后替换为您在网页上申请的appId appKey和appSecret - const std::string app_id = "10455099"; - const std::string app_key = "rKCHBLmYiFPuCQTS0HttLbUD"; - const std::string app_secret = "037dc446820ec143d1628c20146b9d34"; - - const std::string product_id = "1536"; // 普通话搜索模型(没有逗号)):1536,普通话搜索模型+语义理解 15361, 普通话输入法模型(有逗号) 1537 - - cfg_params.set_parameter(bds::ASR_PARAM_KEY_APP_ID, app_id); - cfg_params.set_parameter(bds::ASR_PARAM_KEY_CHUNK_KEY, app_key); - cfg_params.set_parameter(bds::ASR_PARAM_KEY_SECRET_KEY, app_secret); - cfg_params.set_parameter(bds::ASR_PARAM_KEY_PRODUCT_ID, product_id); - cfg_params.set_parameter(bds::COMMON_PARAM_KEY_DEBUG_LOG_LEVEL, bds::EVRDebugLogLevelOff); //关闭debug日志 ,上线时请注释此行 - float vad_pause_frame = 30; //设置vad语句静音切分门限, 30帧= 300ms。 即原始语音静音 300ms后,SDK认为一句话结束 - cfg_params.set_parameter(bds::ASR_PARAM_KEY_MAX_SPEECH_PAUSE, vad_pause_frame); - - //以下是不常用的参数 - // cfg_params.set_parameter(bds::ASR_PARAM_KEY_COMPRESSION_TYPE, bds::EVR_AUDIO_COMPRESSION_BV32); // 有损压缩 - // cfg_params.set_parameter(bds::ASR_PARAM_KEY_SAVE_AUDIO_ENABLE, 1); //是否存识别的音频 - // cfg_params.set_parameter(bds::ASR_PARAM_KEY_SAVE_AUDIO_PATH, "sdk_save_audio.d"); //存音频的路径 - // cfg_params.set_parameter(bds::ASR_PARAM_KEY_DISABLE_PUNCTUATION, 0); // 输出时没有逗号 搜索模型有效 - -} - -/**识别单个文件*/ -static void recog_one_file(); - -/**识别多个文件*/ -static void recog_multi_files(); - -// 调用set_config函数,写入sdk的配置参数 -static void _config(asrdemo::AsrdemoController &controller); - -// 按320字节大小,将数据post到sdk中。 -static bool _post_data(istream &io, asrdemo::AsrdemoController &controller, int &sleep_ms, string &error_msg); - -// 判断流是否结束或异常(io.eof()),结束的话,调用post_data_finish_and_stop,告知sdk音频结束 -static int _push_data_eof(istream &io, asrdemo::AsrdemoController &controller, string &error_msg); - -// flags 是否都是true -static bool _is_all_true(bool flags[], int size); - -int main(int argc, char **argv) { - cout << "BEGIN!" << endl; - //此处25 表示日志文件为 25*512k大小,asrdemo.log超过大小后,自动重命名为asrdemo.log.bak。asrdemo.log继续生成 - asrdemo::AsrdemoController::open_log_file("asrdemo.log", 25); - recog_one_file(); // 识别一个文件 - // recog_multi_files(); // 一个线程里识别多个文件 - asrdemo::AsrdemoController::close_log_file(); // 程序退出时或者不需要再写日志 固定用法, 引擎空闲时调用 - asrdemo::AsrdemoController::do_cleanup(); // 程序退出时或者不需要asr服务时 固定用法, 引擎空闲时调用 - return 0; -} - -/** - * 识别一个文件 - */ -static void recog_one_file() { - string filename = "../pcm/16k-0.pcm"; - ifstream io(filename.c_str()); - - if (!io || !io.is_open()) { - cerr << "read file error:" << filename << endl; - exit(1); - } - - yours::PrintResultListener listener(filename); - asrdemo::AsrdemoController controller("testYourApp", "../../../resources/asr_resource/", listener); - _config(controller); - - bool will_continue = true; - int sleep_ms = 0; - while (will_continue) { - string error_msg; - int status = _push_data_eof(io, controller, error_msg); // 判断是否是文件结尾,是的话,结束这个音频文件的SDK调用 - if (status < 0) { // 出错 - cerr << "stop audio data error:" << error_msg << " : " << status << endl; - will_continue = false; - } else if (status == 1) { // 文件读完了 - will_continue = false; - io.close(); - } else { // 正常 - if (sleep_ms > 0) { //上次_post_data欠的sleep - //cout << "sleep :"<is_open()) { - cerr << "read file error:" << filename << endl; - exit(1); - } - next_sleep_timestamps[i] = 0; - files_eof[i] = false; - sdk_finished[i] = false; - } - - for (int i = 0; i < num_files; i++) { - _config(*controllers[i]); - } - - bool is_success = true; - int status = 0; - int sleep_ms = 0; - std::string error_msg; - while (!_is_all_true(files_eof, num_files)) { - for (int i = 0; i < num_files; i++) { - if (files_eof[i]) { - // cout << "files finished:" << i << endl; - continue;// 文件已经结束 - } - status = _push_data_eof(*ifs[i], *controllers[i], error_msg); - if (status < 0) { // 出错 - cerr << "stop audio data error:" << error_msg << " : " << status << endl; - exit(3); - } else if (status == 1) { //文件结束 - // cout << "file ended :" << i << endl; - files_eof[i] = true; - ifs[i]->close(); - } else { - if (next_sleep_timestamps[i] > 0) { - sleep_ms = next_sleep_timestamps[i] - asrdemo::Util::current_timestamp(); // 需要sleep的耗时 - if (sleep_ms > 0) { - // cout << "sleep :" << sleep_ms << endl; - usleep(sleep_ms * 1000); - } - } - - is_success = _post_data(*ifs[i], *controllers[i], sleep_ms, error_msg); // 是否post成功,一般都是成功的。 - if (!is_success) { - cerr << "stop audio data error:" << error_msg << " : " << status << endl; - exit(3); - } - next_sleep_timestamps[i] = asrdemo::Util::current_timestamp() + sleep_ms; - } - } - } - cout << "ASR MULTIFILES BEGIN TO SLEEP" << endl; - while (!_is_all_true(sdk_finished, num_files)) { // 直到所有controllers都结束 - for (int i = 0; i < num_files; i++) { - if (sdk_finished[i]) { - continue; - } - if (listeners[i]->is_finished()) { - sdk_finished[i] = true; - } else { - //cout << "SLEEP 1s to wait" << endl; - sleep(1); - break; - } - } - } - for (int i = 0; i < num_files; i++) { - delete ifs[i]; - delete listeners[i]; - delete controllers[i]; - - } - - cout << "ASR MULTIFILES FINISHED" << endl; - -} - -static void _config(asrdemo::AsrdemoController &controller) { - bds::BDSSDKMessage cfg_params; - std::string error_msg; - set_config(cfg_params); - // cout << "Config is :\n " << asrdemo::Util::params_to_string(cfg_params); - if (controller.config(cfg_params, error_msg)) { - cout << "FOR Feedback : Config is filled :\n" << asrdemo::Util::params_to_string(cfg_params) << endl; - } else { - cerr << error_msg << " , END!" << endl; - exit(2); - } -} - -/** - * 判断流是否结束或异常(io.eof()),结束的话,调用post_data_finish_and_stop,告知sdk音频结束 - */ -static int _push_data_eof(istream &io, asrdemo::AsrdemoController &controller, string &error_msg) { - if (io.eof()) { - if (!controller.post_data_finish_and_stop(error_msg)) { - return -1; // 出错 - } - return 1; // 文件结束,并且告知了sdk音频结束 - } - return 0; // 文件未结束 -} - -/** - * 按320字节大小从io读取,将数据post到sdk中。 - */ -static bool _post_data(istream &io, asrdemo::AsrdemoController &controller, int &sleep_ms, string &error_msg) { - const int audio_buf_len = 320; - char audio_buf[audio_buf_len]; - int readed_len = 0; - - io.read(audio_buf, audio_buf_len); - readed_len = io.gcount(); - if (readed_len < 0) { - error_msg = " readed_len is <0"; - return false; - } - if (readed_len == 0) { // 读到0字节 - sleep_ms = 0; - return true; - } - if (!controller.post_audio_data(audio_buf, readed_len, error_msg)) { - return false; - } - - sleep_ms = asrdemo::Util::cal_speech_16k_duration_ms(readed_len); // 根据audio_buf_len 计算音频长度 16k采样率 - - return true; -} - -static bool _is_all_true(bool flags[], int size) { - for (int i = 0; i < size; i++) { - if (!flags[i]) { - return false; - } - } - return true; -} diff --git a/src/voice_assistant/README.md b/src/voice_assistant/README.md new file mode 100644 index 0000000..06c5c26 --- /dev/null +++ b/src/voice_assistant/README.md @@ -0,0 +1,7 @@ +# 树莓派实现语音助手 + +### 基于: +1. [Snowboy](https://snowboy.kitt.ai/dashboard),用于实现唤醒系统 +2. [百度语音](https://cloud.baidu.com/),用于语音识别 + +#### 使用python编写,具体介绍前往 [树莓派实现语音助手](https://www.passerma.com/article/54) \ No newline at end of file diff --git a/src/voice_assistant/__pycache__/snowboydecoder.cpython-39.pyc b/src/voice_assistant/__pycache__/snowboydecoder.cpython-39.pyc new file mode 100644 index 0000000..3bca655 Binary files /dev/null and b/src/voice_assistant/__pycache__/snowboydecoder.cpython-39.pyc differ diff --git a/src/voice_assistant/__pycache__/snowboydetect.cpython-39.pyc b/src/voice_assistant/__pycache__/snowboydetect.cpython-39.pyc new file mode 100644 index 0000000..e5b5617 Binary files /dev/null and b/src/voice_assistant/__pycache__/snowboydetect.cpython-39.pyc differ diff --git a/src/voice_assistant/_snowboydetect.so b/src/voice_assistant/_snowboydetect.so new file mode 100644 index 0000000..f3c78d3 Binary files /dev/null and b/src/voice_assistant/_snowboydetect.so differ diff --git a/src/voice_assistant/audio/audio.wav b/src/voice_assistant/audio/audio.wav new file mode 100644 index 0000000..a44c5fd Binary files /dev/null and b/src/voice_assistant/audio/audio.wav differ diff --git a/src/voice_assistant/audio/exit.wav b/src/voice_assistant/audio/exit.wav new file mode 100644 index 0000000..8a6a638 Binary files /dev/null and b/src/voice_assistant/audio/exit.wav differ diff --git a/src/voice_assistant/audio/none.wav b/src/voice_assistant/audio/none.wav new file mode 100644 index 0000000..fda5a70 Binary files /dev/null and b/src/voice_assistant/audio/none.wav differ diff --git a/src/voice_assistant/audio/open.wav b/src/voice_assistant/audio/open.wav new file mode 100644 index 0000000..1192790 Binary files /dev/null and b/src/voice_assistant/audio/open.wav differ diff --git a/src/voice_assistant/fetchToken.py b/src/voice_assistant/fetchToken.py new file mode 100644 index 0000000..ba23d52 --- /dev/null +++ b/src/voice_assistant/fetchToken.py @@ -0,0 +1,69 @@ +#从百度AI开放平台获取语音合成(TTS)服务所需的access_token +# -*- coding: utf-8 -*- + +import sys +import json + +# 保证兼容python2以及python3 +IS_PY3 = sys.version_info.major == 3 +if IS_PY3: + from urllib.request import urlopen + from urllib.request import Request + from urllib.error import URLError + from urllib.parse import urlencode + from urllib.parse import quote_plus +else: + import urllib.request + import urllib + from urllib import quote_plus + from urllib import urlopen + from urllib import Request + from urllib import URLError + from urllib import urlencode + +# 替换你的 API_KEY +API_KEY = 'P2o5IjKMXqGz80VzRuv2v9Uj' + +# 替换你的 SECRET_KEY +SECRET_KEY = 'TbvincgBwx4TfOvVXC5WgrP3WED9J2SQ' + +TOKEN_URL = 'http://openapi.baidu.com/oauth/2.0/token' + + +def fetch_token(): + # 定义请求参数 + params = {'grant_type': 'client_credentials', + 'client_id': API_KEY, + 'client_secret': SECRET_KEY} + # 将参数编码为utf-8 + post_data = urlencode(params) + if (IS_PY3): + post_data = post_data.encode('utf-8') + # 创建请求对象 + req = Request(TOKEN_URL, post_data) + try: + # 发送请求 + f = urlopen(req, timeout=5) + result_str = f.read() + except URLError as err: + # 处理异常 + print('token http response http code : ' + str(err.code)) + result_str = err.read() + if (IS_PY3): + result_str = result_str.decode() + + # 将结果转换为字典 + result = json.loads(result_str) + + # 检查结果中是否包含access_token和scope + if ('access_token' in result.keys() and 'scope' in result.keys()): + # 检查scope中是否包含audio_tts_post + if not 'audio_tts_post' in result['scope'].split(' '): + print('please ensure has check the tts ability') + return '' + # 返回access_token + return result['access_token'] + else: + # 否则,检查API_KEY和SECRET_KEY是否正确 + print('please overwrite the correct API_KEY and SECRET_KEY') + return '' diff --git a/src/voice_assistant/resources/._alexa.umdl b/src/voice_assistant/resources/._alexa.umdl new file mode 100644 index 0000000..e8c147b Binary files /dev/null and b/src/voice_assistant/resources/._alexa.umdl differ diff --git a/src/voice_assistant/resources/._alexa_02092017.umdl b/src/voice_assistant/resources/._alexa_02092017.umdl new file mode 100644 index 0000000..e8c147b Binary files /dev/null and b/src/voice_assistant/resources/._alexa_02092017.umdl differ diff --git a/src/voice_assistant/resources/._common.res b/src/voice_assistant/resources/._common.res new file mode 100644 index 0000000..e8c147b Binary files /dev/null and b/src/voice_assistant/resources/._common.res differ diff --git a/src/voice_assistant/resources/._ding.wav b/src/voice_assistant/resources/._ding.wav new file mode 100644 index 0000000..e8c147b Binary files /dev/null and b/src/voice_assistant/resources/._ding.wav differ diff --git a/src/voice_assistant/resources/._dong.wav b/src/voice_assistant/resources/._dong.wav new file mode 100644 index 0000000..e8c147b Binary files /dev/null and b/src/voice_assistant/resources/._dong.wav differ diff --git a/src/voice_assistant/resources/._snowboy.umdl b/src/voice_assistant/resources/._snowboy.umdl new file mode 100644 index 0000000..e8c147b Binary files /dev/null and b/src/voice_assistant/resources/._snowboy.umdl differ diff --git a/src/voice_assistant/resources/alexa.umdl b/src/voice_assistant/resources/alexa.umdl new file mode 100644 index 0000000..0d9db6f Binary files /dev/null and b/src/voice_assistant/resources/alexa.umdl differ diff --git a/src/voice_assistant/resources/alexa_02092017.umdl b/src/voice_assistant/resources/alexa_02092017.umdl new file mode 100644 index 0000000..c4a6094 Binary files /dev/null and b/src/voice_assistant/resources/alexa_02092017.umdl differ diff --git a/src/voice_assistant/resources/common.res b/src/voice_assistant/resources/common.res new file mode 100644 index 0000000..0e267f5 Binary files /dev/null and b/src/voice_assistant/resources/common.res differ diff --git a/src/voice_assistant/resources/ding.wav b/src/voice_assistant/resources/ding.wav new file mode 100644 index 0000000..79346e0 Binary files /dev/null and b/src/voice_assistant/resources/ding.wav differ diff --git a/src/voice_assistant/resources/dong.wav b/src/voice_assistant/resources/dong.wav new file mode 100644 index 0000000..426596b Binary files /dev/null and b/src/voice_assistant/resources/dong.wav differ diff --git a/src/voice_assistant/resources/snowboy.umdl b/src/voice_assistant/resources/snowboy.umdl new file mode 100644 index 0000000..bb68185 Binary files /dev/null and b/src/voice_assistant/resources/snowboy.umdl differ diff --git a/src/voice_assistant/snow.py b/src/voice_assistant/snow.py new file mode 100644 index 0000000..eb3f4bb --- /dev/null +++ b/src/voice_assistant/snow.py @@ -0,0 +1,195 @@ +import snowboydecoder +import signal +import wave +import sys +import json +import requests +import time +import os +import base64 +from pyaudio import PyAudio, paInt16 +import webbrowser +from fetchToken import fetch_token +import time + +IS_PY3 = sys.version_info.major == 3 +if IS_PY3: + from urllib.request import urlopen + from urllib.request import Request + from urllib.error import URLError + from urllib.parse import urlencode + from urllib.parse import quote_plus +else: + import urllib.request + from urllib import quote_plus + from urllib.request import urlopen + from urllib.request import Request + from urllib.request import URLError + from urllib import urlencode + +interrupted = False # snowboy监听唤醒结束标志 +endSnow = False # 程序结束标志 + +framerate = 16000 # 采样率 +num_samples = 2000 # 采样点 +channels = 1 # 声道 +sampwidth = 2 # 采样宽度2bytes + +FILEPATH = './audio/audio.wav' # 录制完成存放音频路径 +music_exit = './audio/exit.wav' # 唤醒系统退出语音 +music_open = './audio/open.wav' # 唤醒系统打开语音 +os.close(sys.stderr.fileno()) # 去掉错误警告 + +def signal_handler(signal, frame): + """ + 监听键盘结束 + """ + global interrupted + interrupted = True + +def interrupt_callback(): + """ + 监听唤醒 + """ + global interrupted + return interrupted + +def detected(): + """ + 唤醒成功 + """ + print('唤醒成功') + play(music_open) + global interrupted + interrupted = True + detector.terminate() + +def play(filename): + """ + 播放音频 + """ + wf = wave.open(filename, 'rb') # 打开audio.wav + p = PyAudio() # 实例化 pyaudio + # 打开流 + stream = p.open(format=p.get_format_from_width(wf.getsampwidth()), + channels=wf.getnchannels(), + rate=wf.getframerate(), + output=True) + data = wf.readframes(1024) + while data != b'': + data = wf.readframes(1024) + stream.write(data) + # 释放IO + stream.stop_stream() + stream.close() + p.terminate() + +def save_wave_file(filepath, data): + """ + 存储文件 + """ + # 打开文件 + wf = wave.open(filepath, 'wb') + # 设置通道数 + wf.setnchannels(channels) + # 设置采样宽度 + wf.setsampwidth(sampwidth) + # 设置帧率 + wf.setframerate(framerate) + # 将数据写入文件 + wf.writeframes(b''.join(data)) + # 关闭文件 + wf.close() + +def my_record(): + """ + 录音 + """ + pa = PyAudio() # 初始化pyaudio + stream = pa.open(format=paInt16, channels=channels, + rate=framerate, input=True, frames_per_buffer=num_samples) # 打开流 + my_buf = [] # 初始化缓冲区 + # count = 0 + t = time.time() + print('开始录音...') # 打印开始录音信息 + while time.time() < t + 4: + string_audio_data = stream.read(num_samples) # 读取数据 + my_buf.append(string_audio_data) # 添加到缓冲区 + print('录音结束!') # 打印录音结束信息 + save_wave_file(FILEPATH, my_buf) # 保存录音文件 + stream.close() # 关闭流 + + +def speech2text(speech_data, token, dev_pid=1537): + """ + 音频转文字 + """ + FORMAT = 'wav' + RATE = '16000' + CHANNEL = 1 + CUID = 'baidu_workshop' + SPEECH = base64.b64encode(speech_data).decode('utf-8') + data = { + 'format': FORMAT, + 'rate': RATE, + 'channel': CHANNEL, + 'cuid': CUID, + 'len': len(speech_data), + 'speech': SPEECH, + 'token': token, + 'dev_pid': dev_pid + } + # 语音转文字接口 该接口可能每个人不一样,取决于你需要哪种语音识别功能,本文使用的是 语音识别极速版 + + url = 'https://vop.baidu.com/pro_api' + headers = {'Content-Type': 'application/json'} # 请求头 + print('正在识别...') + r = requests.post(url, json=data, headers=headers) + Result = r.json() + if 'result' in Result: + return Result['result'][0] + else: + return Result + +def get_audio(file): + """ + 获取音频文件 + """ + with open(file, 'rb') as f: + data = f.read() + return data + +def identifyComplete(text): + """ + 识别成功 + """ + print(text) + maps = { + '打开百度': ['打开百度。', '打开百度', '打开百度,', 'baidu'] + } + if (text == '再见。' or text == '拜拜。'): + play(music_exit) # 关闭系统播放反馈语音 + exit() + if text in maps['打开百度']: + webbrowser.open_new_tab('https://www.baidu.com') + play('./audio/openbaidu.wav') # 识别到播放反馈语音 + else: + play('./audio/none.wav') # 未匹配口令播放反馈语音 + print('操作完成') + +if __name__ == "__main__": + while endSnow == False: + interrupted = False + # 实例化snowboy,第一个参数就是唤醒识别模型位置 + detector = snowboydecoder.HotwordDetector('ma.pmdl', sensitivity=0.5) + print('等待唤醒') + # snowboy监听循环 + detector.start(detected_callback=detected, + interrupt_check=interrupt_callback, + sleep_time=0.03) + my_record() # 唤醒成功开始录音 + TOKEN = fetch_token() # 获取token + speech = get_audio(FILEPATH) + result = speech2text(speech, TOKEN, int(80001)) + if type(result) == str: + identifyComplete(result.strip(',')) \ No newline at end of file diff --git a/src/voice_assistant/snowboydecoder.py b/src/voice_assistant/snowboydecoder.py new file mode 100644 index 0000000..86e001c --- /dev/null +++ b/src/voice_assistant/snowboydecoder.py @@ -0,0 +1,194 @@ +#!/usr/bin/env python + +import collections +import pyaudio +import snowboydetect +import time +import wave +import os +import logging + +logging.basicConfig() +logger = logging.getLogger("snowboy") +logger.setLevel(logging.INFO) +TOP_DIR = os.path.dirname(os.path.abspath(__file__)) + +RESOURCE_FILE = os.path.join(TOP_DIR, "resources/common.res") +DETECT_DING = os.path.join(TOP_DIR, "resources/ding.wav") +DETECT_DONG = os.path.join(TOP_DIR, "resources/dong.wav") + + +class RingBuffer(object): + """Ring buffer to hold audio from PortAudio""" + + def __init__(self, size=4096): + self._buf = collections.deque(maxlen=size) + + def extend(self, data): + """Adds data to the end of buffer""" + self._buf.extend(data) + + def get(self): + """Retrieves data from the beginning of buffer and clears it""" + tmp = bytes(bytearray(self._buf)) + self._buf.clear() + return tmp + + +def play_audio_file(fname=DETECT_DING): + """Simple callback function to play a wave file. By default it plays + a Ding sound. + + :param str fname: wave file name + :return: None + """ + # 打开wave文件 + ding_wav = wave.open(fname, 'rb') + # 读取文件内容 + ding_data = ding_wav.readframes(ding_wav.getnframes()) + # 初始化pyaudio + audio = pyaudio.PyAudio() + # 打开音频流 + stream_out = audio.open( + format=audio.get_format_from_width(ding_wav.getsampwidth()), + channels=ding_wav.getnchannels(), + rate=ding_wav.getframerate(), input=False, output=True) + # 开始音频流 + stream_out.start_stream() + # 写入音频数据 + stream_out.write(ding_data) + # 等待0.2秒 + time.sleep(0.2) + # 停止音频流 + stream_out.stop_stream() + stream_out.close() + # 关闭pyaudio + audio.terminate() + + +class HotwordDetector(object): + """ + Snowboy decoder to detect whether a keyword specified by `decoder_model` + exists in a microphone input stream. + + :param decoder_model: decoder model file path, a string or a list of strings + :param resource: resource file path. + :param sensitivity: decoder sensitivity, a float of a list of floats. + The bigger the value, the more senstive the + decoder. If an empty list is provided, then the + default sensitivity in the model will be used. + :param audio_gain: multiply input volume by this factor. + """ + + def __init__(self, decoder_model, + resource=RESOURCE_FILE, + sensitivity=[], + audio_gain=1): + + def audio_callback(in_data, frame_count, time_info, status): + self.ring_buffer.extend(in_data) + play_data = chr(0) * len(in_data) + return play_data, pyaudio.paContinue + + tm = type(decoder_model) + ts = type(sensitivity) + if tm is not list: + decoder_model = [decoder_model] + if ts is not list: + sensitivity = [sensitivity] + model_str = ",".join(decoder_model) + + self.detector = snowboydetect.SnowboyDetect( + resource_filename=resource.encode(), model_str=model_str.encode()) + self.detector.SetAudioGain(audio_gain) + self.num_hotwords = self.detector.NumHotwords() + + if len(decoder_model) > 1 and len(sensitivity) == 1: + sensitivity = sensitivity*self.num_hotwords + if len(sensitivity) != 0: + assert self.num_hotwords == len(sensitivity), \ + "number of hotwords in decoder_model (%d) and sensitivity " \ + "(%d) does not match" % (self.num_hotwords, len(sensitivity)) + sensitivity_str = ",".join([str(t) for t in sensitivity]) + if len(sensitivity) != 0: + self.detector.SetSensitivity(sensitivity_str.encode()) + + self.ring_buffer = RingBuffer( + self.detector.NumChannels() * self.detector.SampleRate() * 5) + self.audio = pyaudio.PyAudio() + self.stream_in = self.audio.open( + input=True, output=False, + format=self.audio.get_format_from_width( + self.detector.BitsPerSample() / 8), + channels=self.detector.NumChannels(), + rate=self.detector.SampleRate(), + frames_per_buffer=2048, + stream_callback=audio_callback) + + def start(self, detected_callback=play_audio_file, + interrupt_check=lambda: False, + sleep_time=0.03): + """ + Start the voice detector. For every `sleep_time` second it checks the + audio buffer for triggering keywords. If detected, then call + corresponding function in `detected_callback`, which can be a single + function (single model) or a list of callback functions (multiple + models). Every loop it also calls `interrupt_check` -- if it returns + True, then breaks from the loop and return. + + :param detected_callback: a function or list of functions. The number of + items must match the number of models in + `decoder_model`. + :param interrupt_check: a function that returns True if the main loop + needs to stop. + :param float sleep_time: how much time in second every loop waits. + :return: None + """ + if interrupt_check(): + logger.debug("detect voice return") + return + + tc = type(detected_callback) + if tc is not list: + detected_callback = [detected_callback] + if len(detected_callback) == 1 and self.num_hotwords > 1: + detected_callback *= self.num_hotwords + + assert self.num_hotwords == len(detected_callback), \ + "Error: hotwords in your models (%d) do not match the number of " \ + "callbacks (%d)" % (self.num_hotwords, len(detected_callback)) + + logger.debug("detecting...") + + while True: + if interrupt_check(): + logger.debug("detect voice break") + break + data = self.ring_buffer.get() + if len(data) == 0: + time.sleep(sleep_time) + continue + + ans = self.detector.RunDetection(data) + if ans == -1: + logger.warning( + "Error initializing streams or reading audio data") + elif ans > 0: + message = "Keyword " + str(ans) + " detected at time: " + message += time.strftime("%Y-%m-%d %H:%M:%S", + time.localtime(time.time())) + logger.info(message) + callback = detected_callback[ans-1] + if callback is not None: + callback() + + logger.debug("finished.") + + def terminate(self): + """ + Terminate audio stream. Users cannot call start() again to detect. + :return: None + """ + self.stream_in.stop_stream() + self.stream_in.close() + self.audio.terminate() diff --git a/src/voice_assistant/snowboydetect.py b/src/voice_assistant/snowboydetect.py new file mode 100644 index 0000000..bfa5f6a --- /dev/null +++ b/src/voice_assistant/snowboydetect.py @@ -0,0 +1,180 @@ +# 导入sys模块,并判断版本信息是否大于等于(2, 6, 0) +from sys import version_info +# 如果版本信息大于等于(2, 6, 0),则定义swig_import_helper函数 +if version_info >= (2, 6, 0): + def swig_import_helper(): + # 从os.path模块导入dirname函数 + from os.path import dirname + # 从importlib模块导入load_module函数 + import importlib + # 定义fp变量 + fp = None + # 尝试导入_snowboydetect模块 + try: + fp, pathname, description = importlib.find_module( + '_snowboydetect', [dirname(__file__)]) + # 如果导入失败,则导入_snowboydetect模块 + except ImportError: + import _snowboydetect + return _snowboydetect + # 如果fp不为空,则执行以下操作 + if fp is not None: + try: + # 从fp, pathname, description中导入_mod模块 + _mod = importlib.load_module( + '_snowboydetect', fp, pathname, description) + # finally语句块,关闭fp + finally: + fp.close() + # 返回_mod + return _mod + # 定义_snowboydetect变量,调用swig_import_helper函数 + _snowboydetect = swig_import_helper() + # 删除swig_import_helper变量 + del swig_import_helper +# 如果版本信息小于(2, 6, 0),则导入_snowboydetect模块 +else: + import _snowboydetect +# 删除版本信息变量 +del version_info +# 尝试导入_swig_property变量 +try: + # 如果导入失败,则定义_swig_property变量 + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. + + +def _swig_setattr_nondynamic(self, class_type, name, value, static=1): + # 如果name等于"thisown",则将self.this.own(value)赋值给name + if (name == "thisown"): + return self.this.own(value) + # 如果name等于"this",则将value的类型判断是否为SwigPyObject,如果是,则将self.__dict__[name]赋值给value,否则调用class_type.__swig_setmethods__.get(name, None)函数 + if (name == "this"): + if type(value).__name__ == 'SwigPyObject': + self.__dict__[name] = value + return + # 调用class_type.__swig_setmethods__.get(name, None)函数 + method = class_type.__swig_setmethods__.get(name, None) + # 如果method不为空,则调用method(self, value)函数 + if method: + return method(self, value) + # 如果static为0,则调用object.__setattr__(self, name, value)函数 + if (not static): + if _newclass: + object.__setattr__(self, name, value) + else: + self.__dict__[name] = value + # 否则,抛出AttributeError异常 + else: + raise AttributeError("You cannot add attributes to %s" % self) + + +# 定义_swig_setattr函数,将类、名称和值作为参数 +def _swig_setattr(self, class_type, name, value): + # 返回_swig_setattr_nondynamic函数,将类、名称和值作为参数 + return _swig_setattr_nondynamic(self, class_type, name, value, 0) + + +# 定义_swig_getattr_nondynamic函数,将类、名称和静态作为参数 +def _swig_getattr_nondynamic(self, class_type, name, static=1): + # 如果名称是"thisown",则返回self.this.own() + if (name == "thisown"): + return self.this.own() + # 获取类中是否有该名称的方法 + method = class_type.__swig_getmethods__.get(name, None) + # 如果存在该方法,则返回该方法(self) + if method: + return method(self) + # 如果不是静态的 + if (not static): + # 则返回object.__getattr__(self, name) + return object.__getattr__(self, name) + # 否则抛出AttributeError异常 + else: + raise AttributeError(name) + + +# 定义_swig_getattr函数,将类和名称作为参数 +def _swig_getattr(self, class_type, name): + # 返回_swig_getattr_nondynamic函数,将类、名称和静态作为参数 + return _swig_getattr_nondynamic(self, class_type, name, 0) + + +# 定义_swig_repr函数,将self作为参数 +def _swig_repr(self): + # 尝试将self.__repr__()赋值给strthis + try: + strthis = "proxy of " + self.this.__repr__() + # 如果不存在,则strthis为空 + except: + strthis = "" + # 返回<%s.%s; %s > % % (self.__class__.__module__, self.__class__.__name__, strthis,) + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + + +# 尝试获取object类 +try: + _object = object + # 如果存在,则_newclass为1 + _newclass = 1 +# 如果不存在,则_object为空,_newclass为0 +except AttributeError: + class _object: + pass + _newclass = 0 + + +class SnowboyDetect(_object): + __swig_setmethods__ = {} + def __setattr__(self, name, value): return _swig_setattr( + self, SnowboyDetect, name, value) + __swig_getmethods__ = {} + def __getattr__(self, name): return _swig_getattr( + self, SnowboyDetect, name) + __repr__ = _swig_repr + + def __init__(self, resource_filename, model_str): + this = _snowboydetect.new_SnowboyDetect(resource_filename, model_str) + try: + self.this.append(this) + except: + self.this = this + + def Reset(self): + return _snowboydetect.SnowboyDetect_Reset(self) + + def RunDetection(self, *args): + return _snowboydetect.SnowboyDetect_RunDetection(self, *args) + + def SetSensitivity(self, sensitivity_str): + return _snowboydetect.SnowboyDetect_SetSensitivity(self, sensitivity_str) + + def GetSensitivity(self): + return _snowboydetect.SnowboyDetect_GetSensitivity(self) + + def SetAudioGain(self, audio_gain): + return _snowboydetect.SnowboyDetect_SetAudioGain(self, audio_gain) + + def UpdateModel(self): + return _snowboydetect.SnowboyDetect_UpdateModel(self) + + def NumHotwords(self): + return _snowboydetect.SnowboyDetect_NumHotwords(self) + + def SampleRate(self): + return _snowboydetect.SnowboyDetect_SampleRate(self) + + def NumChannels(self): + return _snowboydetect.SnowboyDetect_NumChannels(self) + + def BitsPerSample(self): + return _snowboydetect.SnowboyDetect_BitsPerSample(self) + __swig_destroy__ = _snowboydetect.delete_SnowboyDetect + def __del__(self): return None + + +SnowboyDetect_swigregister = _snowboydetect.SnowboyDetect_swigregister +SnowboyDetect_swigregister(SnowboyDetect) + +# This file is compatible with both classic and new-style classes. diff --git a/src/voice_assistant/text/test_unit.py b/src/voice_assistant/text/test_unit.py new file mode 100644 index 0000000..70becc2 --- /dev/null +++ b/src/voice_assistant/text/test_unit.py @@ -0,0 +1,52 @@ +import unittest +from unittest.mock import MagicMock +from unittest.mock import patch + +class TestMyCode(unittest.TestCase): + + def setUp(self): + self.detector = MagicMock(spec=snowboydecoder.HotwordDetector) + self.pa = MagicMock(spec=PyAudio) + self.wf = MagicMock(spec=wave.open) + self.p = MagicMock() + self.stream = MagicMock() + self.data = MagicMock() + + @patch('snowboydecoder.HotwordDetector') + @patch('PyAudio.PyAudio') + @patch('wave.open') + def test_detected(self, mock_wave_open, mock_pyaudio, mock_hotword_detector): + mock_hotword_detector.return_value = self.detector + self.detector.start = MagicMock() + self.detector.terminate = MagicMock() + + with patch('builtins.print') as mock_print: + detected() + mock_print.assert_called_with('唤醒成功') + self.detector.start.assert_called_with(detected_callback=detected, interrupt_check=interrupt_callback, sleep_time=0.03) + self.detector.terminate.assert_called() + + @patch('PyAudio.PyAudio') + @patch('wave.open') + def test_my_record(self, mock_wave_open, mock_pyaudio): + self.pa.return_value = self.pa + self.pa.open = MagicMock(return_value=self.stream) + self.stream.read = MagicMock(return_value=self.data) + + my_record() + + self.pa.open.assert_called_with(format=paInt16, channels=channels, rate=framerate, input=True, frames_per_buffer=num_samples) + self.stream.read.assert_called_with(num_samples) + + @patch('requests.post') + def test_speech2text(self, mock_requests_post): + mock_response = MagicMock() + mock_response.json = MagicMock(return_value={'result': ['你好']}) + mock_requests_post.return_value = mock_response + + speech = MagicMock() + result = speech2text(speech, 'token') + self.assertEqual(result, '你好') + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/src/voice_assistant/xm.pmdl b/src/voice_assistant/xm.pmdl new file mode 100644 index 0000000..e753476 Binary files /dev/null and b/src/voice_assistant/xm.pmdl differ