Documentation
¶
Index ¶
- Constants
- Variables
- func GetWSRemoteConnection(connID string) (*websocket.Conn, bool)
- func IsDropAction(err error) bool
- func RemoveWSRemoteConnection(connID string)
- func SetWSRemoteConnection(connID string, conn *websocket.Conn)
- type ConversionStepDef
- type DataMigrateVersion
- type DeleteRequest
- type DropAction
- type EngineRecommendConfig
- type EngineVersionResponse
- type HTTPContent
- type HTTPErrorResponse
- type ListModelResponse
- type ListResponse
- type LoadRequest
- type Model
- type ModelDetails
- type OllamaLoadModelRequest
- type OllamaUnloadModelRequest
- type PathDiskSizeInfo
- type ProgressResponse
- type PullModelRequest
- type PullProgressFunc
- type RecommendConfig
- type ScheduleDetails
- type Service
- type ServiceProvider
- type ServiceProviderProperties
- type ServiceRequest
- type ServiceResult
- type ServiceResultType
- type ServiceTarget
- type SpeechToTextParams
- type StreamMode
- type StreamModeType
- type SupportModel
- type TextToSpeechRequest
- type UnloadModelRequest
- type VersionUpdateRecord
- type WebSocketActionMessage
- type WebSocketEventHeader
- type WebSocketEventMessage
- type WebSocketFinishTaskAction
- type WebSocketParameters
- type WebSocketRecognitionOutput
- type WebSocketResultEvent
- type WebSocketResultPayload
- type WebSocketRunTaskAction
- type WebSocketSentence
Constants ¶
const ( // Database table names TableService = "aog_service" TableServiceProvider = "aog_service_provider" TableModel = "aog_model" TableVersionUpdate = "aog_version_update_record" TableDataMigrateVersion = "aog_data_migration_version" )
const ( ServiceSourceLocal = "local" ServiceSourceRemote = "remote" FlavorAOG = "aog" FlavorTencent = "tencent" FlavorDeepSeek = "deepseek" FlavorOpenAI = "openai" FlavorOllama = "ollama" FlavorBaidu = "baidu" FlavorAliYun = "aliyun" FlavorOpenvino = "openvino" AuthTypeNone = "none" AuthTypeApiKey = "apikey" AuthTypeToken = "token" AuthTypeSign = "sign" ServiceChat = "chat" ServiceModels = "models" ServiceGenerate = "generate" ServiceEmbed = "embed" ServiceTextToImage = "text-to-image" ServiceTextToSpeech = "text-to-speech" ServiceSpeechToText = "speech-to-text" ServiceTextToVideo = "text-to-video" ServiceImageToVideo = "image-to-video" ServiceImageToImage = "image-to-image" ServiceSpeechToTextWS = "speech-to-text-ws" ServiceChatAvatar = constants.BaseDownloadURL + constants.URLDirPathIcon + "/chat.svg" ServiceTextToImageAvatar = constants.BaseDownloadURL + constants.URLDirPathIcon + "/text-to-image.svg" ServiceEmbedAvatar = constants.BaseDownloadURL + constants.URLDirPathIcon + "/Embed.svg" ServiceGenerateAvatar = constants.BaseDownloadURL + constants.URLDirPathIcon + "/Generate.svg" ServiceSpeechToTextAvatar = constants.BaseDownloadURL + constants.URLDirPathIcon + "/Speech-to-text.svg" ServiceTextToSpeechAvatar = constants.BaseDownloadURL + constants.URLDirPathIcon + "/Text-to-speech.svg" ServiceImageToVideoAvatar = constants.BaseDownloadURL + constants.URLDirPathIcon + "/Image-to-video.svg" ServiceImageToImageAvatar = constants.BaseDownloadURL + constants.URLDirPathIcon + "/Image-to-image.svg" ServiceSpeechToTextWSAvatar = constants.BaseDownloadURL + constants.URLDirPathIcon + "/Speech-to-text-ws.svg" ImageTypeUrl = "url" ImageTypePath = "path" ImageTypeBase64 = "base64" HybridPolicyDefault = "default" HybridPolicyLocal = "always_local" HybridPolicyRemote = "always_remote" ProtocolHTTP = "HTTP" ProtocolHTTPS = "HTTPS" ProtocolGRPC = "GRPC" ProtocolGRPC_STREAM = "GRPC_STREAM" ExposeProtocolHTTP = "HTTP" ExposeProtocolWEBSOCKET = "WEBSOCKET" LogLevelDebug = "debug" LogLevelInfo = "info" LogLevelWarn = "warn" LogLevelError = "error" EngineStartModeDaemon = "daemon" EngineStartModeStandard = "standard" VersionRecordStatusInstalled = 1 VersionRecordStatusUpdated = 2 WSTaskTypeAudio = "audio" AudioWav = "wav" AudioMp3 = "mp3" AudioM4a = "m4a" AudioOgg = "ogg" AudioFlac = "flac" AudioAac = "aac" AudioMp4 = "mp4" VoiceMale = "male" VoiceFemale = "female" VoiceGirl = "girl" VoiceBaby = "baby" GPUTypeNvidia = "Nvidia" GPUTypeAmd = "AMD" GPUTypeIntelArc = "Intel Arc" GPUTypeIntelCore = "Intel Core" GPUTypeNone = "None" LanguageZh = "zh" LanguageEn = "en" )
const ( // Client Action types WSActionRunTask = "run-task" WSActionFinishTask = "finish-task" WSSTTTaskTypeUnknown = "unknown" WSSTTTaskTypeRunTask = WSActionRunTask // Start recognition task WSSTTTaskTypeAudio = "audio" // Audio data WSSTTTaskTypeFinishTask = WSActionFinishTask // End recognition task // Server Event types WSEventTaskStarted = "task-started" WSEventTaskFinished = "task-finished" WSEventResultGenerated = "result-generated" WSEventTaskFailed = "task-failed" WSEventTaskResultGenerate = "result-generated" // Error codes WSErrorCodeClientError = "CLIENT_ERROR" WSErrorCodeServerError = "SERVER_ERROR" WSErrorCodeModelError = "MODEL_ERROR" )
WebSocket message constants
Variables ¶
var ( SupportService = []string{ServiceEmbed, ServiceModels, ServiceChat, ServiceGenerate, ServiceTextToImage, ServiceSpeechToText, ServiceSpeechToTextWS, ServiceTextToSpeech, ServiceImageToVideo, ServiceImageToImage} SupportHybridPolicy = []string{HybridPolicyDefault, HybridPolicyLocal, HybridPolicyRemote} SupportAuthType = []string{AuthTypeNone, AuthTypeApiKey, AuthTypeSign, AuthTypeToken} SupportFlavor = []string{FlavorDeepSeek, FlavorOpenAI, FlavorTencent, FlavorOllama, FlavorBaidu, FlavorAliYun, FlavorOpenvino} SupportModelEngine = []string{FlavorOpenvino, FlavorOllama} SupportImageType = []string{ImageTypeUrl, ImageTypeBase64, ImageTypePath} SupportAudioType = []string{AudioWav, AudioMp3} SupportVoiceType = []string{VoiceMale, VoiceFemale, VoiceGirl, VoiceBaby} SupportOnlyRemoteService = []string{ServiceImageToVideo, ServiceImageToImage} SupportServiceAvatar = map[string]string{ ServiceChat: ServiceChatAvatar, ServiceEmbed: ServiceEmbedAvatar, ServiceGenerate: ServiceGenerateAvatar, ServiceTextToImage: ServiceTextToImageAvatar, ServiceTextToSpeech: ServiceTextToSpeechAvatar, ServiceSpeechToText: ServiceSpeechToTextAvatar, ServiceSpeechToTextWS: ServiceSpeechToTextWSAvatar, ServiceImageToVideo: ServiceImageToVideoAvatar, ServiceImageToImage: ServiceImageToImageAvatar, } )
var (
WSRemoteLocalMap = make(map[string]*websocket.Conn)
)
Functions ¶
func GetWSRemoteConnection ¶
GetWSRemoteConnection 线程安全地获取WebSocket连接
func IsDropAction ¶
func RemoveWSRemoteConnection ¶
func RemoveWSRemoteConnection(connID string)
RemoveWSRemoteConnection 线程安全地移除WebSocket连接
func SetWSRemoteConnection ¶
SetWSRemoteConnection 线程安全地设置WebSocket连接
Types ¶
type ConversionStepDef ¶
ConversionStepDef NOTE: we use YAML instead of JSON here because it's easier to read and write In particular, it supports multiline strings which greatly help write jsonata templates
type DataMigrateVersion ¶
type DataMigrateVersion struct { ID int `gorm:"primaryKey;column:id;autoIncrement" json:"id"` Version string `gorm:"column:version;not null" json:"version"` CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP" json:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP" json:"updated_at"` }
VersionUpdateRecord table structure
func (*DataMigrateVersion) Index ¶
func (t *DataMigrateVersion) Index() map[string]interface{}
func (*DataMigrateVersion) PrimaryKey ¶
func (t *DataMigrateVersion) PrimaryKey() string
func (*DataMigrateVersion) SetCreateTime ¶
func (t *DataMigrateVersion) SetCreateTime(time time.Time)
func (*DataMigrateVersion) SetUpdateTime ¶
func (t *DataMigrateVersion) SetUpdateTime(time time.Time)
func (*DataMigrateVersion) TableName ¶
func (t *DataMigrateVersion) TableName() string
type DeleteRequest ¶
type DeleteRequest struct {
Model string `json:"model"`
}
DeleteRequest is the request passed to [Client.Delete].
type DropAction ¶
type DropAction struct{}
func (*DropAction) Error ¶
func (d *DropAction) Error() string
type EngineRecommendConfig ¶
type EngineRecommendConfig struct { Host string `json:"host"` Origin string `json:"origin"` Scheme string `json:"scheme"` RecommendModel string `json:"recommend_model"` DownloadUrl string `json:"download_url"` DownloadPath string `json:"download_path"` EnginePath string `json:"engine_path"` ExecPath string `json:"exec_path"` ExecFile string `json:"exec_file"` }
type EngineVersionResponse ¶
type EngineVersionResponse struct {
Version string `json:"version"`
}
type HTTPContent ¶
func (HTTPContent) String ¶
func (hc HTTPContent) String() string
type HTTPErrorResponse ¶
func (*HTTPErrorResponse) Error ¶
func (hc *HTTPErrorResponse) Error() string
type ListModelResponse ¶
type ListModelResponse struct { Name string `json:"name"` Model string `json:"model"` ModifiedAt time.Time `json:"modified_at"` Size int64 `json:"size"` Digest string `json:"digest"` Details ModelDetails `json:"details,omitempty"` }
ListModelResponse is a single model description in ListResponse.
type ListResponse ¶
type ListResponse struct {
Models []ListModelResponse `json:"models"`
}
ListResponse is the response from [Client.List].
type LoadRequest ¶
type LoadRequest struct {
Model string `json:"model"`
}
type Model ¶
type Model struct { ID int `gorm:"primaryKey;column:id;autoIncrement" json:"id"` ModelName string `gorm:"column:model_name;not null" json:"model_name"` ProviderName string `gorm:"column:provider_name" json:"provider_name"` Status string `gorm:"column:status;not null" json:"status"` ServiceName string `gorm:"column:service_name" json:"service_name"` ServiceSource string `gorm:"column:service_source" json:"service_source"` IsDefault bool `gorm:"column:is_default" json:"is_default"` CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP" json:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP" json:"updated_at"` }
Model table structure
func (*Model) PrimaryKey ¶
func (*Model) SetCreateTime ¶
func (*Model) SetUpdateTime ¶
type ModelDetails ¶
type ModelDetails struct { ParentModel string `json:"parent_model"` Format string `json:"format"` Family string `json:"family"` Families []string `json:"families"` ParameterSize string `json:"parameter_size"` QuantizationLevel string `json:"quantization_level"` }
ModelDetails provides details about a model.
type OllamaLoadModelRequest ¶
type OllamaLoadModelRequest struct {
Model string `json:"model"`
}
type PathDiskSizeInfo ¶
type ProgressResponse ¶
type ProgressResponse struct { Status string `json:"status"` Digest string `json:"digest,omitempty"` Total int64 `json:"total,omitempty"` Completed int64 `json:"completed,omitempty"` }
PullProgressFunc and [PushProgressFunc].
type PullModelRequest ¶
type PullModelRequest struct { Model string `json:"model"` Insecure bool `json:"insecure,omitempty"` Username string `json:"username"` Password string `json:"password"` Stream *bool `json:"stream,omitempty"` ModelType string `json:"model_type,omitempty"` // Deprecated: set the model name with Model instead Name string `json:"name"` }
PullModelRequest is the request passed to [Client.Pull].
type PullProgressFunc ¶
type PullProgressFunc func(ProgressResponse) error
type RecommendConfig ¶
type ScheduleDetails ¶
type Service ¶
type Service struct { Name string `gorm:"primaryKey;column:name" json:"name"` HybridPolicy string `gorm:"column:hybrid_policy;not null;default:default" json:"hybrid_policy"` RemoteProvider string `gorm:"column:remote_provider;not null;default:''" json:"remote_provider"` LocalProvider string `gorm:"column:local_provider;not null;default:''" json:"local_provider"` Status int `gorm:"column:status;not null;default:1" json:"status"` CanInstall int `gorm:"column:can_install;not null;default:0" json:"can_install"` Avatar string `gorm:"column:avatar;not null;default:''" json:"avatar"` CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP" json:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP" json:"updated_at"` }
Service table structure
func (*Service) PrimaryKey ¶
func (*Service) SetCreateTime ¶
func (*Service) SetUpdateTime ¶
type ServiceProvider ¶
type ServiceProvider struct { ID int `gorm:"primaryKey;autoIncrement" json:"id"` ProviderName string `gorm:"column:provider_name" json:"provider_name"` ServiceName string `gorm:"column:service_name" json:"service_name"` ServiceSource string `gorm:"column:service_source;default:local" json:"service_source"` Desc string `gorm:"column:desc" json:"desc"` Method string `gorm:"column:method" json:"method"` URL string `gorm:"column:url" json:"url"` AuthType string `gorm:"column:auth_type" json:"auth_type"` AuthKey string `gorm:"column:auth_key" json:"auth_key"` Flavor string `gorm:"column:flavor" json:"flavor"` ExtraHeaders string `gorm:"column:extra_headers;default:'{}'" json:"extra_headers"` ExtraJSONBody string `gorm:"column:extra_json_body;default:'{}'" json:"extra_json_body"` Properties string `gorm:"column:properties;default:'{}'" json:"properties"` Status int `gorm:"column:status;not null;default:0" json:"status"` CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP" json:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP" json:"updated_at"` }
ServiceProvider Service provider table structure
func (*ServiceProvider) Index ¶
func (t *ServiceProvider) Index() map[string]interface{}
func (*ServiceProvider) PrimaryKey ¶
func (t *ServiceProvider) PrimaryKey() string
func (*ServiceProvider) SetCreateTime ¶
func (t *ServiceProvider) SetCreateTime(time time.Time)
func (*ServiceProvider) SetUpdateTime ¶
func (t *ServiceProvider) SetUpdateTime(time time.Time)
func (*ServiceProvider) TableName ¶
func (t *ServiceProvider) TableName() string
type ServiceRequest ¶
type ServiceRequest struct { AskStreamMode bool `json:"stream"` Model string `json:"model"` HybridPolicy string `json:"hybrid_policy"` RemoteServiceProvider string `json:"remote_service_provider"` FromFlavor string `json:"-"` Service string `json:"-"` Priority int `json:"-"` RequestSegments int `json:"request_segments"` RequestExtraUrl string `json:"extra_url"` HTTP HTTPContent `json:"-"` OriginalRequest *http.Request `json:"-"` WebSocketConnID string `json:"-"` // WebSocket connection ID, used to associate multiple messages on the same connection }
ServiceRequest The body of the OriginalRequest has been read out so need to placed here
func (*ServiceRequest) String ¶
func (sr *ServiceRequest) String() string
type ServiceResult ¶
type ServiceResult struct { Type ServiceResultType TaskId uint64 Error error StatusCode int HTTP HTTPContent }
func (*ServiceResult) String ¶
func (sr *ServiceResult) String() string
func (*ServiceResult) WriteBack ¶
func (sr *ServiceResult) WriteBack(w http.ResponseWriter)
type ServiceResultType ¶
type ServiceResultType int
const ( ServiceResultDone ServiceResultType = iota ServiceResultFailed ServiceResultChunk )
type ServiceTarget ¶
type ServiceTarget struct { Location string Stream bool Model string ToFavor string XPU string Protocol string // Service protocol type, such as GRPC_STREAM ExposeProtocol string ServiceProvider *ServiceProvider }
func (*ServiceTarget) String ¶
func (sr *ServiceTarget) String() string
type SpeechToTextParams ¶
type SpeechToTextParams struct { // 基本参数 TaskID string `json:"task_id,omitempty"` // 任务ID Service string `json:"service,omitempty"` Model string `json:"model,omitempty"` // 模型名称 Language string `json:"language,omitempty"` // 语言,如"zh"、"en" AudioFormat string `json:"audio_format,omitempty"` // 音频格式 SampleRate int `json:"sample_rate,omitempty"` // 采样率 // 高级参数 UseVAD bool `json:"use_vad,omitempty"` // 是否使用VAD ReturnFormat string `json:"return_format,omitempty"` // 返回格式 MaxDuration int `json:"max_duration,omitempty"` // 最大处理时长(秒) // 状态参数 Action string `json:"action,omitempty"` // 当前任务状态 run-task finish-task TotalAudioBytes int `json:"total_audio_bytes,omitempty"` // 总音频字节数 LastAudioTime int64 `json:"last_audio_time,omitempty"` // 最后一次接收音频的时间 }
SpeechToTextParams 语音识别详细参数结构
func NewSpeechToTextParams ¶
func NewSpeechToTextParams() *SpeechToTextParams
NewSpeechToTextParams 创建语音识别参数对象,设置默认值
func (*SpeechToTextParams) FromJSON ¶
func (p *SpeechToTextParams) FromJSON(data []byte) error
FromJSON 从JSON字符串解析参数
func (*SpeechToTextParams) ToJSON ¶
func (p *SpeechToTextParams) ToJSON() ([]byte, error)
ToJSON 将参数转换为JSON字符串
type StreamMode ¶
type StreamMode struct { Mode StreamModeType Header http.Header }
func (*StreamMode) IsStream ¶
func (sm *StreamMode) IsStream() bool
func (*StreamMode) ReadChunk ¶
func (sm *StreamMode) ReadChunk(reader *bufio.Reader) ([]byte, error)
ReadChunk the chunks of the stream is delimited by "\n\n" for event-stream, and "\n" or "\r\n" for x=ndjson so only need to read to '\n'. However, reader can only stop at one character, so we need to handle it by ourselves for "\n\n" case
func (*StreamMode) UnwrapChunk ¶
func (sm *StreamMode) UnwrapChunk(chunk []byte) []byte
UnwrapChunk Get real data event-stream is started with "data: " which need to be removed TODO: event-stream may contain multiple fields, and we only need to pick the data: fields. Need to handle it in the future. Currently we assume there is only a data: field.
func (*StreamMode) WrapChunk ¶
func (sm *StreamMode) WrapChunk(chunk []byte) []byte
type StreamModeType ¶
type StreamModeType int
const ( StreamModeNonStream StreamModeType = iota StreamModeEventStream StreamModeNDJson )
func (StreamModeType) String ¶
func (st StreamModeType) String() string
type SupportModel ¶
type SupportModel struct { Id string `json:"id"` OllamaId string `json:"Ollama_id"` Name string `json:"name"` Avatar string `json:"avatar"` Description string `json:"description"` Class []string `json:"class"` Flavor string `json:"flavor"` ApiFlavor string `json:"api_flavor"` Size string `json:"size"` ParamSize float32 `json:"params_size"` MaxInput int `json:"max_input"` MaxOutput int `json:"max_output"` InputLength int `json:"input_length"` OutputLength int `json:"output_length"` ServiceSource string `json:"service_source"` ServiceName string `json:"service_name"` CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP" json:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP" json:"updated_at"` Think bool `json:"think"` ThinkSwitch bool `json:"think_switch"` Tools bool `json:"tools"` // 是否支持工具调用 Context float32 `json:"context"` }
SupportModel table structure
func (*SupportModel) Index ¶
func (s *SupportModel) Index() map[string]interface{}
func (*SupportModel) PrimaryKey ¶
func (s *SupportModel) PrimaryKey() string
func (*SupportModel) SetCreateTime ¶
func (s *SupportModel) SetCreateTime(time time.Time)
func (*SupportModel) SetUpdateTime ¶
func (s *SupportModel) SetUpdateTime(time time.Time)
func (*SupportModel) TableName ¶
func (s *SupportModel) TableName() string
type TextToSpeechRequest ¶
type UnloadModelRequest ¶
type UnloadModelRequest struct {
Models []string `json:"model"`
}
type VersionUpdateRecord ¶
type VersionUpdateRecord struct { ID int `gorm:"primaryKey;column:id;autoIncrement" json:"id"` Version string `gorm:"column:version;not null" json:"version"` ReleaseNotes string `gorm:"column:release_notes;not null" json:"release_notes"` Status int `gorm:"column:status;not null" json:"status"` CreatedAt time.Time `gorm:"column:created_at;default:CURRENT_TIMESTAMP" json:"created_at"` UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP" json:"updated_at"` }
VersionUpdateRecord table structure
func (*VersionUpdateRecord) Index ¶
func (t *VersionUpdateRecord) Index() map[string]interface{}
func (*VersionUpdateRecord) PrimaryKey ¶
func (t *VersionUpdateRecord) PrimaryKey() string
func (*VersionUpdateRecord) SetCreateTime ¶
func (t *VersionUpdateRecord) SetCreateTime(time time.Time)
func (*VersionUpdateRecord) SetUpdateTime ¶
func (t *VersionUpdateRecord) SetUpdateTime(time time.Time)
func (*VersionUpdateRecord) TableName ¶
func (t *VersionUpdateRecord) TableName() string
type WebSocketActionMessage ¶
type WebSocketActionMessage struct { Task string `json:"task"` // 任务类型,如"speech-to-text-ws" Action string `json:"action"` // 动作类型,如"run-task"或"finish-task" TaskID string `json:"task_id,omitempty"` // 任务ID,由服务端生成并返回,用于后续消息关联 Model string `json:"model,omitempty"` // 模型名称 Parameters *WebSocketParameters `json:"parameters,omitempty"` // 可选参数 }
WebSocketActionMessage 客户端发送到服务端的基础消息结构
type WebSocketEventHeader ¶
type WebSocketEventHeader struct { Action string `json:"action"` Streaming string `json:"streaming"` TaskID string `json:"task_id"` // 任务ID Event string `json:"event"` // 事件类型 ErrorCode string `json:"error_code,omitempty"` // 错误码,仅在task-failed事件中出现 ErrorMessage string `json:"error_message,omitempty"` // 错误信息,仅在task-failed事件中出现 }
WebSocketEventHeader 所有服务端事件的通用头部
type WebSocketEventMessage ¶
type WebSocketEventMessage struct { Header WebSocketEventHeader `json:"header"` // 事件头部 Payload interface{} `json:"payload,omitempty"` // 根据事件类型不同,包含不同的数据 }
WebSocketEventMessage 服务端发送到客户端的基础消息结构
func NewTaskFailedEvent ¶
func NewTaskFailedEvent(taskID, errorCode, errorMessage string) WebSocketEventMessage
NewTaskFailedEvent 创建任务失败事件
func NewTaskFinishedEvent ¶
func NewTaskFinishedEvent(taskID string) WebSocketEventMessage
NewTaskFinishedEvent 创建任务完成事件
func NewTaskStartedEvent ¶
func NewTaskStartedEvent(taskID string) WebSocketEventMessage
NewTaskStartedEvent 创建任务开始事件
type WebSocketFinishTaskAction ¶
type WebSocketFinishTaskAction struct {
WebSocketActionMessage
}
WebSocketFinishTaskAction 结束任务的消息
func NewFinishTaskAction ¶
func NewFinishTaskAction(taskID, model string) WebSocketFinishTaskAction
NewFinishTaskAction 创建结束任务的消息
type WebSocketParameters ¶
type WebSocketParameters struct { Service string `json:"service,omitempty"` // 服务名称,如: "speech-to-text" "speech-to-text-ws" Format string `json:"format,omitempty"` // 音频格式: pcm/wav/mp3 SampleRate int `json:"sample_rate,omitempty"` // 采样率,通常为16000 Language string `json:"language,omitempty"` // 语言,如"zh"、"en" UseVAD bool `json:"use_vad,omitempty"` // 是否使用VAD ReturnFormat string `json:"return_format,omitempty"` // 返回格式,如"text"、"json"、"srt" }
WebSocketParameters 通用参数结构
type WebSocketRecognitionOutput ¶
type WebSocketRecognitionOutput struct {
Sentence WebSocketSentence `json:"sentence"` // 识别的句子
}
WebSocketRecognitionOutput 语音识别输出结构
type WebSocketResultEvent ¶
type WebSocketResultEvent struct { Header WebSocketEventHeader `json:"header"` Payload WebSocketResultPayload `json:"payload"` }
WebSocketResultEvent 识别结果事件
func NewResultGeneratedEvent ¶
func NewResultGeneratedEvent(taskID string, beginTime *int, endTime *int, text string) WebSocketResultEvent
NewResultGeneratedEvent 创建识别结果事件
type WebSocketResultPayload ¶
type WebSocketResultPayload struct {
Output WebSocketRecognitionOutput `json:"output"` // 识别输出
}
WebSocketResultPayload 识别结果的有效载荷
type WebSocketRunTaskAction ¶
type WebSocketRunTaskAction struct {
WebSocketActionMessage
}
WebSocketRunTaskAction 开始任务的消息
func NewRunTaskAction ¶
func NewRunTaskAction(model string, parameters *WebSocketParameters) WebSocketRunTaskAction
NewRunTaskAction 创建开始任务的消息
type WebSocketSentence ¶
type WebSocketSentence struct { BeginTime *int `json:"begin_time"` // 开始时间,毫秒 EndTime *int `json:"end_time"` // 结束时间,毫秒,可能为null Text string `json:"text"` // 识别的文本 }
WebSocketSentence 识别结果中的句子结构