From 894acd3c431ff2978ee9e89a4d013306ccb9b110 Mon Sep 17 00:00:00 2001 From: jpgallegoar Date: Mon, 14 Oct 2024 19:33:04 +0200 Subject: [PATCH] Added back parse_emotional_text --- gradio_app.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gradio_app.py b/gradio_app.py index 9c1424b..946b43d 100644 --- a/gradio_app.py +++ b/gradio_app.py @@ -509,6 +509,30 @@ Supported by [RootingInLoad](https://github.com/RootingInLoad) outputs=podcast_output, ) + def parse_emotional_text(gen_text): + # Pattern to find (Emotion) + pattern = r'\((.*?)\)' + + # Split the text by the pattern + tokens = re.split(pattern, gen_text) + + segments = [] + + current_emotion = 'Regular' + + for i in range(len(tokens)): + if i % 2 == 0: + # This is text + text = tokens[i].strip() + if text: + segments.append({'emotion': current_emotion, 'text': text}) + else: + # This is emotion + emotion = tokens[i].strip() + current_emotion = emotion + + return segments + # New section for emotional generation gr.Markdown( """