Skip to content

Commit

Permalink
fix: use empty audio as fallback for failed tts tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Huanshere committed Dec 9, 2024
1 parent 0f3f4ab commit 6bd0a0f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/all_tts_functions/tts_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ def tts_main(text, save_as, number, task_df):
else:
if os.path.exists(save_as):
os.remove(save_as)
raise Exception("Generated audio duration is 0")

if attempt == max_retries - 1:
print(f"Warning: Generated audio duration is 0 for text: {text}")
# Create silent audio file
silence = AudioSegment.silent(duration=100) # 100ms silence
silence.export(save_as, format="wav")
return
print(f"Attempt {attempt + 1} failed, retrying...")
except Exception as e:
if attempt == max_retries - 1:
raise Exception(f"Failed to generate audio after {max_retries} attempts: {str(e)}")
Expand Down

0 comments on commit 6bd0a0f

Please sign in to comment.