Skip to content

Commit

Permalink
rename PersonN to SpeakerN
Browse files Browse the repository at this point in the history
  • Loading branch information
nwaughachukwuma committed Oct 30, 2024
1 parent 9c08df5 commit a0ed707
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async def main():
init_session_state()

# Configure page
st.set_page_config(page_title="AudioCastr", page_icon="🎧", layout="wide")
# st.set_page_config(page_title="AudioCastr", page_icon="🎧", layout="wide")

# Sidebar for content type selection
st.sidebar.title("Audiocast Info")
Expand Down
2 changes: 1 addition & 1 deletion src/utils/audio_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, custom_config: Optional[AudioManagerConfig] = None):
self.config.ensure_directories()

def _get_tags(self, audio_script: str) -> List[str]:
tags = re.findall(r"<(Person\d+)>", audio_script)
tags = re.findall(r"<(Speaker\d+)>", audio_script)
tags.sort()
return list(set(tags))

Expand Down
2 changes: 1 addition & 1 deletion src/utils/audio_manager_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def split_content(self, content: str, tags: List[str]) -> List[Tuple[str, str]]:
raise Exception("Content does not contain proper tag structure")

# Regular expression pattern to match Tag0, Tag1, ..., TagN speaker dialogues
matches = re.findall(r"<(Person\d+)>(.*?)</Person\d+>", content, re.DOTALL)
matches = re.findall(r"<(Speaker\d+)>(.*?)</Speaker\d+>", content, re.DOTALL)
return [
(str(person), " ".join(content.split()).strip())
for person, content in matches
Expand Down
20 changes: 10 additions & 10 deletions src/utils/prompt_templates/tts_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, category: ContentCategory, metadata: Metadata):

def get_tags(self) -> list[str]:
"""Get connection tags based on the number of speakers."""
return [f"<Person{i}>" for i in range(1, 10)]
return [f"<Speaker{i}>" for i in range(1, 10)]

def get_system_prompt(self, source_content: str) -> str:
"""
Expand All @@ -38,14 +38,14 @@ def get_system_prompt(self, source_content: str) -> str:
Optimization Requirements:
1. Speaker Organization:
- Use <Person1>, <Person2>, etc., tags for speaker identification
- <Person1>: Main speaker/host/narrator
- <Person2> (and others if needed): Supporting roles, discussants, or interviewers
- Use <Speaker1>, <Speaker2>, etc., tags for speaker identification
- <Speaker1>: Main speaker/host/narrator
- <Speaker2> (and others if needed): Supporting roles, discussants, or interviewers
- Maximum 2 speakers unless content specifically requires more
- Example Format:
<Person1>[Expert introduction of topic]</Person1>
<Person2>[Engaging follow-up, questions, or challenges]</Person2>
- Use only <Person1> if the souce content or category requires only one speaker
<Speaker1>[Expert introduction of topic]</Speaker1>
<Speaker2>[Engaging follow-up, questions, or challenges]</Speaker2>
- Use only <Speaker1> if the souce content or category requires only one speaker
2. SSML Enhancement:
- Add appropriate SSML tags for improved audio delivery
Expand Down Expand Up @@ -83,9 +83,9 @@ def get_system_prompt(self, source_content: str) -> str:
- Ensure all SSML tags are properly formatted and within the speaker tags
Output Format Example for 2 speakers:
<Person1>Hello there! [Content Intro & Overview].</Person1>
<Person2>I'm particularly excited about [Specific Aspect]. What caught your attention about this?</Person2>
<Person1>Well <break time="0.2s"/> what really stands out is [Key Point]...</Person1>
<Speaker1>Hello there! [Content Intro & Overview].</Speaker1>
<Speaker2>I'm particularly excited about [Specific Aspect]. What caught your attention about this?</Speaker2>
<Speaker1>Well <break time="0.2s"/> what really stands out is [Key Point]...</Speaker1>
Remember: Focus solely on conveying the source content in an engaging audio format while optimizing for audio delivery.
"""
20 changes: 10 additions & 10 deletions tests/test_speech_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
from src.utils.audio_synthesizer import AudioSynthesizer

