types

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIReqUpload    = "/resource/create"
	APICommitUpload = "/resource/create/complete"
	APICreateTask   = "/task"
	APIQueryResult  = "/task/result"
)

Variables

View Source
var (
	SupportedInputFormats  = []string{"flac", "aac", "m4a", "mp3", "wav"}
	SupportedOutputFormats = []string{"srt", "json", "lrc", "txt"}
)

Functions

func GetAPIBaseURL

func GetAPIBaseURL() string

GetAPIBaseURL 获取API基础URL

func ProgressStageCN

func ProgressStageCN(stage ProgressStage) string

进度中文

func SetAPIBaseURL

func SetAPIBaseURL(url string)

SetAPIBaseURL 设置API基础URL

Types

type ASRResponse

type ASRResponse struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

ASRResponse 定义API响应结构

type ASRResult

type ASRResult struct {
	Utterances []Utterance `json:"utterances"`
	Version    string      `json:"version"`
}

ASRResult 定义识别结果

func (*ASRResult) ToLRC

func (r *ASRResult) ToLRC() string

ToLRC 将识别结果转换为LRC格式

func (*ASRResult) ToSRT

func (r *ASRResult) ToSRT() string

ToSRT 将识别结果转换为SRT格式

func (*ASRResult) ToTXT

func (r *ASRResult) ToTXT() string

ToTXT 将识别结果转换为纯文本格式

type ProgressCallback

type ProgressCallback func(ProgressInfo)

ProgressCallback 进度回调函数类型

type ProgressInfo

type ProgressInfo struct {
	Stage       ProgressStage // 当前阶段
	Total       int           // 总进度(100)
	Current     int           // 当前进度(0-100)
	Description string        // 当前状态描述
}

ProgressInfo 进度信息

type ProgressStage

type ProgressStage string

ProgressStage 进度阶段

const (
	StageInit     ProgressStage = "init"     // 初始化
	StageUpload   ProgressStage = "upload"   // 上传文件
	StageProcess  ProgressStage = "process"  // 语音识别
	StageComplete ProgressStage = "complete" // 完成
)

type ResourceCompleteResponse

type ResourceCompleteResponse struct {
	ResourceID  string `json:"resource_id"`
	DownloadURL string `json:"download_url"`
}

ResourceCompleteResponse 定义上传完成响应

type ResourceCreateResponse

type ResourceCreateResponse struct {
	ResourceID string   `json:"resource_id"`
	Title      string   `json:"title"`
	Type       int      `json:"type"`
	InBossKey  string   `json:"in_boss_key"`
	Size       int64    `json:"size"`
	UploadURLs []string `json:"upload_urls"`
	UploadID   string   `json:"upload_id"`
	PerSize    int      `json:"per_size"`
}

ResourceCreateResponse 定义上传请响应

type ResultState

type ResultState int
const (
	StateStop     ResultState = 0
	StateRunning  ResultState = 1
	StateError    ResultState = 3
	StateComplete ResultState = 4
)

type TaskCreateResponse

type TaskCreateResponse struct {
	Resource string `json:"resource"`
	Result   string `json:"result"`
	TaskID   string `json:"task_id"`
}

TaskCreateResponse 定义任务创建响应

type TaskResultResponse

type TaskResultResponse struct {
	TaskID string      `json:"task_id"`
	Result string      `json:"result"`
	Remark string      `json:"remark"`
	State  ResultState `json:"state"`
}

TaskResultResponse 义任务结果响应

type Utterance

type Utterance struct {
	StartTime  int64   `json:"start_time"`
	EndTime    int64   `json:"end_time"`
	Transcript string  `json:"transcript"`
	Words      []Words `json:"words"`
}

Utterance 定义识别的句子

type Words

type Words struct {
	Label     string `json:"label"`
	StartTime int64  `json:"start_time"`
	EndTime   int64  `json:"end_time"`
}

Words 定义识别的词

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL