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