Merge branch 'harry0703:main' into main

This commit is contained in:
cpanel10x
2024-03-28 10:22:36 +07:00
committed by GitHub
7 changed files with 85 additions and 43 deletions

View File

@@ -1,19 +1,26 @@
# MoneyPrinterTurbo 💸 # MoneyPrinterTurbo 💸
Simply provide a **topic** or **keyword** for a video, and it will automatically generate the video copy, video materials, video subtitles, and video background music before synthesizing a high-definition short video. [Chinese 简体中文](README.md)
> Thanks to [RootFTW](https://github.com/Root-FTW) for the translation
Simply provide a **topic** or **keyword** for a video, and it will automatically generate the video copy, video
materials, video subtitles, and video background music before synthesizing a high-definition short video.
![](docs/webui.jpg) ![](docs/webui.jpg)
## Special Thanks 🙏 ## Special Thanks 🙏
Due to the **deployment** and **usage** of this project, there is a certain threshold for some beginner users. We would like to express our special thanks to Due to the **deployment** and **usage** of this project, there is a certain threshold for some beginner users. We would
like to express our special thanks to
**LuKa (AI Intelligent Multimedia Service Platform)** for providing a free `AI Video Generator` service based on this project. It allows for online use without deployment, which is very convenient. **LuKa (AI Intelligent Multimedia Service Platform)** for providing a free `AI Video Generator` service based on this
project. It allows for online use without deployment, which is very convenient.
- Chinese version: https://reccloud.cn https://reccloud.com
- English version: https://reccloud.com
![](docs/reccloud.jpg) ![](docs/reccloud.com.jpg)
## Features 🎯 ## Features 🎯
@@ -22,14 +29,18 @@ Due to the **deployment** and **usage** of this project, there is a certain thre
- [x] Supports various **high-definition video** sizes - [x] Supports various **high-definition video** sizes
- [x] Portrait 9:16, `1080x1920` - [x] Portrait 9:16, `1080x1920`
- [x] Landscape 16:9, `1920x1080` - [x] Landscape 16:9, `1920x1080`
- [x] Supports **batch video generation**, allowing the creation of multiple videos at once, then selecting the most satisfactory one - [x] Supports **batch video generation**, allowing the creation of multiple videos at once, then selecting the most
satisfactory one
- [x] Supports setting the **duration of video clips**, facilitating adjustments to material switching frequency - [x] Supports setting the **duration of video clips**, facilitating adjustments to material switching frequency
- [x] Supports video copy in both **Chinese** and **English** - [x] Supports video copy in both **Chinese** and **English**
- [x] Supports **multiple voice** synthesis - [x] Supports **multiple voice** synthesis
- [x] Supports **subtitle generation**, with adjustable `font`, `position`, `color`, `size`, and also supports `subtitle outlining` - [x] Supports **subtitle generation**, with adjustable `font`, `position`, `color`, `size`, and also
supports `subtitle outlining`
- [x] Supports **background music**, either random or specified music files, with adjustable `background music volume` - [x] Supports **background music**, either random or specified music files, with adjustable `background music volume`
- [x] Video material sources are **high-definition** and **royalty-free** - [x] Video material sources are **high-definition** and **royalty-free**
- [x] Supports integration with various models such as **OpenAI**, **moonshot**, **Azure**, **gpt4free**, **one-api**, and more - [x] Supports integration with various models such as **OpenAI**, **moonshot**, **Azure**, **gpt4free**, **one-api**, *
*qianwen**
and more
### Future Plans 📅 ### Future Plans 📅
@@ -37,32 +48,34 @@ Due to the **deployment** and **usage** of this project, there is a certain thre
- [ ] Optimize voice synthesis using large models to make the synthesized voice sound more natural and emotionally rich - [ ] Optimize voice synthesis using large models to make the synthesized voice sound more natural and emotionally rich
- [ ] Add video transition effects to make the viewing experience smoother - [ ] Add video transition effects to make the viewing experience smoother
- [ ] Optimize the relevance of video materials - [ ] Optimize the relevance of video materials
- [ ] OLLAMA support
## Video Demos 📺 ## Video Demos 📺
### Portrait 9:16 ### Portrait 9:16
▶️ How to Add Fun to Your Life ▶️ How to Add Fun to Your Life
https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/a84d33d5-27a2-4aba-8fd0-9fb2bd91c6a6 https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/a84d33d5-27a2-4aba-8fd0-9fb2bd91c6a6
▶️ What is the Meaning of Life ▶️ What is the Meaning of Life
https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/112c9564-d52b-4472-99ad-970b75f66476 https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/112c9564-d52b-4472-99ad-970b75f66476
### Landscape 16:9 ### Landscape 16:9
▶️ What is the Meaning of Life ▶️ What is the Meaning of Life
https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/346ebb15-c55f-47a9-a653-114f08bb8073 https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/346ebb15-c55f-47a9-a653-114f08bb8073
▶️ Why Exercise ▶️ Why Exercise
https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/271f2fae-8283-44a0-8aa0-0ed8f9a6fa87 https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/271f2fae-8283-44a0-8aa0-0ed8f9a6fa87
## Installation & Deployment 📥 ## Installation & Deployment 📥
It is recommended to create a Python virtual environment using [conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html) It is recommended to create a Python virtual environment
using [conda](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)
```shell ```shell
git clone https://github.com/harry0703/MoneyPrinterTurbo.git git clone https://github.com/harry0703/MoneyPrinterTurbo.git
@@ -112,13 +125,18 @@ sudo yum install ImageMagick
#### ② Modify the Configuration File #### ② Modify the Configuration File
- Copy the `config.example.toml` file and rename it to `config.toml` - Copy the `config.example.toml` file and rename it to `config.toml`
- Follow the instructions in the `config.toml` file to configure `pexels_api_keys` and `llm_provider`, and according to the llm_provider's service provider, set up the corresponding API Key - Follow the instructions in the `config.toml` file to configure `pexels_api_keys` and `llm_provider`, and according to
- If it's a `Windows` system, `imagemagick_path` is your actual installation path (if you didn't change the path during installation, just uncomment it) the llm_provider's service provider, set up the corresponding API Key
- If it's a `Windows` system, `imagemagick_path` is your actual installation path (if you didn't change the path during
installation, just uncomment it)
#### ③ Configure Large Language Models (LLM) #### ③ Configure Large Language Models (LLM)
- To use `GPT-4.0` or `GPT-3.5`, you need an `API Key` from `OpenAI`. If you don't have one, you can set `llm_provider` to `g4f` (a free-to-use GPT library https://github.com/xtekky/gpt4free) - To use `GPT-4.0` or `GPT-3.5`, you need an `API Key` from `OpenAI`. If you don't have one, you can set `llm_provider`
- Alternatively, you can apply at [Moonshot](https://platform.moonshot.cn/console/api-keys). Register to get 15 yuan of trial money, which allows for about 1500 conversations. Then set `llm_provider="moonshot"` and `moonshot_api_key`. Thanks to [@jerryblues](https://github.com/harry0703/MoneyPrinterTurbo/issues/8) for the suggestion to `g4f` (a free-to-use GPT library https://github.com/xtekky/gpt4free)
- Alternatively, you can apply at [Moonshot](https://platform.moonshot.cn/console/api-keys). Register to get 15 yuan of
trial money, which allows for about 1500 conversations. Then set `llm_provider="moonshot"` and `moonshot_api_key`.
Thanks to [@jerryblues](https://github.com/harry0703/MoneyPrinterTurbo/issues/8) for the suggestion
### Launch the Web Interface 🌐 ### Launch the Web Interface 🌐
@@ -149,7 +167,8 @@ The effect is shown in the following image:
python main.py python main.py
``` ```
After launching, you can view the `API documentation` at http://127.0.0.1:8080/docs and directly test the interface online for a quick experience. After launching, you can view the `API documentation` at http://127.0.0.1:8080/docs and directly test the interface
online for a quick experience.
The effect is shown in the following image: The effect is shown in the following image:
![](docs/api.jpg) ![](docs/api.jpg)
@@ -162,23 +181,28 @@ A list of all supported voices can be viewed here: [Voice List](./docs/voice-lis
Currently, there are 2 ways to generate subtitles: Currently, there are 2 ways to generate subtitles:
- edge: Faster generation speed, better performance, no specific requirements for computer configuration, but the quality may be unstable - edge: Faster generation speed, better performance, no specific requirements for computer configuration, but the
- whisper: Slower generation speed, poorer performance, specific requirements for computer configuration, but more reliable quality quality may be unstable
- whisper: Slower generation speed, poorer performance, specific requirements for computer configuration, but more
reliable quality
You can switch between them by modifying the `subtitle_provider` in the `config.toml` configuration file You can switch between them by modifying the `subtitle_provider` in the `config.toml` configuration file
It is recommended to use `edge` mode, and switch to `whisper` mode if the quality of the subtitles generated is not satisfactory. It is recommended to use `edge` mode, and switch to `whisper` mode if the quality of the subtitles generated is not
satisfactory.
> If left blank, it means no subtitles will be generated. > If left blank, it means no subtitles will be generated.
## Background Music 🎵 ## Background Music 🎵
Background music for videos is located in the project's `resource/songs` directory. Background music for videos is located in the project's `resource/songs` directory.
> The current project includes some default music from YouTube videos. If there are copyright issues, please delete them. > The current project includes some default music from YouTube videos. If there are copyright issues, please delete
> them.
## Subtitle Fonts 🅰 ## Subtitle Fonts 🅰
Fonts for rendering video subtitles are located in the project's `resource/fonts` directory, and you can also add your own fonts. Fonts for rendering video subtitles are located in the project's `resource/fonts` directory, and you can also add your
own fonts.
## Common Questions 🤔 ## Common Questions 🤔
@@ -192,7 +216,8 @@ RuntimeError: No ffmpeg exe could be found.
Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.
``` ```
In this case, you can download ffmpeg from https://www.gyan.dev/ffmpeg/builds/, unzip it, and set `ffmpeg_path` to your actual installation path. In this case, you can download ffmpeg from https://www.gyan.dev/ffmpeg/builds/, unzip it, and set `ffmpeg_path` to your
actual installation path.
```toml ```toml
[app] [app]
@@ -222,7 +247,8 @@ This is likely due to network issues preventing access to foreign services. Plea
[issue 33](https://github.com/harry0703/MoneyPrinterTurbo/issues/33) [issue 33](https://github.com/harry0703/MoneyPrinterTurbo/issues/33)
1. Follow the `example configuration` provided `download address` to install https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-29-Q16-x64-static.exe, using the static library 1. Follow the `example configuration` provided `download address` to
install https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-29-Q16-x64-static.exe, using the static library
2. Do not install in a path with Chinese characters to avoid unpredictable issues 2. Do not install in a path with Chinese characters to avoid unpredictable issues
[issue 54](https://github.com/harry0703/MoneyPrinterTurbo/issues/54#issuecomment-2017842022) [issue 54](https://github.com/harry0703/MoneyPrinterTurbo/issues/54#issuecomment-2017842022)
@@ -233,19 +259,13 @@ Thanks to [@wangwenqiao666](https://github.com/wangwenqiao666) for their researc
## Feedback & Suggestions 📢 ## Feedback & Suggestions 📢
- You can submit an [issue](https://github.com/harry0703/MoneyPrinterTurbo/issues) or a [pull request](https://github.com/harry0703/MoneyPrinterTurbo/pulls). - You can submit an [issue](https://github.com/harry0703/MoneyPrinterTurbo/issues) or
- You can also follow my **TikTok** or **Video Account**: `Wang Xu Harry.AI` a [pull request](https://github.com/harry0703/MoneyPrinterTurbo/pulls).
- I will post some **usage tutorials** and **pure technical** shares there.
- If there are updates and optimizations, I will **notify promptly** there.
- You can also **leave messages** there, and I will **reply as soon as possible**.
| TikTok | | Video Account |
|:-----------------------------------------:|:------------:|:----------------------------------------------------:|
| <img src="docs/douyin.jpg" width="180"> | | <img src="docs/shipinghao.jpg" width="200"> |
## Reference Projects 📚 ## Reference Projects 📚
This project is based on https://github.com/FujiwaraChoki/MoneyPrinter and has been refactored with a lot of optimizations and added functionalities. Thanks to the original author for their spirit of open source. This project is based on https://github.com/FujiwaraChoki/MoneyPrinter and has been refactored with a lot of
optimizations and added functionalities. Thanks to the original author for their spirit of open source.
## License 📝 ## License 📝

View File

@@ -1,5 +1,7 @@
# MoneyPrinterTurbo 💸 # MoneyPrinterTurbo 💸
[English](README-en.md)
只需提供一个视频 **主题****关键词** ,就可以全自动生成视频文案、视频素材、视频字幕、视频背景音乐,然后合成一个高清的短视频。 只需提供一个视频 **主题****关键词** ,就可以全自动生成视频文案、视频素材、视频字幕、视频背景音乐,然后合成一个高清的短视频。
![](docs/webui.jpg) ![](docs/webui.jpg)
@@ -13,7 +15,7 @@
- 中文版https://reccloud.cn - 中文版https://reccloud.cn
- 英文版https://reccloud.com - 英文版https://reccloud.com
![](docs/reccloud.jpg) ![](docs/reccloud.cn.jpg)
## 功能特性 🎯 ## 功能特性 🎯
@@ -29,7 +31,7 @@
- [x] 支持 **字幕生成**,可以调整 `字体``位置``颜色``大小`,同时支持`字幕描边`设置 - [x] 支持 **字幕生成**,可以调整 `字体``位置``颜色``大小`,同时支持`字幕描边`设置
- [x] 支持 **背景音乐**,随机或者指定音乐文件,可设置`背景音乐音量` - [x] 支持 **背景音乐**,随机或者指定音乐文件,可设置`背景音乐音量`
- [x] 视频素材来源 **高清**,而且 **无版权** - [x] 视频素材来源 **高清**,而且 **无版权**
- [x] 支持 **OpenAI**、**moonshot**、**Azure**、**gpt4free**、**one-api** 等多种模型接入 - [x] 支持 **OpenAI**、**moonshot**、**Azure**、**gpt4free**、**one-api**、**通义千问** 等多种模型接入
### 后期计划 📅 ### 后期计划 📅
@@ -37,6 +39,7 @@
- [ ] 优化语音合成,利用大模型,使其合成的声音,更加自然,情绪更加丰富 - [ ] 优化语音合成,利用大模型,使其合成的声音,更加自然,情绪更加丰富
- [ ] 增加视频转场效果,使其看起来更加的流畅 - [ ] 增加视频转场效果,使其看起来更加的流畅
- [ ] 优化视频素材的匹配度 - [ ] 优化视频素材的匹配度
- [ ] OLLAMA 支持
## 视频演示 📺 ## 视频演示 📺

View File

@@ -2,7 +2,6 @@ import logging
import re import re
import json import json
from typing import List from typing import List
import g4f
from loguru import logger from loguru import logger
from openai import OpenAI from openai import OpenAI
from openai import AzureOpenAI from openai import AzureOpenAI
@@ -17,7 +16,7 @@ def _generate_response(prompt: str) -> str:
model_name = config.app.get("g4f_model_name", "") model_name = config.app.get("g4f_model_name", "")
if not model_name: if not model_name:
model_name = "gpt-3.5-turbo-16k-0613" model_name = "gpt-3.5-turbo-16k-0613"
import g4f
content = g4f.ChatCompletion.create( content = g4f.ChatCompletion.create(
model=model_name, model=model_name,
messages=[{"role": "user", "content": prompt}], messages=[{"role": "user", "content": prompt}],
@@ -43,6 +42,10 @@ def _generate_response(prompt: str) -> str:
model_name = config.app.get("azure_model_name") model_name = config.app.get("azure_model_name")
base_url = config.app.get("azure_base_url", "") base_url = config.app.get("azure_base_url", "")
api_version = config.app.get("azure_api_version", "2024-02-15-preview") api_version = config.app.get("azure_api_version", "2024-02-15-preview")
elif llm_provider == "qwen":
api_key = config.app.get("qwen_api_key")
model_name = config.app.get("qwen_model_name")
base_url = "***"
else: else:
raise ValueError("llm_provider is not set, please set it in the config.toml file.") raise ValueError("llm_provider is not set, please set it in the config.toml file.")
@@ -53,6 +56,16 @@ def _generate_response(prompt: str) -> str:
if not base_url: if not base_url:
raise ValueError(f"{llm_provider}: base_url is not set, please set it in the config.toml file.") raise ValueError(f"{llm_provider}: base_url is not set, please set it in the config.toml file.")
if llm_provider == "qwen":
import dashscope
dashscope.api_key = api_key
response = dashscope.Generation.call(
model=model_name,
messages=[{"role": "user", "content": prompt}]
)
content = response["output"]["text"]
return content.replace("\n", "")
if llm_provider == "azure": if llm_provider == "azure":
client = AzureOpenAI( client = AzureOpenAI(
api_key=api_key, api_key=api_key,

View File

@@ -7,7 +7,7 @@
pexels_api_keys = [] pexels_api_keys = []
# 如果你没有 OPENAI API Key可以使用 g4f 代替,或者使用国内的 Moonshot API # 如果你没有 OPENAI API Key可以使用 g4f 代替,或者使用国内的 Moonshot API
llm_provider="openai" # "openai" or "moonshot" or "oneapi" or "g4f" or "azure" llm_provider="openai" # "openai" or "moonshot" or "oneapi" or "g4f" or "azure" or "qwen"
########## OpenAI API Key ########## OpenAI API Key
# Visit https://openai.com/api/ for details on obtaining an API key. # Visit https://openai.com/api/ for details on obtaining an API key.
@@ -40,6 +40,11 @@
azure_model_name="gpt-35-turbo" # replace with your model deployment name azure_model_name="gpt-35-turbo" # replace with your model deployment name
azure_api_version = "2024-02-15-preview" azure_api_version = "2024-02-15-preview"
########## qwen API Key, you need to pip install dashscope firstly
# Visit https://tongyi.aliyun.com/qianwen/ to get more details
qwen_api_key = ""
qwen_model_name = "qwen-max"
# Subtitle Provider, "edge" or "whisper" # Subtitle Provider, "edge" or "whisper"
# If empty, the subtitle will not be generated # If empty, the subtitle will not be generated

View File

Before

Width:  |  Height:  |  Size: 294 KiB

After

Width:  |  Height:  |  Size: 294 KiB

BIN
docs/reccloud.com.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

View File

@@ -10,6 +10,7 @@ streamlit~=1.32.0
loguru~=0.7.2 loguru~=0.7.2
aiohttp~=3.9.3 aiohttp~=3.9.3
urllib3~=2.2.1 urllib3~=2.2.1
pillow~=10.2.0 pillow~=9.5.0
pydantic~=2.6.3 pydantic~=2.6.3
g4f~=0.2.5.4 g4f~=0.2.5.4
dashscope~=1.15.0