Spaces:
Sleeping
Sleeping
Commit ·
c7b90e4
1
Parent(s): deeeb78
rm unessary comment
Browse files4 unmodified lines567891019 unmodified lines30313233343536103 unmodified lines14014114214314414514613 unmodified lines16016116216316416516634 unmodified lines2012022032042052062074 unmodified linesimport gradio as grimport requestsfrom openai import OpenAIstreet_interview = False19 unmodified linesself.speaker_mapping = {}self._load_transcript()self._process_transcript()self.map_speaker_ids_to_names() # Map speaker IDs to namesdef _load_transcript(self) -> None:"""Load the transcript JSON file."""103 unmodified linesfor segment in self.segments:spk_id = f"spk_{segment.speaker_id}"speaker_name = self.speaker_mapping.get(spk_id, spk_id)segment.speaker_name = speaker_name # Store the speaker name# Recreate the formatted transcript with speaker namesformatted_segments = []13 unmodified linesdef correct_speaker_mapping_with_agenda(self, url: str) -> None:"""Fetch agenda from a URL and correct the speaker mapping using OpenAI."""try:# Fetch the HTML content from the URLresponse = requests.get(url)response.raise_for_status()html_content = response.text34 unmodified lines"You should only update the name if the name sounds very similar, or there is a good spelling overlap/ The Speaker Introduction matches the description of the Talk from Agends. If the name is totally unrelated, keep the original name.")# Use OpenAI API to get corrected mappingclient = OpenAI()completion = client.chat.completions.create(4 unmodified lines56789101119 unmodified lines31323334353637103 unmodified lines14114214314414514614713 unmodified lines16116216316416516616734 unmodified lines2022032042052062074 unmodified linesimport gradio as grimport requestsfrom bs4 import BeautifulSoupfrom openai import OpenAIstreet_interview = False19 unmodified linesself.speaker_mapping = {}self._load_transcript()self._process_transcript()self.map_speaker_ids_to_names()def _load_transcript(self) -> None:"""Load the transcript JSON file."""103 unmodified linesfor segment in self.segments:spk_id = f"spk_{segment.speaker_id}"speaker_name = self.speaker_mapping.get(spk_id, spk_id)segment.speaker_name = speaker_name# Recreate the formatted transcript with speaker namesformatted_segments = []13 unmodified linesdef correct_speaker_mapping_with_agenda(self, url: str) -> None:"""Fetch agenda from a URL and correct the speaker mapping using OpenAI."""try:response = requests.get(url)response.raise_for_status()html_content = response.text34 unmodified lines"You should only update the name if the name sounds very similar, or there is a good spelling overlap/ The Speaker Introduction matches the description of the Talk from Agends. If the name is totally unrelated, keep the original name.")client = OpenAI()completion = client.chat.completions.create(
app.py+4-4