Documentation
¶
Index ¶
- Constants
- func CloseRecognitionClient(cli *httpclient.WsClient) error
- func ConnRecognitionClient(request *Request, token string) (*httpclient.WsClient, error)
- func GenerateTaskID() string
- func HandleRecognitionResult(ctx context.Context, cli *httpclient.WsClient, fn StreamingFunc)
- func SendRadioData(cli *httpclient.WsClient, bytesData []byte)
- func TaskURL(taskID string) string
- type AsyncInput
- type AsyncTaskRequest
- type AsyncTaskResponse
- type Attributes
- type FileResult
- type Header
- type ModelParaformer
- type Output
- type Parameters
- type PayloadIn
- type PayloadOut
- type Properties
- type RecognitionResult
- type ReqHeader
- type Request
- type Result
- type ResultWriter
- type Sentence
- type StreamingFunc
- type TaskMetrics
- type TaskResultRequest
- type TaskResultResponse
- type Transcript
- type Usage
- type VoiceFileResponse
- type Word
Constants ¶
View Source
const ( // real-time voice recognition. ParaformerWSURL = "wss://dashscope.aliyuncs.com/api-ws/v1/inference" // audio file to text. ParaformerAsyncURL = "https://dashscope.aliyuncs.com/api/v1/services/audio/asr/transcription" // audio file to text async-task-result query. ParaformerTaskURL = "https://dashscope.aliyuncs.com/api/v1/tasks/%s" )
Variables ¶
This section is empty.
Functions ¶
func CloseRecognitionClient ¶
func CloseRecognitionClient(cli *httpclient.WsClient) error
func ConnRecognitionClient ¶
func ConnRecognitionClient(request *Request, token string) (*httpclient.WsClient, error)
func HandleRecognitionResult ¶
func HandleRecognitionResult(ctx context.Context, cli *httpclient.WsClient, fn StreamingFunc)
func SendRadioData ¶
func SendRadioData(cli *httpclient.WsClient, bytesData []byte)
Types ¶
type AsyncInput ¶
type AsyncInput struct { FileURLs []string `json:"file_urls"` VocabularyID string `json:"vocabulary_id,omitempty"` // 热词表 ID. ChannelID []int `json:"channel_id,omitempty"` // 音轨索引. DisfluencyRemovalEnabled bool `json:"disfluency_removal_enabled,omitempty"` // 过滤语气词. LanguageHints []string `json:"language_hints,omitempty"` // 识别语音中语言的代码列表. 仅对paraformer-v2生效 }
type AsyncTaskRequest ¶
type AsyncTaskRequest struct { Model string `json:"model"` Input AsyncInput `json:"input"` HasUploadOss bool `json:"-"` Download bool `json:"-"` }
=========== 生成异步 task_id.
type AsyncTaskResponse ¶
type AsyncTaskResponse struct { RequestID string `json:"request_id"` Output TaskResultResponse `json:"output"` }
func AsyncVoiceFileRecognitionTask ¶
func AsyncVoiceFileRecognitionTask(ctx context.Context, request *AsyncTaskRequest, cli httpclient.IHttpClient, token string) (*AsyncTaskResponse, error)
func CheckTaskStatus ¶
func CheckTaskStatus(ctx context.Context, req *TaskResultRequest, httpcli httpclient.IHttpClient, options ...httpclient.HTTPOption) (*AsyncTaskResponse, error)
type Attributes ¶
type Attributes struct{}
type FileResult ¶
type FileResult struct { FileURL string `json:"file_url"` Properties Properties `json:"properties"` Transcripts []Transcript `json:"transcripts"` }
=========== 最终结果 ===========.
type Header ¶
type Header struct { TaskID string `json:"task_id"` Event string `json:"event"` Attributes Attributes `json:"attributes"` }
type ModelParaformer ¶
type ModelParaformer = string
const ( // detect from file. ParaformerV1 ModelParaformer = "paraformer-v1" Paraformer8KV1 ModelParaformer = "paraformer-8k-v1" ParaformerMtlV1 ModelParaformer = "paraformer-mtl-v1" ParaformerV2 ModelParaformer = "paraformer-v2" Paraformer8KV2 ModelParaformer = "paraformer-8k-v2" // real time voice. ParaformerRealTimeV1 ModelParaformer = "paraformer-realtime-v1" ParaformerRealTime8KV1 ModelParaformer = "paraformer-realtime-8k-v1" ParaformerRealTimeV2 ModelParaformer = "paraformer-realtime-v2" ParaformerRealTime8KV2 ModelParaformer = "paraformer-realtime-8k-v2" )
type Parameters ¶
type PayloadOut ¶
type Properties ¶
type RecognitionResult ¶
type RecognitionResult struct { Header Header `json:"header"` Payload PayloadOut `json:"payload"` }
type Request ¶
type Request struct { Header ReqHeader `json:"header"` Payload PayloadIn `json:"payload"` StreamingFn StreamingFunc `json:"-"` }
type ResultWriter ¶
type TaskMetrics ¶
type TaskResultRequest ¶
type TaskResultRequest struct {
TaskID string `json:"task_id"`
}
根据 task_id 获取结果.
type TaskResultResponse ¶
type TaskResultResponse struct { TaskID string `json:"task_id,omitempty"` TaskStatus string `json:"task_status,omitempty"` SubmitTime string `json:"submit_time,omitempty"` ScheduledTime string `json:"scheduled_time,omitempty"` EndTime string `json:"end_time,omitempty"` Results []Result `json:"results,omitempty"` TaskMetrics TaskMetrics `json:"task_metrics,omitempty"` }
type Transcript ¶
type VoiceFileResponse ¶
type VoiceFileResponse struct { AsyncTaskResp *AsyncTaskResponse FileResults []*FileResult }
func VoiceFileToTextGeneration ¶
func VoiceFileToTextGeneration(ctx context.Context, req *AsyncTaskRequest, cli httpclient.IHttpClient, token string) (*VoiceFileResponse, error)
Click to show internal directories.
Click to hide internal directories.