gabrielchua commited on
Commit
2cf7afe
1 Parent(s): 3b75e3f

fix random_voice_number for suno

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. utils.py +3 -1
app.py CHANGED
@@ -65,8 +65,8 @@ def generate_podcast(
65
 
66
  text = ""
67
 
68
- # Choose random number from 0 to 9
69
- random_voice_number = random.randint(0, 9) # this is for suno model
70
 
71
  if not use_advanced_audio and language in NOT_SUPPORTED_IN_MELO_TTS:
72
  raise gr.Error(ERROR_MESSAGE_NOT_SUPPORTED_IN_MELO_TTS)
 
65
 
66
  text = ""
67
 
68
+ # Choose random number from 0 to 8
69
+ random_voice_number = random.randint(0, 8) # this is for suno model
70
 
71
  if not use_advanced_audio and language in NOT_SUPPORTED_IN_MELO_TTS:
72
  raise gr.Error(ERROR_MESSAGE_NOT_SUPPORTED_IN_MELO_TTS)
utils.py CHANGED
@@ -148,9 +148,11 @@ def generate_podcast_audio(
148
 
149
  def _use_suno_model(text: str, speaker: str, language: str, random_voice_number: int) -> str:
150
  """Generate advanced audio using Bark."""
 
 
151
  audio_array = generate_audio(
152
  text,
153
- history_prompt=f"v2/{language}_speaker_{random_voice_number if speaker == 'Host (Jane)' else random_voice_number + 1}",
154
  )
155
  file_path = f"audio_{language}_{speaker}.mp3"
156
  write_wav(file_path, SAMPLE_RATE, audio_array)
 
148
 
149
  def _use_suno_model(text: str, speaker: str, language: str, random_voice_number: int) -> str:
150
  """Generate advanced audio using Bark."""
151
+ host_voice_num = str(random_voice_number)
152
+ guest_voice_num = str(random_voice_number + 1)
153
  audio_array = generate_audio(
154
  text,
155
+ history_prompt=f"v2/{language}_speaker_{host_voice_num if speaker == 'Host (Jane)' else guest_voice_num}",
156
  )
157
  file_path = f"audio_{language}_{speaker}.mp3"
158
  write_wav(file_path, SAMPLE_RATE, audio_array)