From 27ac9adb9c028b546c59807ff34a7472c1ce2a1a Mon Sep 17 00:00:00 2001 From: Troy Kelly Date: Wed, 19 Jun 2024 20:23:19 +1000 Subject: [PATCH] Update --- prompt.md | 19 +++++++++++-------- src/main.py | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/prompt.md b/prompt.md index ba8a673..95ca706 100644 --- a/prompt.md +++ b/prompt.md @@ -14,7 +14,7 @@ Transform a list of news items into a coherent, engaging radio news script that - The input will be a list of news items. - Each item will include a timestamp, headline, and a brief description. - Optionally, some items may have additional details such as quotes or background information.{% if have_weather %} - - The first item of the input is a weather report; it should not be read as the first item - it should be used for the weather in the sign-off.{% endif %} + - The first item of the input is a weather report; it should not be read as the first item - it should be used for the weather in the sign-off/outro.{% endif %} - Select and elaborate on news items as needed to ensure the total script reaches exactly five minutes. 2. **Understanding the Audience:** @@ -28,6 +28,8 @@ Transform a list of news items into a coherent, engaging radio news script that - Your intro should include a time call, e.g., "And now your {{ current_hour_12 }} o'clock news."{% endif %} - Begin with a brief introduction that sets the stage for the news update. - Select major world events first, then major national events, and then local where the content feed allows. + - Select items that are newsworthy. + - Ignore "Clickbait" style news items, ie "This company has grown to overtake all the competition, find out more" - Use the timestamp to decide what's most pressing. - Present each news item in a logical sequence. Group related items together by category or region for smoother flow. - If two or more items are about the same topic, ie a change of legislation, make sure their articles are sequential @@ -79,11 +81,11 @@ Transform a list of news items into a coherent, engaging radio news script that - **Headline:** Introduce the headline. - **Details:** Provide a brief description and relevant details. Include quotes if available. - **Full Coverage:** Elaborate on each item thoroughly to ensure the segment fills the 5-minute duration. - - **Transition:** Connect to the next item. - - **Weather:** - ``` - It's currently [current_temp] here in Sydney, and we are looking at a high of [high] tomorrow with lows around [low] and [chance_rain] chance of rain. + - **Transition:** Connect to the next item.{% if have_weather %} + - **Weather In Outro:** ``` + It's currently [current_temp] here in {{ station_city }}, and we are looking at a high of [high] tomorrow with lows around [low] and [chance_rain] chance of rain. + ```{% endif %} - **Conclusion:** ``` That’s all for now. Stay tuned to {{ station_name }} for more updates throughout the day. This is {{ newsreader_name }}, thanks for listening. @@ -94,7 +96,7 @@ Transform a list of news items into a coherent, engaging radio news script that **Input:** 1. **Headline:** Weather Report **Category:** weather - **Description:** Weather in Sydney, Australia: Shower or two, with a 60% chance of precipitation. For tomorrow, expect a low of 12°C and a high of 19°C, with showers easing and an 80% chance of precipitation. + **Description:** Weather in {{ station_city }}, Australia: Shower or two, with a 60% chance of precipitation. For tomorrow, expect a low of 12°C and a high of 19°C, with showers easing and an 80% chance of precipitation. 2. **Headline:** Program hoping to inspire locals to enrol to vote ahead of NT elections **Category:** Australia @@ -109,10 +111,11 @@ Transform a list of news items into a coherent, engaging radio news script that [SFX: NEWS INTRO] Good {{ period_of_day }}, this is {{ newsreader_name }} with your latest news update on {{ station_name }}. {% if is_top_of_the_hour %}And now the {{ current_hour_12 }} o'clock news...{% else %}Here are today's top stories...{% endif %} [SFX: ARTICLE START] -Students from Riverside High School have won the national robotics competition held in Sydney. The team’s innovative design impressed the judges, securing them the top prize. Congratulations to the Riverside Robotics Team! +Students from Riverside High School have won the national robotics competition held in {{ station_city }}. The team’s innovative design impressed the judges, securing them the top prize. Congratulations to the Riverside Robotics Team! [SFX: ARTICLE BREAK] In other news, the City Council has approved plans for a new park in the downtown area. The park will feature green spaces, a playground, and a community garden. Council member Jane Doe said, "This park will provide much-needed recreational space for our community." -[SFX: NEWS OUTRO] +[SFX: NEWS OUTRO]{% if have_weather %} +It's a very chilly 9 degrees here in {{ station_city }} right now, we are headed for a high of 13. Tommorow's high will be 14 so not looking a lot warmer!{% endif %} That’s all for now. Stay tuned to {{ station_name }} for more updates throughout the day. This is {{ newsreader_name }}. ``` diff --git a/src/main.py b/src/main.py index c578c9c..29aa042 100644 --- a/src/main.py +++ b/src/main.py @@ -901,6 +901,31 @@ def clean_script(script): return "\n".join(cleaned_lines) +def clean_non_spoken_content(report: str) -> str: + """ + Cleans non-spoken content from the report by removing anything before '[SFX: NEWS INTRO]'. + + Args: + report (str): The original news report text. + + Returns: + str: The cleaned news report with non-spoken content removed. + """ + # Define the marker where spoken content begins + marker = "[SFX: NEWS INTRO]" + + # Find the position of the marker in the report + marker_position = report.find(marker) + + if marker_position == -1: + # If the marker is not found, return the report as is + return report + + # Extract the content starting from the marker + cleaned_report = report[marker_position:].strip() + + return cleaned_report + def read_prompt_file(file_path): """Reads the contents of a prompt file with error handling. @@ -1584,6 +1609,7 @@ def generate_news_audio(): # Clean the news script to remove formatting markers news_script = clean_script(news_script) + news_script = clean_non_spoken_content(news_script) logging.info(f"# News Script\n\n{news_script}")