Spaces:
Running
Running
Upload 5 files
Browse files
src/__init__.py
ADDED
|
File without changes
|
src/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (159 Bytes). View file
|
|
|
src/__pycache__/story_gen.cpython-311.pyc
ADDED
|
Binary file (3.65 kB). View file
|
|
|
src/story_gen.py
CHANGED
|
@@ -4,12 +4,13 @@ from gtts import gTTS
|
|
| 4 |
from langchain_groq import ChatGroq
|
| 5 |
from langchain.messages import HumanMessage, SystemMessage
|
| 6 |
import os
|
|
|
|
| 7 |
|
| 8 |
# Load variables from .env
|
| 9 |
load_dotenv()
|
| 10 |
|
| 11 |
# Access key
|
| 12 |
-
groq_api_key =
|
| 13 |
|
| 14 |
chat = ChatGroq(
|
| 15 |
model="openai/gpt-oss-20b",
|
|
@@ -67,17 +68,20 @@ Write the story in STYLE style with:
|
|
| 67 |
"""
|
| 68 |
|
| 69 |
|
| 70 |
-
def generate_story(story_plot,
|
| 71 |
messages=[
|
| 72 |
-
SystemMessage(content=sys_prompt.replace("LANGUAGE",
|
| 73 |
HumanMessage(content=story_plot)
|
| 74 |
]
|
| 75 |
response = chat.invoke(messages)
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
-
tts = gTTS(text=response.content, lang=
|
| 81 |
tts.save(fileName)
|
| 82 |
|
| 83 |
return {
|
|
|
|
| 4 |
from langchain_groq import ChatGroq
|
| 5 |
from langchain.messages import HumanMessage, SystemMessage
|
| 6 |
import os
|
| 7 |
+
from app_ui.utils.utils import app_config_col
|
| 8 |
|
| 9 |
# Load variables from .env
|
| 10 |
load_dotenv()
|
| 11 |
|
| 12 |
# Access key
|
| 13 |
+
groq_api_key = app_config_col.get("GROQ_API_KEY")
|
| 14 |
|
| 15 |
chat = ChatGroq(
|
| 16 |
model="openai/gpt-oss-20b",
|
|
|
|
| 68 |
"""
|
| 69 |
|
| 70 |
|
| 71 |
+
def generate_story(story_plot,config):
|
| 72 |
messages=[
|
| 73 |
+
SystemMessage(content=sys_prompt.replace("LANGUAGE",config.get('lang')[0]).replace('LANG',config.get('lang')[1])),
|
| 74 |
HumanMessage(content=story_plot)
|
| 75 |
]
|
| 76 |
response = chat.invoke(messages)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
user_name=config.get('user')
|
| 80 |
+
fileName=f"{user_name}_{uuid.uuid4().hex}.wav"
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
+
tts = gTTS(text=response.content, lang=config.get('lang')[1])
|
| 85 |
tts.save(fileName)
|
| 86 |
|
| 87 |
return {
|