You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

语音转写

示例代码
<?php
include './vendor/autoload.php';

// 设置转写参数
$lfasrConfig = [
    'hasParticiple' => 'true'
    //...  
];

// 这里的$app_id、$secret_key是在开放平台控制台获得
$client = new IFlytek\Xfyun\Speech\LfasrClient($app_id, $secret_key, $lfasrConfig);

// $filePath为待转写的本地文件路径返回taskId作为后续查询进度、获取结果操作的参数
$taskId = $client->combineUpload($filePath);

// 查询进度json格式
$progress = $client->getProgress($taskId)->getBody()->getContents();

// 获取结果json格式
$result = $client->getResult($taskId)->getBody()->getContents();

更详细请参见Demo

合成参数
参数 类型 必须 说明 示例
lfasrType string 转写类型,默认 0
0: (标准版,格式: wav,flac,opus,mp3,m4a)
2: (电话版,已取消)
0
hasParticiple string 转写结果是否包含分词信息 false或true 默认false
maxAlternatives string 转写结果中最大的候选词个数 默认0最大不超过5
speakerNumber string 发音人个数可选值0-100表示盲分
:发音人分离目前还是测试效果达不到商用标准,如测试无法满足您的需求,请慎用该功能。
默认2适用通话时两个人对话的场景
hasSeperate string 转写结果中是否包含发音人分离信息 false或true默认为false
roleType string 支持两种参数
1: 通用角色分离
2: 电话信道角色分离适用于speaker_number为2的说话场景
该字段只有在开通了角色分离功能的前提下才会生效,正确传入该参数后角色分离效果会有所提升。 如果该字段不传,默认采用 1 类型
language string 语种
cn:中英文&中文(默认)
en:英文(英文不支持热词)
cn
pd string 垂直领域个性化参数:
法院: court
教育: edu
金融: finance
医疗: medical
科技: tech
设置示例:prepareParam.put("pd", "edu")
pd为非必须设置参数不设置参数默认为通用