Fix repeated voices in listening
This commit is contained in:
@@ -278,6 +278,7 @@ def generate_listening_1_conversation(topic: str):
|
||||
GEN_QUESTION_TEMPERATURE
|
||||
)
|
||||
|
||||
chosen_voices = []
|
||||
name_to_voice = {}
|
||||
for segment in processed['conversation']:
|
||||
if 'voice' not in segment:
|
||||
@@ -285,10 +286,17 @@ def generate_listening_1_conversation(topic: str):
|
||||
if name in name_to_voice:
|
||||
voice = name_to_voice[name]
|
||||
else:
|
||||
voice = None
|
||||
while voice is None:
|
||||
if segment['gender'].lower() == 'male':
|
||||
voice = random.choice(MALE_NEURAL_VOICES)['Id']
|
||||
available_voices = MALE_NEURAL_VOICES
|
||||
else:
|
||||
voice = random.choice(FEMALE_NEURAL_VOICES)['Id']
|
||||
available_voices = FEMALE_NEURAL_VOICES
|
||||
|
||||
chosen_voice = random.choice(available_voices)['Id']
|
||||
if chosen_voice not in chosen_voices:
|
||||
voice = chosen_voice
|
||||
chosen_voices.append(voice)
|
||||
name_to_voice[name] = voice
|
||||
segment['voice'] = voice
|
||||
return response, processed
|
||||
|
||||
Reference in New Issue
Block a user