diff --git a/README-en.md b/README-en.md index bd0241c..8f88a6e 100644 --- a/README-en.md +++ b/README-en.md @@ -1,19 +1,26 @@ # 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) ## 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 -- English version: https://reccloud.com +https://reccloud.com -![](docs/reccloud.jpg) +![](docs/reccloud.com.jpg) ## 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] Portrait 9:16, `1080x1920` - [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 video copy in both **Chinese** and **English** - [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] 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 📅 @@ -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 - [ ] Add video transition effects to make the viewing experience smoother - [ ] Optimize the relevance of video materials +- [ ] OLLAMA support ## Video Demos 📺 ### 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 -▶️ “What is the Meaning of Life” +▶️ What is the Meaning of Life https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/112c9564-d52b-4472-99ad-970b75f66476 ### 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 -▶️ “Why Exercise” +▶️ Why Exercise https://github.com/harry0703/MoneyPrinterTurbo/assets/4928832/271f2fae-8283-44a0-8aa0-0ed8f9a6fa87 ## 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 git clone https://github.com/harry0703/MoneyPrinterTurbo.git @@ -112,13 +125,18 @@ sudo yum install ImageMagick #### ② Modify the Configuration File - 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 -- 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) +- 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 +- 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) -- 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) -- 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 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) +- 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 🌐 @@ -149,7 +167,8 @@ The effect is shown in the following image: 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: ![](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: -- edge: Faster generation speed, better performance, no specific requirements for computer configuration, but the quality may be unstable -- whisper: Slower generation speed, poorer performance, specific requirements for computer configuration, but more reliable quality +- edge: Faster generation speed, better performance, no specific requirements for computer configuration, but the + 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 -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. ## Background Music 🎵 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 🅰 -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 🤔 @@ -192,7 +216,8 @@ RuntimeError: No ffmpeg exe could be found. 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 [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) -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 [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 📢 -- You can submit an [issue](https://github.com/harry0703/MoneyPrinterTurbo/issues) or a [pull request](https://github.com/harry0703/MoneyPrinterTurbo/pulls). -- You can also follow my **TikTok** or **Video Account**: `Wang Xu Harry.AI` - - 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 | -|:-----------------------------------------:|:------------:|:----------------------------------------------------:| -| | | | +- You can submit an [issue](https://github.com/harry0703/MoneyPrinterTurbo/issues) or + a [pull request](https://github.com/harry0703/MoneyPrinterTurbo/pulls). ## 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 📝 diff --git a/README.md b/README.md index 0dcaf10..6e70077 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # MoneyPrinterTurbo 💸 +[English](README-en.md) + 只需提供一个视频 **主题** 或 **关键词** ,就可以全自动生成视频文案、视频素材、视频字幕、视频背景音乐,然后合成一个高清的短视频。 ![](docs/webui.jpg) @@ -13,7 +15,7 @@ - 中文版:https://reccloud.cn - 英文版:https://reccloud.com -![](docs/reccloud.jpg) +![](docs/reccloud.cn.jpg) ## 功能特性 🎯 @@ -29,7 +31,7 @@ - [x] 支持 **字幕生成**,可以调整 `字体`、`位置`、`颜色`、`大小`,同时支持`字幕描边`设置 - [x] 支持 **背景音乐**,随机或者指定音乐文件,可设置`背景音乐音量` - [x] 视频素材来源 **高清**,而且 **无版权** -- [x] 支持 **OpenAI**、**moonshot**、**Azure**、**gpt4free**、**one-api** 等多种模型接入 +- [x] 支持 **OpenAI**、**moonshot**、**Azure**、**gpt4free**、**one-api**、**通义千问** 等多种模型接入 ### 后期计划 📅 @@ -37,6 +39,7 @@ - [ ] 优化语音合成,利用大模型,使其合成的声音,更加自然,情绪更加丰富 - [ ] 增加视频转场效果,使其看起来更加的流畅 - [ ] 优化视频素材的匹配度 +- [ ] OLLAMA 支持 ## 视频演示 📺 diff --git a/app/services/llm.py b/app/services/llm.py index dc70913..ebcf127 100644 --- a/app/services/llm.py +++ b/app/services/llm.py @@ -2,7 +2,6 @@ import logging import re import json from typing import List -import g4f from loguru import logger from openai import OpenAI from openai import AzureOpenAI @@ -17,7 +16,7 @@ def _generate_response(prompt: str) -> str: model_name = config.app.get("g4f_model_name", "") if not model_name: model_name = "gpt-3.5-turbo-16k-0613" - + import g4f content = g4f.ChatCompletion.create( model=model_name, messages=[{"role": "user", "content": prompt}], @@ -43,6 +42,10 @@ def _generate_response(prompt: str) -> str: model_name = config.app.get("azure_model_name") base_url = config.app.get("azure_base_url", "") 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: 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: 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": client = AzureOpenAI( api_key=api_key, diff --git a/config.example.toml b/config.example.toml index b8b99e4..e94d848 100644 --- a/config.example.toml +++ b/config.example.toml @@ -7,7 +7,7 @@ pexels_api_keys = [] # 如果你没有 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 # 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_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" # If empty, the subtitle will not be generated diff --git a/docs/reccloud.jpg b/docs/reccloud.cn.jpg similarity index 100% rename from docs/reccloud.jpg rename to docs/reccloud.cn.jpg diff --git a/docs/reccloud.com.jpg b/docs/reccloud.com.jpg new file mode 100644 index 0000000..043e521 Binary files /dev/null and b/docs/reccloud.com.jpg differ diff --git a/requirements.txt b/requirements.txt index 884c2fd..651f46a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,6 +10,7 @@ streamlit~=1.32.0 loguru~=0.7.2 aiohttp~=3.9.3 urllib3~=2.2.1 -pillow~=10.2.0 +pillow~=9.5.0 pydantic~=2.6.3 -g4f~=0.2.5.4 \ No newline at end of file +g4f~=0.2.5.4 +dashscope~=1.15.0 \ No newline at end of file