├── .gitignore ├── .env.example ├── requirements.txt ├── LICENSE.md ├── README.md └── chat.py /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | OPENAI_API_KEY='' 2 | ELEVEN_API_KEY='' 3 | REPLICATE_API_TOKEN='' 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | replicate 2 | langchain 3 | elevenlabs 4 | python-dotenv 5 | streamlit 6 | openai 7 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Peter 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Story Storm 2 | Introducing Story Storm, a powerful tool that harnesses the power of OpenAI's GPT-3.5 Turbo API to generate fascinating and engaging stories. 3 | But we didn't stop there! We wanted to make your story experience even more immersive. That's why we've also integrated the Eleven Labs API to convert your generated story into an audio narration. 4 | And that's not all! We've also incorporated the replicate API to generate accompanying images for your story. So now, as you listen, you can also see vivid depictions of the story's characters and settings. 5 | 6 | ## Getting Started 7 | To get started, clone the repository and install the required dependencies: 8 | 9 | 10 | ```git clone https://github.com/peterw/StoryStorm.git``` 11 | 12 | ```cd Story_storm``` 13 | 14 | ```pip install -r requirements.txt``` 15 | 16 | ## Prerequisites 17 | You will need to set up API keys for[OpenAI](https://platform.openai.com/account/api-keys),[Eleven Labs ](https://beta.elevenlabs.io/speech-synthesis) [Replicate](https://replicate.com/account/api-tokens). 18 | 19 | ## Usage 20 | To run the program, simply run the following command in the terminal: 21 | 22 | ```streamlit run chat.py``` 23 | 24 | Then enter a word and select a voice to generate a story. 25 | 26 | ## Sponsors 27 | 28 | ✨ Find profitable ideas faster: [Exploding Insights](https://explodinginsights.com/) 29 | 30 | ## License 31 | This project is licensed under the MIT License - see the LICENSE file for details. 32 | -------------------------------------------------------------------------------- /chat.py: -------------------------------------------------------------------------------- 1 | 2 | import os 3 | 4 | import replicate 5 | import streamlit as st 6 | from dotenv import load_dotenv 7 | from elevenlabs import generate 8 | from langchain import PromptTemplate 9 | from langchain.chains import LLMChain 10 | from langchain.llms import OpenAI 11 | 12 | load_dotenv() 13 | 14 | openai_api_key = os.getenv("OPENAI_API_KEY") 15 | eleven_api_key = os.getenv("ELEVEN_API_KEY") 16 | 17 | llm = OpenAI(temperature=0.9) 18 | 19 | def generate_story(text): 20 | """Generate a story using the langchain library and OpenAI's GPT-3 model.""" 21 | prompt = PromptTemplate( 22 | input_variables=["text"], 23 | template=""" 24 | You are a fun and seasoned storyteller. Generate a story for me about {text}. 25 | """ 26 | ) 27 | story = LLMChain(llm=llm, prompt=prompt) 28 | return story.run(text=text) 29 | 30 | 31 | def generate_audio(text, voice): 32 | """Convert the generated story to audio using the Eleven Labs API.""" 33 | audio = generate(text=text, voice=voice, api_key=eleven_api_key) 34 | return audio 35 | 36 | 37 | def generate_images(story_text): 38 | """Generate images using the story text using the Replicate API.""" 39 | output = replicate.run( 40 | "stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf", 41 | input={"prompt": story_text} 42 | ) 43 | return output 44 | 45 | 46 | def app(): 47 | st.title("Story Storm") 48 | 49 | with st.form(key='my_form'): 50 | text = st.text_input( 51 | "Enter a word to generate a story", 52 | max_chars=None, 53 | type="default", 54 | placeholder="Enter a word to generate a story", 55 | ) 56 | options = ["Bella", "Antoni", "Arnold", "Adam", "Domi", "Elli", "Josh", "Rachel", "Sam"] 57 | voice = st.selectbox("Select a voice", options) 58 | 59 | if st.form_submit_button("Submit"): 60 | with st.spinner('Generating story...'): 61 | story_text = generate_story(text) 62 | audio = generate_audio(story_text, voice) 63 | 64 | st.audio(audio, format='audio/mp3') 65 | images = generate_images(story_text) 66 | for item in images: 67 | st.image(item) 68 | 69 | if not text or not voice: 70 | st.info("Please enter a word and select a voice") 71 | 72 | 73 | if __name__ == '__main__': 74 | app() --------------------------------------------------------------------------------