-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from f-aguzzi/main
Refactoring of text to speech function.
- Loading branch information
Showing
1 changed file
with
14 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,20 @@ | ||
""" | ||
Basic example of scraping pipeline using SpeechSummaryGraph | ||
""" | ||
|
||
from scrapegraphai.graphs import SpeechSummaryGraph | ||
|
||
def text_to_speech(key:str, prompt:str, url:str): | ||
""" | ||
Given a text it reads after the prompt | ||
def text_to_speech(api_key: str, prompt: str, url: str): | ||
"""Reads text after the prompt from a given URL. | ||
Args: | ||
- url (str): url to scrape | ||
- prompt(str): prompt to do | ||
- key(str) openaikey | ||
- api_key (str): OpenAI API key | ||
- prompt (str): Prompt to use | ||
- url (str): URL to scrape | ||
Returns: | ||
- str: Path to the generated audio file | ||
""" | ||
|
||
|
||
llm_config = { | ||
"api_key": key | ||
} | ||
|
||
# Save the audio to a file | ||
llm_config = {"api_key": api_key} | ||
|
||
# Define the name of the audio file | ||
audio_file = "audio_result.mp3" | ||
speech_summary_graph = SpeechSummaryGraph(prompt, | ||
url, llm_config, | ||
audio_file) | ||
|
||
return speech_summary_graph.run() | ||
|
||
# Create and run the speech summary graph | ||
speech_summary_graph = SpeechSummaryGraph(prompt, url, llm_config, audio_file) | ||
return speech_summary_graph.run() |