<?php

namespace App\Services\Vendor\Xunfei;

/**
 * 讯飞语音转化文字
 */
class XunFei
{


    /**
     * 预处理方法
     */
    public function prepare($filesize, $fileBasename)
    {
        $extData = [
            'file_len' => $filesize,
            'file_name' => 'name.' . $fileBasename,
            'slice_num' => 1,
        ];
        $xunfei = new Voice2Text();

        return $xunfei->prepare($extData);
    }

    /**
     * 上传方法
     */
    public function upload($taskId, $fileContent)
    {
        $extData = [
            'task_id' => $taskId,
            'slice_id' => 'aaaaaaaaaa',
            'content' => $fileContent,
        ];
        $xunfei = new Voice2Text();

        return $xunfei->upload($extData);
    }

    /**
     * 合并文件
     */
    public function merge($taskId)
    {
        $extData = [
            'task_id' => $taskId,
        ];
        $xunfei = new Voice2Text();

        return $xunfei->merge($extData);
    }

    /**
     * 获取进度
     */
    public function getProgress($taskId)
    {
        $extData = [
            'task_id' => $taskId,
        ];
        $xunfei = new Voice2Text();

        return $xunfei->getProgress($extData);
    }

    /**
     * 获取结果
     */
    public function getResult($taskId)
    {
        $extData = [
            'task_id' => $taskId,
        ];
        $xunfei = new Voice2Text();

        return $xunfei->getResult($extData);
    }
}
