This tool generates diary-style text by combining tweets retrieved from X (formerly Twitter) with weather data. Additionally, it extracts elements from the generated diary necessary for image creation and uses an image generation API to produce related images.
-
Tweet Retrieval
- Fetches tweets from a specified user.
- Option to use mock data is also available.
-
Weather Data Retrieval
- Retrieves weather data for a specified period and location.
- Can use either mock data or real weather data APIs.
-
Diary Generation
- Converts tweet content into a diary format.
-
Image Generation
- Extracts situations and characters from the diary and uses an image generation API to create images.
-
File Output
- Saves the generated diary and images to a specified directory.
- External APIs
- Weather data retrieval: Weather Data Web API
- Image generation: Gemini
- Tweet retrieval: Tweepy
-
Install the required libraries:
pip install -r requirements.txt
-
Set up environment variables. Create a
.envfile with the following content:X_API_KEY="YOUR_X_API_KEY" X_API_KEY_SECRET="YOUR_X_API_KEY_SECRET" X_ACCESS_TOKEN="YOUR_X_ACCESS_TOKEN" X_ACCESS_TOKEN_SECRET="YOUR_X_ACCESS_TOKEN_SECRET" X_BEARER_TOKEN="X_BEARER_TOKEN" GEMINI_KEY="YOUR_GEMINI_API_KEY"
-
To run using actual data:
python src/main.py --user_name <user_name> --location_name <location> --start_date <start_date> --end_date <end_date>
Example:
python src/main.py --user_name "example_user" --location_name "Tokyo" --start_date "2023-05-01" --end_date "2023-05-07"
-
To run using mock data:
python src/main.py --mock
Notes:
user_nameshould be the X username. The@symbol is optional.location_nameshould correspond to a location listed in materials/station_data.json.start_dateandend_datemust be strings inyyyy-mm-ddformat.- The period between
start_dateandend_datemust be less than one month.- Example:
start_date=2024-03-20→end_date=2024-04-19✅start_date=2024-03-20→end_date=2024-04-20❌
- Example:
- Comply with X API terms of service.
- The generated diary entries and images may not always be realistic or appropriate. Please verify before use.
-
Switch Weather Data Retrieval to JMA API
Currently, the Japan Meteorological Agency's historical weather data download is under maintenance, so a third-party API is being used, which references JMA data. Once maintenance is complete, the tool will be updated to download data directly from JMA.