zoukankan      html  css  js  c++  java
  • 乱七八糟


    百度人工智能

    语音类:
    语音识别:
    语音合成:

    图片技术:
    文字识别。。。
    图像识别。。。
    图像审核。。。
    图像处理。。。
    图像搜索。。。


    人脸与人体识别:
    人脸识别。。。
    人体分析。。。

    视频技术:

    AR与VR:
    (AR)增强现实。。。
    (VR)虚拟现实。。。

    自然语言处理:
    语言处理基础技术。。。
    文本审核。。。
    机器翻译。。。



    ai.baidu.com #账号登陆,创建应用生成id,key
    SDK:导包调用(直接封装好了)


    智能问答:语音识别+图灵机器人+语音合成
    1 安装sdk:pip3 install baidu-aip
    #文字转成mp3 语音合成
    #pcm音频文件变成文字输出,语音问语音回答 语音识别

    2 音频文件转码 (ffmpeg安装配置环境) m4a-->pcm
    ffmpeg -y -i nh.m4a -acodec pcm_s16le -f s16le -ac 1 -ar 16000 nh.m4a.pcm
    3 m4a-->pcm在程序中自动转换
    4 模仿说话(语音识别的文字--》语音合成--mp3)
    5 一问一答 my_nlp 自主问答交流系统
    6 自然语言处理:短文本相似度 (另外创建一个应用,使用新的id,key)
    from aip import AipNlp
    7 数据采集,问题无法自己定义的时候
    图灵机器人 http://www.tuling123.com 看官方文档 问答机器人


    8 web录音+智能回答  https://gitee.com/jinjinxu/Smart-question-and-answer


    from aip import AipSpeech
    import os
    import my_nlp
    
    """ 你的 APPID AK SK """
    APP_ID = 'APPID'
    API_KEY = 'AK'
    SECRET_KEY = 'SK'
    
    client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
    
    # 读取文件
    def get_file_content(filePath):
        # m4a--pcm
        any2pcm_str=f"ffmpeg -y  -i {filePath}  -acodec pcm_s16le -f s16le -ac 1 -ar 16000 {filePath}.pcm"
        os.system(any2pcm_str)
        with open(f"{filePath}.pcm", 'rb') as fp:
            return fp.read()
    
    # 识别本地文件
    res = client.asr(get_file_content('age.m4a'), 'pcm', 16000, { #输入端
        'dev_pid': 1536,
    })
    
    Q = res.get('result')[0] #语音(问题)--文字(问题)语音识别
    s = my_nlp.my_nlp(Q)    #文字(问题)--文字(答案) 图灵机器人
    
    # 文字(答案)--音频 (答案)   语音合成
    result  = client.synthesis(s, 'zh', 1, {
        'vol': 5,
    })
    
    # 识别正确返回语音二进制 错误则返回dict 参照下面错误码
    if not isinstance(result, dict):
        with open('auido.mp3', 'wb') as f:
            f.write(result)
    
    os.system('auido.mp3') #系统调用播放音频(答案)
    ssqa.py
    from aip import AipNlp
    import tuling_test
    
    """ 你的 APPID AK SK """
    APP_ID = '14456041'
    API_KEY = 'ybBcLZMDFGMYzlGpzMVhh6Fa'
    SECRET_KEY = 'BtSDog3YYYagxCavzT6BP2SkoRHzeZZp'
    
    client = AipNlp(APP_ID, API_KEY, SECRET_KEY)
    
    def my_nlp(Q):
        return tuling_test.to_tuling(Q)
    my_nlp.py
    import requests
    
    # 文本(问题)--文本 (答案)  不同的问题,不同的回答  调用图灵机器人的接口
    tuling_url = "http://openapi.tuling123.com/openapi/api/v2"
    
    
    data = {
        "reqType": 0,
        "perception": {
            "inputText": {
                "text": "s%"
            },
        },
        "userInfo": {
            "apiKey": "apiKey",
            "userId": "userId"
        }
    }
    
    def to_tuling(Q):
        data["perception"]["inputText"]["text"] = Q
        s = requests.post(tuling_url,json=data)
    
        res = s.json().get("results")[0].get("values").get("text")
    
        return res
    tuling_test.py
  • 相关阅读:
    pytest ini配置文件格式
    C#星辰之路
    bootstrap
    rabbitmq 安装
    curl 下载文件
    mysql 面试题
    mvn --version
    后台运行的nohup vs &
    scp
    linux下.tar.gz和.gz文件解压详解
  • 原文地址:https://www.cnblogs.com/xujinjin18/p/9886476.html
Copyright © 2011-2022 走看看