kftools/ivoice-ai

YII2智能语音组件

v1.0.2 2021-03-31 09:17 UTC

This package is not auto-updated.

Last update: 2024-05-01 20:01:23 UTC


README

智能语音交互

平台

更新日志

  • 20210331 对接百度语音识别标准版,为保证识别准确性,推荐使用PCM格式音频
  • 20210327 初始化项目,对接阿里云录音文件识别极速版

使用说明

  • 安装插件

    composer require --prefer-dist kftools/ivoice-ai:^1.0

  • 配置(两种方式二选一)

    • config配置

        'voiceAi'=>[
            'class'=>\kftools\ivoiceAi\VoiceAiComponent::class, // 组件基类
            'driverClass'=>\kftools\ivoiceAi\aliyun\Driver::class, // 服务商对应的类
            'cache'=>'cache', // 缓存组件ID
            'config'=>[ // 各个服务商对应的配置(以下以阿里的举例)
                'accessKey' => 'xxx', // 阿里云accessKey (需申请)
                'accessSecret' => 'xxx', // 阿里云accessSecret (需阿里云申请)
                'appKey' => 'xxx', // 阿里云音频智能应用appKey (需申请)
            ]
        ]
      
    • 代码里实例化组件

        \Yii::createObject([
            'class'=>VoiceAiComponent::class,  // 组件基类
            'driverClass'=>Driver::class, // 服务商对应的类
            'cache'=>'cache', // 缓存组件ID
            'config'=>[ // 各个服务商对应的配置(以下以阿里的举例) 
                'accessKey' => 'xxx',  // 阿里云accessKey (需申请)
                'accessSecret' => 'xxx', // 阿里云accessSecret (需阿里云申请)
                'appKey' => 'xxx', // 阿里云音频智能应用appKey (需申请)
            ]
        ]);
      
  • 使用

          $result = \Yii::$app->voiceAi->flashRecognizer($voicePath);
    

功能说明

  • voiceAi->flashRecognizer(filePath)
    • 录音文件识别极速版
    • 参数说明
      • filePath: 本地录音文件