siddhartharya commited on
Commit
bf3ae24
·
verified ·
1 Parent(s): 2872581

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +4 -4
utils.py CHANGED
@@ -14,7 +14,7 @@ tokenizer = tiktoken.get_encoding("cl100k_base")
14
  VOICERSS_API_KEY = os.environ["VOICERSS_API_KEY"]
15
 
16
  class DialogueItem(BaseModel):
17
- speaker: Literal["Maria", "Sarah"]
18
  text: str
19
 
20
  class Dialogue(BaseModel):
@@ -57,7 +57,7 @@ def generate_script(system_prompt: str, input_text: str, tone: str, target_lengt
57
  Generate a complete, well-structured podcast script that:
58
  1. Starts with a proper introduction
59
  2. Covers the main points from the input text
60
- 3. Has a natural flow of conversation between Maria and Sarah
61
  4. Concludes with a summary and sign-off
62
  5. Fits within the {word_limit} word limit for the target length of {target_length}
63
 
@@ -95,8 +95,8 @@ def generate_script(system_prompt: str, input_text: str, tone: str, target_lengt
95
  return dialogue
96
 
97
  def generate_audio(text: str, speaker: str) -> str:
98
- voice = "en-us" if speaker == "Maria" else "en-gb"
99
- url = f"http://api.voicerss.org/?key={VOICERSS_API_KEY}&hl={voice}&src={text}"
100
 
101
  response = requests.get(url)
102
  if response.status_code != 200:
 
14
  VOICERSS_API_KEY = os.environ["VOICERSS_API_KEY"]
15
 
16
  class DialogueItem(BaseModel):
17
+ speaker: Literal["John", "Lily"]
18
  text: str
19
 
20
  class Dialogue(BaseModel):
 
57
  Generate a complete, well-structured podcast script that:
58
  1. Starts with a proper introduction
59
  2. Covers the main points from the input text
60
+ 3. Has a natural flow of conversation between John and Lily
61
  4. Concludes with a summary and sign-off
62
  5. Fits within the {word_limit} word limit for the target length of {target_length}
63
 
 
95
  return dialogue
96
 
97
  def generate_audio(text: str, speaker: str) -> str:
98
+ voice = "John" if speaker == "John" else "Lily"
99
+ url = f"http://api.voicerss.org/?key={VOICERSS_API_KEY}&hl=en-us&v={voice}&src={text}"
100
 
101
  response = requests.get(url)
102
  if response.status_code != 200: