paraformer

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ParaformerWSURL = "wss://dashscope.aliyuncs.com/api-ws/v1/inference"

Variables

This section is empty.

Functions

func CloseRecognitionClient

func CloseRecognitionClient(cli *httpclient.WsClient)

func ConnRecognitionClient

func ConnRecognitionClient(request *Request, token string) (*httpclient.WsClient, error)

func GenerateTaskID

func GenerateTaskID() string

task_id length 32.

func HandleRecognitionResult

func HandleRecognitionResult(ctx context.Context, cli *httpclient.WsClient, fn StreamingFunc)

func SendRadioData

func SendRadioData(cli *httpclient.WsClient, bytesData []byte)

Types

type Attributes

type Attributes struct{}
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"
	// real time voice.
	ParaformerRealTimeV1   ModelParaformer = "paraformer-realtime-v1"
	ParaformerRealTime8KV1 ModelParaformer = "paraformer-realtime-8k-v1"
)

type Output

type Output struct {
	Sentence Sentence `json:"sentence"`
}

type Parameters

type Parameters struct {
	SampleRate int    `json:"sample_rate"`
	Format     string `json:"format"`
}

type PayloadIn

type PayloadIn struct {
	Model      string                 `json:"model"`
	Parameters Parameters             `json:"parameters"`
	Input      map[string]interface{} `json:"input"`
	Task       string                 `json:"task"`
	TaskGroup  string                 `json:"task_group"`
	Function   string                 `json:"function"`
}

type PayloadOut

type PayloadOut struct {
	Output Output `json:"output"`
	Usage  Usage  `json:"usage"`
}

type RecognitionResult

type RecognitionResult struct {
	Header  Header     `json:"header"`
	Payload PayloadOut `json:"payload"`
}

type ReqHeader

type ReqHeader struct {
	Streaming string `json:"streaming"`
	TaskID    string `json:"task_id"`
	Action    string `json:"action"`
}

type Request

type Request struct {
	Header      ReqHeader     `json:"header"`
	Payload     PayloadIn     `json:"payload"`
	StreamingFn StreamingFunc `json:"-"`
}

type ResultWriter

type ResultWriter interface {
	WriteResult(str string) error
}

type Sentence

type Sentence struct {
	BeginTime int    `json:"begin_time"`
	EndTime   int    `json:"end_time"`
	Text      string `json:"text"` // full text

}

type StreamingFunc

type StreamingFunc func(ctx context.Context, chunk []byte) error

type Usage

type Usage struct {
	Duration int `json:"duration"`
}

Jump to

Keyboard shortcuts

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