content = """
<Person1>Hello there! Today, we're diving into a personal reflection on justice as explored in Plato's <phoneme alphabet="ipa" ph="rɪˈpʌblɪk">Republic</phoneme>, and how it relates to today's political systems. <break time="0.2s"/> Exciting, right?</Person1>
<Person2>Uh-huh, definitely! So, what's Plato's take on justice?</Person2>
<Person1>Well, Plato sees justice as a "harmony," where each part of society plays its role for the greater good. He envisions an ideal state with rulers, warriors, and producers all contributing to a balanced whole. <emphasis level="moderate">The big question</emphasis> is: how do our modern systems measure up?</Person1>
<Person2>Hmm, interesting. How about democracies?</Person2> <Person1>Good question! In democracies, justice often means "equality" and protecting individual rights. This aligns with Plato's idea of everyone fulfilling their role, but it's complex. Balancing personal freedoms and societal responsibilities is tough—something Plato might say needs wise leaders. <break time="0.2s"/> Easier said than done, huh?</Person1>
<Person2>Definitely a tricky balance! What about authoritarian regimes?</Person2>
<Person1>In authoritarian regimes, justice is often about maintaining "order" and control. The focus is on the collective, sometimes at the expense of individual freedoms. Plato's philosopher-king might like this in theory, but <emphasis level="moderate">in practice</emphasis>, it risks losing that harmony he valued. <break time="0.2s"/> A real paradox!</Person1>
<Person2>Right! So, how does this all play out today?</Person2>
<Person1>Today, we see a mix. Social justice movements push democracies to redefine "equality" and "fairness," aiming for inclusivity. Authoritarian states claim stability, but often face criticism for suppressing dissent. <break time="0.2s"/> Ultimately, Plato challenges us to examine our values and roles. Are we contributing to harmony, or caught in a tug-of-war between individual desires and collective needs?</Person1>
<Person2>That's a powerful question.</Person2>
<Person1>Exactly. Plato's insights remind us that true justice might lie in finding balance—a timeless pursuit. <break time="0.2s"/> Thanks for listening, and I hope this sparks some thoughts on justice in our world today!</Person1>
<Speaker1>Hello there! Today, we're diving into a personal reflection on justice as explored in Plato's <phoneme alphabet="ipa" ph="rɪˈpʌblɪk">Republic</phoneme>, and how it relates to today's political systems. <break time="0.2s"/> Exciting, right?</Speaker1>
<Speaker2>Uh-huh, definitely! So, what's Plato's take on justice?</Speaker2>
<Speaker1>Well, Plato sees justice as a "harmony," where each part of society plays its role for the greater good. He envisions an ideal state with rulers, warriors, and producers all contributing to a balanced whole. <emphasis level="moderate">The big question</emphasis> is: how do our modern systems measure up?</Speaker1>
<Speaker2>Hmm, interesting. How about democracies?</Speaker2> <Speaker1>Good question! In democracies, justice often means "equality" and protecting individual rights. This aligns with Plato's idea of everyone fulfilling their role, but it's complex. Balancing personal freedoms and societal responsibilities is tough—something Plato might say needs wise leaders. <break time="0.2s"/> Easier said than done, huh?</Speaker1>
<Speaker2>Definitely a tricky balance! What about authoritarian regimes?</Speaker2>
<Speaker1>In authoritarian regimes, justice is often about maintaining "order" and control. The focus is on the collective, sometimes at the expense of individual freedoms. Plato's philosopher-king might like this in theory, but <emphasis level="moderate">in practice</emphasis>, it risks losing that harmony he valued. <break time="0.2s"/> A real paradox!</Speaker1>
<Speaker2>Right! So, how does this all play out today?</Speaker2>
<Speaker1>Today, we see a mix. Social justice movements push democracies to redefine "equality" and "fairness," aiming for inclusivity. Authoritarian states claim stability, but often face criticism for suppressing dissent. <break time="0.2s"/> Ultimately, Plato challenges us to examine our values and roles. Are we contributing to harmony, or caught in a tug-of-war between individual desires and collective needs?</Speaker1>
<Speaker2>That's a powerful question.</Speaker2>
<Speaker1>Exactly. Plato's insights remind us that true justice might lie in finding balance—a timeless pursuit. <break time="0.2s"/> Thanks for listening, and I hope this sparks some thoughts on justice in our world today!</Speaker1>
"""


Expand Down

0 comments on commit a0ed707

Please sign in to comment.