From 669227c2cf6525ea10ca2e089c63d0a8688790d4 Mon Sep 17 00:00:00 2001 From: biubiu7 Date: Sat, 9 Nov 2024 16:57:08 +0800 Subject: [PATCH 1/2] update paraformer model v2 --- paraformer/params.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paraformer/params.go b/paraformer/params.go index 140c761..a0a49c9 100644 --- a/paraformer/params.go +++ b/paraformer/params.go @@ -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 ( From 3df837bfe345e25abf811714e3b1a97daeb9b36e Mon Sep 17 00:00:00 2001 From: biubiu7 Date: Sat, 9 Nov 2024 22:02:18 +0800 Subject: [PATCH 2/2] update paraformer model input params --- example/paraformer/voice_file/recordfile2text.go | 8 +++++--- paraformer/dtypes.go | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/example/paraformer/voice_file/recordfile2text.go b/example/paraformer/voice_file/recordfile2text.go index e791ed6..7143956 100644 --- a/example/paraformer/voice_file/recordfile2text.go +++ b/example/paraformer/voice_file/recordfile2text.go @@ -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") @@ -29,12 +29,14 @@ func main() { filePath := "file://" + voiceFile req := ¶former.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, // 是否下载异步任务结果. } diff --git a/paraformer/dtypes.go b/paraformer/dtypes.go index 75fa689..dbe8acb 100644 --- a/paraformer/dtypes.go +++ b/paraformer/dtypes.go @@ -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 {