StoryCrafterAI is a creative storytelling application that leverages the power of large language models (LLMs) and AI image generation to bring your ideas to life. This project is designed to run completely locally on your CPU, ensuring your privacy and creative control.
- AI-Powered Story Generation: Leverage the power of LangChain to generate unique and engaging stories from your prompts.
- Local Image Generation: Create custom images for your stories using a locally run Stable Diffusion model, ensuring privacy and creative control.
- Audio-to-Text: Transcribe your story ideas from audio recordings directly into text prompts.
- Web-Based Interface: An intuitive and easy-to-use interface built with Django for a seamless user experience.
This project uses the following models, all running locally to ensure privacy and offline functionality:
- Story Generation:
- Primary:
gpt2- A powerful and versatile language model for generating creative and coherent stories. - Fallback:
distilgpt2- A smaller, faster version of GPT-2, used as a fallback to ensure availability.
- Primary:
- Audio Transcription:
whisper-tiny- An efficient and accurate model for transcribing spoken audio into text. - Image Generation:
nota-ai/bk-sdm-small- This is a Block-removed Knowledge-distilled Stable Diffusion Model (BK-SDM), which is an architecturally compressed SDM for efficient general-purpose text-to-image synthesis. This model is built by (i) removing several residual and attention blocks from the U-Net of Stable Diffusion v1.4 and (ii) distillation pretraining on only 0.22M LAION pairs (fewer than 0.1% of the full training set). Despite being trained with very limited resources, this compact model can imitate the original SDM by benefiting from transferred knowledge.
To get started with StoryCrafterAI, follow these steps:
- Python 3.10+
- A C++ compiler (required for some of the dependencies)
- Redis
-
Clone the repository:
git clone https://github.com/PranavDarshan/StoryCrafterAI-LangChain-Local.git cd StoryCrafterAI-LangChain-Local -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Edit the environment file: Edit the .env file and create a hugging face read API and paste it under the HUGGINGFACE_TOKEN
HUGGINGFACE_TOKEN="your-read-token" -
Install the dependencies:
pip install -r requirements.txt
-
Run the database migrations:
python manage.py migrate
-
Start the development server:
python manage.py runserver
-
Open your browser: Navigate to
http://127.0.0.1:8000/to start creating stories.
-
Start the development server:
python manage.py runserver
-
Access the application: Open your web browser and go to
http://127.0.0.1:8000/. -
Provide a Prompt: You can either type a story prompt or upload an audio file.
-
Story Generation: The application uses a local LLM via LangChain to generate a story based on your prompt.
-
Image Generation: The application generates a character and a background image using local Stable Diffusion. These images are then combined.
-
View Your Story: The final story and image are displayed in the browser.
Here's a look at the StoryCrafterAI dashboard, where you can input your story prompt:
This is an example of an image generated by the application based on a story prompt:
Contributions are welcome! Please feel free to submit a pull request or open an issue.
This project is licensed under the MIT License.
This project is for educational and research purposes only. The stories and images generated are not intended for commercial use.
For any questions or feedback, please open an issue on GitHub.

