File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
apps/setting/models_provider/impl/aliyun_bai_lian_model_provider/model Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 11from typing import Dict
22
33import dashscope
4- from dashscope . audio . tts_v2 import *
4+
55from django .utils .translation import gettext as _
66
77from common .util .common import _remove_empty_lines
@@ -38,9 +38,14 @@ def check_auth(self):
3838
3939 def text_to_speech (self , text ):
4040 dashscope .api_key = self .api_key
41- synthesizer = SpeechSynthesizer (model = self .model , ** self .params )
4241 text = _remove_empty_lines (text )
43- audio = synthesizer .call (text )
42+ if 'sambert' in self .model :
43+ from dashscope .audio .tts import SpeechSynthesizer
44+ audio = SpeechSynthesizer .call (model = self .model , text = text , ** self .params ).get_audio_data ()
45+ else :
46+ from dashscope .audio .tts_v2 import SpeechSynthesizer
47+ synthesizer = SpeechSynthesizer (model = self .model , ** self .params )
48+ audio = synthesizer .call (text )
4449 if type (audio ) == str :
4550 print (audio )
4651 raise Exception (audio )
You can’t perform that action at this time.
0 commit comments