feat(asr): integrate Automatic Speech Recognition (ASR) support
- Added ASR configuration options to the knowledge base and model settings. - Implemented ASR model selection and transcription capabilities in the knowledge processing pipeline. - Enhanced file upload support to include audio formats for ASR processing. - Updated localization files to include ASR-related labels and descriptions. - Refactored model handling to accommodate ASR as a new model type.
This commit is contained in:
@@ -20,6 +20,8 @@ type ReadResult struct {
|
||||
ImageDirPath string
|
||||
Metadata map[string]string
|
||||
Error string
|
||||
IsAudio bool // true when the result contains raw audio data needing ASR transcription
|
||||
AudioData []byte // raw audio bytes for ASR processing
|
||||
}
|
||||
|
||||
// ImageRef represents an image reference extracted from the document.
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/Tencent/WeKnora/internal/models/chat"
|
||||
"github.com/Tencent/WeKnora/internal/models/embedding"
|
||||
"github.com/Tencent/WeKnora/internal/models/rerank"
|
||||
"github.com/Tencent/WeKnora/internal/models/asr"
|
||||
"github.com/Tencent/WeKnora/internal/models/vlm"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
@@ -32,6 +33,8 @@ type ModelService interface {
|
||||
GetChatModel(ctx context.Context, modelId string) (chat.Chat, error)
|
||||
// GetVLMModel gets a vision language model
|
||||
GetVLMModel(ctx context.Context, modelId string) (vlm.VLM, error)
|
||||
// GetASRModel gets an automatic speech recognition model
|
||||
GetASRModel(ctx context.Context, modelId string) (asr.ASR, error)
|
||||
}
|
||||
|
||||
// ModelRepository defines the model repository interface
|
||||
|
||||
@@ -60,6 +60,8 @@ type KnowledgeBase struct {
|
||||
SummaryModelID string `yaml:"summary_model_id" json:"summary_model_id"`
|
||||
// VLM config
|
||||
VLMConfig VLMConfig `yaml:"vlm_config" json:"vlm_config" gorm:"type:json"`
|
||||
// ASR config (Automatic Speech Recognition)
|
||||
ASRConfig ASRConfig `yaml:"asr_config" json:"asr_config" gorm:"type:json"`
|
||||
// Storage provider config (new): only stores provider selection; credentials from tenant StorageEngineConfig
|
||||
StorageProviderConfig *StorageProviderConfig `yaml:"storage_provider_config" json:"storage_provider_config" gorm:"column:storage_provider_config;type:jsonb"`
|
||||
// Deprecated: legacy COS config column. Kept for backward compatibility with old data.
|
||||
@@ -386,6 +388,35 @@ func (c *VLMConfig) Scan(value interface{}) error {
|
||||
return json.Unmarshal(b, c)
|
||||
}
|
||||
|
||||
// ASRConfig represents the ASR (Automatic Speech Recognition) configuration
|
||||
type ASRConfig struct {
|
||||
Enabled bool `yaml:"enabled" json:"enabled"`
|
||||
ModelID string `yaml:"model_id" json:"model_id"`
|
||||
Language string `yaml:"language" json:"language"` // optional: language hint for transcription
|
||||
}
|
||||
|
||||
// IsASREnabled checks if ASR is enabled with a valid model
|
||||
func (c ASRConfig) IsASREnabled() bool {
|
||||
return c.Enabled && c.ModelID != ""
|
||||
}
|
||||
|
||||
// Value implements the driver.Valuer interface, used to convert ASRConfig to database value
|
||||
func (c ASRConfig) Value() (driver.Value, error) {
|
||||
return json.Marshal(c)
|
||||
}
|
||||
|
||||
// Scan implements the sql.Scanner interface, used to convert database value to ASRConfig
|
||||
func (c *ASRConfig) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
b, ok := value.([]byte)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(b, c)
|
||||
}
|
||||
|
||||
// ExtractConfig represents the extract configuration for a knowledge base
|
||||
type ExtractConfig struct {
|
||||
Enabled bool `yaml:"enabled" json:"enabled"`
|
||||
|
||||
@@ -18,6 +18,7 @@ const (
|
||||
ModelTypeRerank ModelType = "Rerank" // Rerank model
|
||||
ModelTypeKnowledgeQA ModelType = "KnowledgeQA" // KnowledgeQA model
|
||||
ModelTypeVLLM ModelType = "VLLM" // VLLM model
|
||||
ModelTypeASR ModelType = "ASR" // ASR (Automatic Speech Recognition) model
|
||||
)
|
||||
|
||||
// ModelStatus represents the status of the model
|
||||
|
||||
Reference in New Issue
Block a user