fix: issue where an error occurs when invoking TTS without selecting a voice (#5046)

This commit is contained in:
takatost
2024-06-09 20:28:24 +08:00
committed by GitHub
parent 2573b138bf
commit 5986841e27
3 changed files with 9 additions and 2 deletions

View File

@@ -93,6 +93,13 @@ class AudioService:
raise ProviderNotSupportTextToSpeechServiceError()
try:
if not voice:
voices = model_instance.get_tts_voices()
if voices:
voice = voices[0].get('value')
else:
raise ValueError("Sorry, no voice available.")
return model_instance.invoke_tts(
content_text=text.strip(),
user=end_user,