Skip to content

Commit 9e84fae

Browse files
authored
Merge pull request #10 from biu7/main
update paraformer model v2
2 parents 91ec842 + 3df837b commit 9e84fae

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

example/paraformer/voice_file/recordfile2text.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
func main() {
15-
model := paraformer.ParaformerV1
15+
model := paraformer.ParaformerV2
1616
token := os.Getenv("DASHSCOPE_API_KEY")
1717
if token == "" {
1818
panic("token is empty")
@@ -29,12 +29,14 @@ func main() {
2929
filePath := "file://" + voiceFile
3030

3131
req := &paraformer.AsyncTaskRequest{
32-
Model: paraformer.ParaformerV1,
32+
Model: paraformer.ParaformerV2,
3333
Input: paraformer.AsyncInput{
3434
// 官方示例中使用的远程文件.
3535
// FileURLs: []string{"https://dashscope.oss-cn-beijing.aliyuncs.com/samples/audio/paraformer/hello_world_female2.wav"},
3636
// 本地文件.
37-
FileURLs: []string{filePath},
37+
FileURLs: []string{filePath},
38+
DisfluencyRemovalEnabled: true,
39+
LanguageHints: []string{"zh", "en"},
3840
},
3941
Download: true, // 是否下载异步任务结果.
4042
}

paraformer/dtypes.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ type AsyncTaskRequest struct {
7676
}
7777

7878
type AsyncInput struct {
79-
FileURLs []string `json:"file_urls"`
79+
FileURLs []string `json:"file_urls"`
80+
VocabularyID string `json:"vocabulary_id,omitempty"` // 热词表 ID.
81+
ChannelID []int `json:"channel_id,omitempty"` // 音轨索引.
82+
DisfluencyRemovalEnabled bool `json:"disfluency_removal_enabled,omitempty"` // 过滤语气词.
83+
LanguageHints []string `json:"language_hints,omitempty"` // 识别语音中语言的代码列表. 仅对paraformer-v2生效
8084
}
8185

8286
type AsyncTaskResponse struct {

paraformer/params.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ const (
99
ParaformerV1 ModelParaformer = "paraformer-v1"
1010
Paraformer8KV1 ModelParaformer = "paraformer-8k-v1"
1111
ParaformerMtlV1 ModelParaformer = "paraformer-mtl-v1"
12+
ParaformerV2 ModelParaformer = "paraformer-v2"
13+
Paraformer8KV2 ModelParaformer = "paraformer-8k-v2"
14+
1215
// real time voice.
1316
ParaformerRealTimeV1 ModelParaformer = "paraformer-realtime-v1"
1417
ParaformerRealTime8KV1 ModelParaformer = "paraformer-realtime-8k-v1"
18+
ParaformerRealTimeV2 ModelParaformer = "paraformer-realtime-v2"
19+
ParaformerRealTime8KV2 ModelParaformer = "paraformer-realtime-8k-v2"
1520
)
1621

1722
const (

0 commit comments

Comments
 (0)