Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update paraformer model v2 #10

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions example/paraformer/voice_file/recordfile2text.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func main() {
model := paraformer.ParaformerV1
model := paraformer.ParaformerV2
token := os.Getenv("DASHSCOPE_API_KEY")
if token == "" {
panic("token is empty")
Expand All @@ -29,12 +29,14 @@ func main() {
filePath := "file://" + voiceFile

req := &paraformer.AsyncTaskRequest{
Model: paraformer.ParaformerV1,
Model: paraformer.ParaformerV2,
Input: paraformer.AsyncInput{
// 官方示例中使用的远程文件.
// FileURLs: []string{"https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/paraformer/hello_world_female2.wav"},
// 本地文件.
FileURLs: []string{filePath},
FileURLs: []string{filePath},
DisfluencyRemovalEnabled: true,
LanguageHints: []string{"zh", "en"},
},
Download: true, // 是否下载异步任务结果.
}
Expand Down
6 changes: 5 additions & 1 deletion paraformer/dtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ type AsyncTaskRequest struct {
}

type AsyncInput struct {
FileURLs []string `json:"file_urls"`
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 AsyncTaskResponse struct {
Expand Down
5 changes: 5 additions & 0 deletions paraformer/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ const (
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"
)

const (
Expand Down
Loading