fix: handle audio generation failure by raising an exception
This commit is contained in:
parent
2971406909
commit
1e8e3a90aa
@ -46,6 +46,8 @@ class AliyunBaiLianTextToSpeech(MaxKBBaseModel, BaseTextToSpeech):
|
|||||||
from dashscope.audio.tts_v2 import SpeechSynthesizer
|
from dashscope.audio.tts_v2 import SpeechSynthesizer
|
||||||
synthesizer = SpeechSynthesizer(model=self.model, **self.params)
|
synthesizer = SpeechSynthesizer(model=self.model, **self.params)
|
||||||
audio = synthesizer.call(text)
|
audio = synthesizer.call(text)
|
||||||
|
if audio is None:
|
||||||
|
raise Exception('Failed to generate audio')
|
||||||
if type(audio) == str:
|
if type(audio) == str:
|
||||||
print(audio)
|
print(audio)
|
||||||
raise Exception(audio)
|
raise Exception(audio)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user