Update utils.py
Browse files
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["
|
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
|
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 = "
|
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:
|