Skip to content

Commit

Permalink
fix random_voice_number for suno
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielchua committed Oct 1, 2024
1 parent 3b75e3f commit 2cf7afe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def generate_podcast(

text = ""

# Choose random number from 0 to 9
random_voice_number = random.randint(0, 9) # this is for suno model
# Choose random number from 0 to 8
random_voice_number = random.randint(0, 8) # this is for suno model

if not use_advanced_audio and language in NOT_SUPPORTED_IN_MELO_TTS:
raise gr.Error(ERROR_MESSAGE_NOT_SUPPORTED_IN_MELO_TTS)
Expand Down
4 changes: 3 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ def generate_podcast_audio(

def _use_suno_model(text: str, speaker: str, language: str, random_voice_number: int) -> str:
"""Generate advanced audio using Bark."""
host_voice_num = str(random_voice_number)
guest_voice_num = str(random_voice_number + 1)
audio_array = generate_audio(
text,
history_prompt=f"v2/{language}_speaker_{random_voice_number if speaker == 'Host (Jane)' else random_voice_number + 1}",
history_prompt=f"v2/{language}_speaker_{host_voice_num if speaker == 'Host (Jane)' else guest_voice_num}",
)
file_path = f"audio_{language}_{speaker}.mp3"
write_wav(file_path, SAMPLE_RATE, audio_array)
Expand Down

0 comments on commit 2cf7afe

Please sign in to comment.