diff --git a/app.py b/app.py index 5ec587a..de855c9 100644 --- a/app.py +++ b/app.py @@ -634,7 +634,11 @@ def generate_speaking_video(): try: data = request.get_json() avatar = data.get("avatar", random.choice(list(AvatarEnum)).value) - sp1_result = create_video(data["question"], avatar) + prompts = data.get("prompts", []) + question = data.get("question") + if len(prompts) > 0: + question = question + " In your answer you should consider: " + " ".join(prompts) + sp1_result = create_video(question, avatar) if sp1_result is not None: sound_file_path = VIDEO_FILES_PATH + sp1_result firebase_file_path = FIREBASE_SPEAKING_VIDEO_FILES_PATH + sp1_result @@ -644,7 +648,7 @@ def generate_speaking_video(): return { "text": data["question"], - "prompts": data["prompts"] if "prompts" in data else [], + "prompts": prompts, "title": data["topic"], "video_url": sp1_video_url, "video_path": sp1_video_path, diff --git a/helper/speech_to_text_helper.py b/helper/speech_to_text_helper.py index e536cf8..a08403f 100644 --- a/helper/speech_to_text_helper.py +++ b/helper/speech_to_text_helper.py @@ -36,6 +36,15 @@ def text_to_speech(text: str, file_name: str): VoiceId=voice ) audio_segments.append(tts_response['AudioStream'].read()) + + # Add finish message + audio_segments.append(client.synthesize_speech( + Engine="neural", + Text="This audio recording, for the listening exercise, has finished.", + OutputFormat="mp3", + VoiceId="Stephen" + )['AudioStream'].read()) + # Combine the audio segments into a single audio file combined_audio = b"".join(audio_segments) # Save the combined audio to a single file @@ -63,6 +72,15 @@ def conversation_text_to_speech(conversation: list, file_name: str): VoiceId=segment["voice"] ) audio_segments.append(response['AudioStream'].read()) + + # Add finish message + audio_segments.append(client.synthesize_speech( + Engine="neural", + Text="This audio recording, for the listening exercise, has finished.", + OutputFormat="mp3", + VoiceId="Stephen" + )['AudioStream'].read()) + # Combine the audio segments into a single audio file combined_audio = b"".join(audio_segments) # Save the combined audio to a single file