Skip to content

Commit

Permalink
Merge pull request #10 from biu7/main
Browse files Browse the repository at this point in the history
update paraformer model v2
  • Loading branch information
devinyf authored Nov 12, 2024
2 parents 91ec842 + 3df837b commit 9e84fae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
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

0 comments on commit 9e84fae

Please sign in to comment.