一个文生视频MoneyPrinterTurbo项目解析

news/2024/12/23 1:30:37/

最近抖音剪映发布了图文生成视频功能,同时百家号也有这个功能,这个可以看做是一个开源的实现,一起看看它的原理吧~

一句话提示词

大模型生成文案

百家号生成视频效果

MoneyPrinterTurbo生成视频效果

天空为什么是蓝色的?

天空之所以呈现蓝色,是因为大气中的分子和小粒子会散射太阳光中的蓝色光线比其他颜色更多。这种现象称为“瑞利散射”。太阳光是由不同颜色的光线组成的,这些颜色的光线混合在一起形成了白光。在地球的大气中,较短的波长,如蓝色和紫色,比较长的波长,如红色和橙色,更容易被散射。然而,我们的眼睛对蓝色光线的敏感度更高,因此我们看到的天空大部分时间都是蓝色的。此外,当太阳接近地平线时,光线需要穿越更多的大气层,这使得更多的蓝色和绿色光线被散射掉,留下的主要是红色和橙色,这就是为什么日落和日出时天空会呈现出红色或橙色的原因。

天空为什么是蓝色的?

 

天空为什么是蓝的MPT生成

 

一、项目说明

利用AI大模型,一键生成高清短视频:只需提供一个视频 主题关键词 ,就可以全自动生成视频文案、视频素材、视频字幕、视频背景音乐,然后合成一个高清的短视频。

3301d15b0b154e4ea9254659ecb12669.png2a35b6c6824643a9b8192297c7300b70.png

1.功能特性

  • 完整的MVC架构,代码结构清晰,易于维护,支持APIWeb界面

  • 支持视频文案AI自动生成,也可以自定义文案

  • 支持多种高清视频尺寸

    • 竖屏 9:16,1080x1920

    • 横屏 16:9,1920x1080

  • 支持批量视频生成,可以一次生成多个视频,然后选择一个最满意的

  • 支持视频片段时长设置,方便调节素材切换频率

  • 支持中文英文视频文案

  • 支持多种语音合成

  • 支持字幕生成,可以调整字体位置颜色大小,同时支持字幕描边设置

  • 支持背景音乐,随机或者指定音乐文件,可设置背景音乐音量

  • 视频素材来源高清,而且无版权

  • 支持OpenAImoonshotAzuregpt4freeone-api通义千问Google GeminiOllama等多种模型接入

2.后期计划

  • GPT-SoVITS 配音支持

  • 优化语音合成,利用大模型,使其合成的声音,更加自然,情绪更加丰富

  • 增加视频转场效果,使其看起来更加的流畅

  • 增加更多视频素材来源,优化视频素材和文案的匹配度

  • 增加视频长度选项:短、中、长

  • 打包成一键启动包(Windows,macOS),方便使用

  • 增加免费网络代理,让访问OpenAI和素材下载不再受限

  • 可以使用自己的素材

  • 朗读声音和背景音乐,提供实时试听

  • 支持更多的语音合成服务商,比如 OpenAI TTS, Azure TTS

  • 自动上传到YouTube平台

二.安装部署

1.安装

  • 尽量不要使用 中文路径,避免出现一些无法预料的问题

  • 请确保你的 网络 是正常的,VPN需要打开全局流量模式

① 克隆代码

git clone https://github.com/harry0703/MoneyPrinterTurbo.git

② 修改配置文件

  • config.example.toml 文件复制一份,命名为 config.toml

  • 按照 config.toml 文件中的说明,配置好 pexels_api_keysllm_provider,并根据 llm_provider 对应的服务商,配置相关的 API Key

③ 配置大模型(LLM)

  • 如果要使用 GPT-4.0GPT-3.5,需要有 OpenAIAPI Key,如果没有,可以将 llm_provider 设置为 g4f ( 一个免费使用GPT的开源库 https://github.com/xtekky/gpt4free ,但是该免费的服务,稳定性较差,有时候可以用,有时候用不了)

  • 或者可以使用到 月之暗面 申请。注册就送 15元体验金,可以对话1500次左右。然后设置 llm_provider="moonshot"moonshot_api_key

  • 也可以使用 通义千问,具体请看配置文件里面的注释说明

2.部署

① 创建虚拟环境

建议使用conda创建 python 虚拟环境

git clone https://github.com/harry0703/MoneyPrinterTurbo.gitcd MoneyPrinterTurboconda create -n MoneyPrinterTurbo python=3.10conda activate MoneyPrinterTurbopip install -r requirements.txt

② 安装好 ImageMagick

Windows:

  • 下载https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-29-Q16-x64-static.exe

  • 安装下载好的 ImageMagick,注意不要修改安装路径

  • 修改配置文件 config.toml中的imagemagick_path为你的实际安装路径(如果安装的时候没有修改路径,直接取消注释即可)

MacOS:

brew install imagemagick

Ubuntu:

sudo apt-get install imagemagick

CentOS:

sudo yum install ImageMagick

③ 启动Web界面

注意需要到 MoneyPrinterTurbo 项目根目录下执行以下命令

Windows:

conda activate MoneyPrinterTurbowebui.bat

MacOS or Linux:

conda activate MoneyPrinterTurbosh webui.sh

启动后,会自动打开浏览器

④ 启动API服务

python main.py

启动后,可以查看API文档http://127.0.0.1:8080/docs或者http://127.0.0.1:8080/redoc直接在线调试接口,快速体验

三.源码剖析

1.开发框架

  • UI:Streamlit • A faster way to build and share data apps

  • OpenAPI:FastAPI

2.参数解析

{"video_subject": "string",                      ## 视频主题,必选"video_script": "",                             ## 视频脚本,可以为空,为空则LLM生成"video_terms": "string",                        ## 视频搜索词列表,英文,可以为空,为空则LLM生成"video_aspect": "9:16",                         ## 视频宽高比,支持:"16:9""9:16""1:1""video_concat_mode": "random",                  ## 视频拼接方式,支持:"random""sequential""video_clip_duration": 5,                       ## 视频剪辑持续时长,默认5,小于此时长的视频不会被下载"video_count": 1,                               ## 视频生成个数,默认1"video_language": "",                           ## 视频语言"voice_name": "",                               ## 配音人名称"voice_volume": 1,                              ## 配音音量,默认1"bgm_type": "random",                           ## 背景音乐选择类型,默认random"bgm_file": "",                                 ## 背景音乐文件"bgm_volume": 0.2,                              ## 背景音乐音量大小,默认0.2"subtitle_enabled": true,                       ## 生成视频是否包含字幕,默认true"subtitle_position": "bottom",                  ## 字幕位置,默认bottom"font_name": "STHeitiMedium.ttc",               ## 字幕字体,默认STHeitiMedium.ttc"text_fore_color": "#FFFFFF",                   ## 字幕字体前景色,默认#FFFFFF"text_background_color": "transparent",         ## 字幕字体背景色,默认transparent"font_size": 60,                                ## 字幕字体大小,默认60"stroke_color": "#000000",                      ## 字幕描边颜色,默认#000000"stroke_width": 1.5,                            ## 字幕描边宽度,默认1.5"n_threads": 2,                                 ## 处理线程数,默认2"paragraph_number": 1                           ## 生成视频段落数量,默认1
}

3.处理流程

70a4972c971349878f61eb9de17f5e4d.png

3.1.获取配音人信息

配音人格式:语言 - 姓名 - 性别,返回:去除性别的其它部分

# zh-CN-XiaoyiNeural-Female
# zh-CN-YunxiNeural-Male

3.2.视频脚本&视频搜索词生成

视频脚本&视频搜索词生成基于LLM,可以修改 config.toml 配置文件中的 llm_provider 进行切换,目前支持的LLM有:

    #   openai#   moonshot (月之暗面)#   oneapi#   g4f#   azure#   qwen (通义千问)#   gemini

(1).如果有视频脚本参数为空,则启用LLM生成,生成所需提示词详情如下:

# Role: Video Script Generator## Goals:
Generate a script for a video, depending on the subject of the video.## Constrains:
1. the script is to be returned as a string with the specified number of paragraphs.
2. do not under any circumstance reference this prompt in your response.
3. get straight to the point, don't start with unnecessary things like, "welcome to this video".
4. you must not include any type of markdown or formatting in the script, never use a title. 
5. only return the raw content of the script. 
6. do not include "voiceover", "narrator" or similar indicators of what should be spoken at the beginning of each paragraph or line. 
7. you must not mention the prompt, or anything about the script itself. also, never talk about the amount of paragraphs or lines. just write the script.
8. respond in the same language as the video subject.# Initialization:
- video subject: {视频主题}
- number of paragraphs: {生成的视频段落}
- language: {视频语言}

(2).如果有视频搜索词参数为空,则启用LLM生成,生成所需提示词详情如下:

# Role: Video Search Terms Generator## Goals:
Generate {amount} search terms for stock videos, depending on the subject of a video.## Constrains:
1. the search terms are to be returned as a json-array of strings.
2. each search term should consist of 1-3 words, always add the main subject of the video.
3. you must only return the json-array of strings. you must not return anything else. you must not return the script.
4. the search terms must be related to the subject of the video.
5. reply with english search terms only.## Output Example:
["search term 1", "search term 2", "search term 3","search term 4","search term 5"]## Context:
### Video Subject
{视频主题}### Video Script
{视频脚本}Please note that you must use English for generating video search terms; Chinese is not accepted.

3.3.音频合成

基于edge_tts库进行语音合成(失败尝试3次)

  • 代码库:https://github.com/rany2/edge-tts

  • 所有支持的声音列表,可以查看:附录-声音列表

  • 使用方法:口播神器,基于Edge,微软TTS(text-to-speech)文字转语音免费开源库edge-tts实践(Python3.10)

3.4.字幕生成

当前支持2种字幕生成方式:

  • edge: 生成速度更快,性能更好,对电脑配置没有要求,但是质量可能不稳定

  • whisper: 生成速度较慢,性能较差,对电脑配置有一定要求,但是质量更可靠

可以修改 config.toml 配置文件中的 subtitle_provider 进行切换

建议使用 edge 模式,如果生成的字幕质量不好,再切换到 whisper 模式

注意:

  1. whisper 模式下需要到 HuggingFace 下载一个模型文件,大约 3GB 左右,请确保网络通畅

  2. 如果留空,表示不生成字幕。

3.5.视频下载

需要提前在config.toml 文件中配置pexels_api_keys

视频文件搜索基于免费的https://www.pexels.com/zh-cn/提供,详细接口文档见:附录 - Pexels视频搜索接口

  1. 根据视频搜索词+宽高比作为参数进行检索

  2. 检索结果去除小于video_clip_duration的视频链接

  3. 然后根据video_concat_mode进行排序

  4. 最后按照2.3合成音频总时长顺序下载列表中的视频

3.6.视频合并

视频拼接基于moviepy库:

  • 代码库:https://github.com/Zulko/moviepy

  • 使用方法:User Guide — MoviePy 1.0.2 documentation

拼接方法:

  1. 获取音频时长,通过视频个数计算每个视频的时长

  2. 根据宽高比,获取视频分辨率

  3. 不停地添加下载的剪辑,直到达到音频的持续时间(根据情况处理时长、resize宽高比分辨率)

3.7.视频生成

基于如上生成的TTS配音、SRT字幕及静音视频,加之以预置的音乐文件,进行视频生成。

  1. SRT字幕、静音视频与TTS配音CLIP合成,生成temp视频文件

  2. temp视频文件与背景音乐CLIP合成,生成最终视频

用于视频的背景音乐,位于项目的 resource/songs 目录下。

用于视频字幕的渲染,位于项目的 resource/fonts 目录下,你也可以放进去自己的字体。

四.附录

1.声音列表

Name: af-ZA-AdriNeural
Gender: FemaleName: af-ZA-WillemNeural
Gender: MaleName: am-ET-AmehaNeural
Gender: MaleName: am-ET-MekdesNeural
Gender: FemaleName: ar-AE-FatimaNeural
Gender: FemaleName: ar-AE-HamdanNeural
Gender: MaleName: ar-BH-AliNeural
Gender: MaleName: ar-BH-LailaNeural
Gender: FemaleName: ar-DZ-AminaNeural
Gender: FemaleName: ar-DZ-IsmaelNeural
Gender: MaleName: ar-EG-SalmaNeural
Gender: FemaleName: ar-EG-ShakirNeural
Gender: MaleName: ar-IQ-BasselNeural
Gender: MaleName: ar-IQ-RanaNeural
Gender: FemaleName: ar-JO-SanaNeural
Gender: FemaleName: ar-JO-TaimNeural
Gender: MaleName: ar-KW-FahedNeural
Gender: MaleName: ar-KW-NouraNeural
Gender: FemaleName: ar-LB-LaylaNeural
Gender: FemaleName: ar-LB-RamiNeural
Gender: MaleName: ar-LY-ImanNeural
Gender: FemaleName: ar-LY-OmarNeural
Gender: MaleName: ar-MA-JamalNeural
Gender: MaleName: ar-MA-MounaNeural
Gender: FemaleName: ar-OM-AbdullahNeural
Gender: MaleName: ar-OM-AyshaNeural
Gender: FemaleName: ar-QA-AmalNeural
Gender: FemaleName: ar-QA-MoazNeural
Gender: MaleName: ar-SA-HamedNeural
Gender: MaleName: ar-SA-ZariyahNeural
Gender: FemaleName: ar-SY-AmanyNeural
Gender: FemaleName: ar-SY-LaithNeural
Gender: MaleName: ar-TN-HediNeural
Gender: MaleName: ar-TN-ReemNeural
Gender: FemaleName: ar-YE-MaryamNeural
Gender: FemaleName: ar-YE-SalehNeural
Gender: MaleName: az-AZ-BabekNeural
Gender: MaleName: az-AZ-BanuNeural
Gender: FemaleName: bg-BG-BorislavNeural
Gender: MaleName: bg-BG-KalinaNeural
Gender: FemaleName: bn-BD-NabanitaNeural
Gender: FemaleName: bn-BD-PradeepNeural
Gender: MaleName: bn-IN-BashkarNeural
Gender: MaleName: bn-IN-TanishaaNeural
Gender: FemaleName: bs-BA-GoranNeural
Gender: MaleName: bs-BA-VesnaNeural
Gender: FemaleName: ca-ES-EnricNeural
Gender: MaleName: ca-ES-JoanaNeural
Gender: FemaleName: cs-CZ-AntoninNeural
Gender: MaleName: cs-CZ-VlastaNeural
Gender: FemaleName: cy-GB-AledNeural
Gender: MaleName: cy-GB-NiaNeural
Gender: FemaleName: da-DK-ChristelNeural
Gender: FemaleName: da-DK-JeppeNeural
Gender: MaleName: de-AT-IngridNeural
Gender: FemaleName: de-AT-JonasNeural
Gender: MaleName: de-CH-JanNeural
Gender: MaleName: de-CH-LeniNeural
Gender: FemaleName: de-DE-AmalaNeural
Gender: FemaleName: de-DE-ConradNeural
Gender: MaleName: de-DE-FlorianMultilingualNeural
Gender: MaleName: de-DE-KatjaNeural
Gender: FemaleName: de-DE-KillianNeural
Gender: MaleName: de-DE-SeraphinaMultilingualNeural
Gender: FemaleName: el-GR-AthinaNeural
Gender: FemaleName: el-GR-NestorasNeural
Gender: MaleName: en-AU-NatashaNeural
Gender: FemaleName: en-AU-WilliamNeural
Gender: MaleName: en-CA-ClaraNeural
Gender: FemaleName: en-CA-LiamNeural
Gender: MaleName: en-GB-LibbyNeural
Gender: FemaleName: en-GB-MaisieNeural
Gender: FemaleName: en-GB-RyanNeural
Gender: MaleName: en-GB-SoniaNeural
Gender: FemaleName: en-GB-ThomasNeural
Gender: MaleName: en-HK-SamNeural
Gender: MaleName: en-HK-YanNeural
Gender: FemaleName: en-IE-ConnorNeural
Gender: MaleName: en-IE-EmilyNeural
Gender: FemaleName: en-IN-NeerjaExpressiveNeural
Gender: FemaleName: en-IN-NeerjaNeural
Gender: FemaleName: en-IN-PrabhatNeural
Gender: MaleName: en-KE-AsiliaNeural
Gender: FemaleName: en-KE-ChilembaNeural
Gender: MaleName: en-NG-AbeoNeural
Gender: MaleName: en-NG-EzinneNeural
Gender: FemaleName: en-NZ-MitchellNeural
Gender: MaleName: en-NZ-MollyNeural
Gender: FemaleName: en-PH-JamesNeural
Gender: MaleName: en-PH-RosaNeural
Gender: FemaleName: en-SG-LunaNeural
Gender: FemaleName: en-SG-WayneNeural
Gender: MaleName: en-TZ-ElimuNeural
Gender: MaleName: en-TZ-ImaniNeural
Gender: FemaleName: en-US-AnaNeural
Gender: FemaleName: en-US-AndrewNeural
Gender: MaleName: en-US-AriaNeural
Gender: FemaleName: en-US-AvaNeural
Gender: FemaleName: en-US-BrianNeural
Gender: MaleName: en-US-ChristopherNeural
Gender: MaleName: en-US-EmmaNeural
Gender: FemaleName: en-US-EricNeural
Gender: MaleName: en-US-GuyNeural
Gender: MaleName: en-US-JennyNeural
Gender: FemaleName: en-US-MichelleNeural
Gender: FemaleName: en-US-RogerNeural
Gender: MaleName: en-US-SteffanNeural
Gender: MaleName: en-ZA-LeahNeural
Gender: FemaleName: en-ZA-LukeNeural
Gender: MaleName: es-AR-ElenaNeural
Gender: FemaleName: es-AR-TomasNeural
Gender: MaleName: es-BO-MarceloNeural
Gender: MaleName: es-BO-SofiaNeural
Gender: FemaleName: es-CL-CatalinaNeural
Gender: FemaleName: es-CL-LorenzoNeural
Gender: MaleName: es-CO-GonzaloNeural
Gender: MaleName: es-CO-SalomeNeural
Gender: FemaleName: es-CR-JuanNeural
Gender: MaleName: es-CR-MariaNeural
Gender: FemaleName: es-CU-BelkysNeural
Gender: FemaleName: es-CU-ManuelNeural
Gender: MaleName: es-DO-EmilioNeural
Gender: MaleName: es-DO-RamonaNeural
Gender: FemaleName: es-EC-AndreaNeural
Gender: FemaleName: es-EC-LuisNeural
Gender: MaleName: es-ES-AlvaroNeural
Gender: MaleName: es-ES-ElviraNeural
Gender: FemaleName: es-ES-XimenaNeural
Gender: FemaleName: es-GQ-JavierNeural
Gender: MaleName: es-GQ-TeresaNeural
Gender: FemaleName: es-GT-AndresNeural
Gender: MaleName: es-GT-MartaNeural
Gender: FemaleName: es-HN-CarlosNeural
Gender: MaleName: es-HN-KarlaNeural
Gender: FemaleName: es-MX-DaliaNeural
Gender: FemaleName: es-MX-JorgeNeural
Gender: MaleName: es-NI-FedericoNeural
Gender: MaleName: es-NI-YolandaNeural
Gender: FemaleName: es-PA-MargaritaNeural
Gender: FemaleName: es-PA-RobertoNeural
Gender: MaleName: es-PE-AlexNeural
Gender: MaleName: es-PE-CamilaNeural
Gender: FemaleName: es-PR-KarinaNeural
Gender: FemaleName: es-PR-VictorNeural
Gender: MaleName: es-PY-MarioNeural
Gender: MaleName: es-PY-TaniaNeural
Gender: FemaleName: es-SV-LorenaNeural
Gender: FemaleName: es-SV-RodrigoNeural
Gender: MaleName: es-US-AlonsoNeural
Gender: MaleName: es-US-PalomaNeural
Gender: FemaleName: es-UY-MateoNeural
Gender: MaleName: es-UY-ValentinaNeural
Gender: FemaleName: es-VE-PaolaNeural
Gender: FemaleName: es-VE-SebastianNeural
Gender: MaleName: et-EE-AnuNeural
Gender: FemaleName: et-EE-KertNeural
Gender: MaleName: fa-IR-DilaraNeural
Gender: FemaleName: fa-IR-FaridNeural
Gender: MaleName: fi-FI-HarriNeural
Gender: MaleName: fi-FI-NooraNeural
Gender: FemaleName: fil-PH-AngeloNeural
Gender: MaleName: fil-PH-BlessicaNeural
Gender: FemaleName: fr-BE-CharlineNeural
Gender: FemaleName: fr-BE-GerardNeural
Gender: MaleName: fr-CA-AntoineNeural
Gender: MaleName: fr-CA-JeanNeural
Gender: MaleName: fr-CA-SylvieNeural
Gender: FemaleName: fr-CA-ThierryNeural
Gender: MaleName: fr-CH-ArianeNeural
Gender: FemaleName: fr-CH-FabriceNeural
Gender: MaleName: fr-FR-DeniseNeural
Gender: FemaleName: fr-FR-EloiseNeural
Gender: FemaleName: fr-FR-HenriNeural
Gender: MaleName: fr-FR-RemyMultilingualNeural
Gender: MaleName: fr-FR-VivienneMultilingualNeural
Gender: FemaleName: ga-IE-ColmNeural
Gender: MaleName: ga-IE-OrlaNeural
Gender: FemaleName: gl-ES-RoiNeural
Gender: MaleName: gl-ES-SabelaNeural
Gender: FemaleName: gu-IN-DhwaniNeural
Gender: FemaleName: gu-IN-NiranjanNeural
Gender: MaleName: he-IL-AvriNeural
Gender: MaleName: he-IL-HilaNeural
Gender: FemaleName: hi-IN-MadhurNeural
Gender: MaleName: hi-IN-SwaraNeural
Gender: FemaleName: hr-HR-GabrijelaNeural
Gender: FemaleName: hr-HR-SreckoNeural
Gender: MaleName: hu-HU-NoemiNeural
Gender: FemaleName: hu-HU-TamasNeural
Gender: MaleName: id-ID-ArdiNeural
Gender: MaleName: id-ID-GadisNeural
Gender: FemaleName: is-IS-GudrunNeural
Gender: FemaleName: is-IS-GunnarNeural
Gender: MaleName: it-IT-DiegoNeural
Gender: MaleName: it-IT-ElsaNeural
Gender: FemaleName: it-IT-GiuseppeNeural
Gender: MaleName: it-IT-IsabellaNeural
Gender: FemaleName: ja-JP-KeitaNeural
Gender: MaleName: ja-JP-NanamiNeural
Gender: FemaleName: jv-ID-DimasNeural
Gender: MaleName: jv-ID-SitiNeural
Gender: FemaleName: ka-GE-EkaNeural
Gender: FemaleName: ka-GE-GiorgiNeural
Gender: MaleName: kk-KZ-AigulNeural
Gender: FemaleName: kk-KZ-DauletNeural
Gender: MaleName: km-KH-PisethNeural
Gender: MaleName: km-KH-SreymomNeural
Gender: FemaleName: kn-IN-GaganNeural
Gender: MaleName: kn-IN-SapnaNeural
Gender: FemaleName: ko-KR-HyunsuNeural
Gender: MaleName: ko-KR-InJoonNeural
Gender: MaleName: ko-KR-SunHiNeural
Gender: FemaleName: lo-LA-ChanthavongNeural
Gender: MaleName: lo-LA-KeomanyNeural
Gender: FemaleName: lt-LT-LeonasNeural
Gender: MaleName: lt-LT-OnaNeural
Gender: FemaleName: lv-LV-EveritaNeural
Gender: FemaleName: lv-LV-NilsNeural
Gender: MaleName: mk-MK-AleksandarNeural
Gender: MaleName: mk-MK-MarijaNeural
Gender: FemaleName: ml-IN-MidhunNeural
Gender: MaleName: ml-IN-SobhanaNeural
Gender: FemaleName: mn-MN-BataaNeural
Gender: MaleName: mn-MN-YesuiNeural
Gender: FemaleName: mr-IN-AarohiNeural
Gender: FemaleName: mr-IN-ManoharNeural
Gender: MaleName: ms-MY-OsmanNeural
Gender: MaleName: ms-MY-YasminNeural
Gender: FemaleName: mt-MT-GraceNeural
Gender: FemaleName: mt-MT-JosephNeural
Gender: MaleName: my-MM-NilarNeural
Gender: FemaleName: my-MM-ThihaNeural
Gender: MaleName: nb-NO-FinnNeural
Gender: MaleName: nb-NO-PernilleNeural
Gender: FemaleName: ne-NP-HemkalaNeural
Gender: FemaleName: ne-NP-SagarNeural
Gender: MaleName: nl-BE-ArnaudNeural
Gender: MaleName: nl-BE-DenaNeural
Gender: FemaleName: nl-NL-ColetteNeural
Gender: FemaleName: nl-NL-FennaNeural
Gender: FemaleName: nl-NL-MaartenNeural
Gender: MaleName: pl-PL-MarekNeural
Gender: MaleName: pl-PL-ZofiaNeural
Gender: FemaleName: ps-AF-GulNawazNeural
Gender: MaleName: ps-AF-LatifaNeural
Gender: FemaleName: pt-BR-AntonioNeural
Gender: MaleName: pt-BR-FranciscaNeural
Gender: FemaleName: pt-BR-ThalitaNeural
Gender: FemaleName: pt-PT-DuarteNeural
Gender: MaleName: pt-PT-RaquelNeural
Gender: FemaleName: ro-RO-AlinaNeural
Gender: FemaleName: ro-RO-EmilNeural
Gender: MaleName: ru-RU-DmitryNeural
Gender: MaleName: ru-RU-SvetlanaNeural
Gender: FemaleName: si-LK-SameeraNeural
Gender: MaleName: si-LK-ThiliniNeural
Gender: FemaleName: sk-SK-LukasNeural
Gender: MaleName: sk-SK-ViktoriaNeural
Gender: FemaleName: sl-SI-PetraNeural
Gender: FemaleName: sl-SI-RokNeural
Gender: MaleName: so-SO-MuuseNeural
Gender: MaleName: so-SO-UbaxNeural
Gender: FemaleName: sq-AL-AnilaNeural
Gender: FemaleName: sq-AL-IlirNeural
Gender: MaleName: sr-RS-NicholasNeural
Gender: MaleName: sr-RS-SophieNeural
Gender: FemaleName: su-ID-JajangNeural
Gender: MaleName: su-ID-TutiNeural
Gender: FemaleName: sv-SE-MattiasNeural
Gender: MaleName: sv-SE-SofieNeural
Gender: FemaleName: sw-KE-RafikiNeural
Gender: MaleName: sw-KE-ZuriNeural
Gender: FemaleName: sw-TZ-DaudiNeural
Gender: MaleName: sw-TZ-RehemaNeural
Gender: FemaleName: ta-IN-PallaviNeural
Gender: FemaleName: ta-IN-ValluvarNeural
Gender: MaleName: ta-LK-KumarNeural
Gender: MaleName: ta-LK-SaranyaNeural
Gender: FemaleName: ta-MY-KaniNeural
Gender: FemaleName: ta-MY-SuryaNeural
Gender: MaleName: ta-SG-AnbuNeural
Gender: MaleName: ta-SG-VenbaNeural
Gender: FemaleName: te-IN-MohanNeural
Gender: MaleName: te-IN-ShrutiNeural
Gender: FemaleName: th-TH-NiwatNeural
Gender: MaleName: th-TH-PremwadeeNeural
Gender: FemaleName: tr-TR-AhmetNeural
Gender: MaleName: tr-TR-EmelNeural
Gender: FemaleName: uk-UA-OstapNeural
Gender: MaleName: uk-UA-PolinaNeural
Gender: FemaleName: ur-IN-GulNeural
Gender: FemaleName: ur-IN-SalmanNeural
Gender: MaleName: ur-PK-AsadNeural
Gender: MaleName: ur-PK-UzmaNeural
Gender: FemaleName: uz-UZ-MadinaNeural
Gender: FemaleName: uz-UZ-SardorNeural
Gender: MaleName: vi-VN-HoaiMyNeural
Gender: FemaleName: vi-VN-NamMinhNeural
Gender: MaleName: zh-CN-XiaoxiaoNeural
Gender: FemaleName: zh-CN-XiaoyiNeural
Gender: FemaleName: zh-CN-YunjianNeural
Gender: MaleName: zh-CN-YunxiNeural
Gender: MaleName: zh-CN-YunxiaNeural
Gender: MaleName: zh-CN-YunyangNeural
Gender: MaleName: zh-CN-liaoning-XiaobeiNeural
Gender: FemaleName: zh-CN-shaanxi-XiaoniNeural
Gender: FemaleName: zh-HK-HiuGaaiNeural
Gender: FemaleName: zh-HK-HiuMaanNeural
Gender: FemaleName: zh-HK-WanLungNeural
Gender: MaleName: zh-TW-HsiaoChenNeural
Gender: FemaleName: zh-TW-HsiaoYuNeural
Gender: FemaleName: zh-TW-YunJheNeural
Gender: MaleName: zu-ZA-ThandoNeural
Gender: FemaleName: zu-ZA-ThembaNeural
Gender: Male

2.Pexels视频搜索接口

接口文档见:https://www.pexels.com/zh-cn/api/documentation/#videos-search,详情如下:

GET https://api.pexels.com/videos/search

此端点使你可以在Pexels中搜索任意主题。例如,你的查询范围可以很宽泛,如NatureTigersPeople;也可以很具体,如Group of people working

参数

  • querystring | requiredThe search query.Ocean,Tigers,Pears, etc.

  • orientationstring | optionalDesired video orientation. The current supported orientations are:landscape,portraitorsquare.

  • sizestring | optionalMinimum video size. The current supported sizes are:large(4K),medium(Full HD) orsmall(HD).

  • localestring | optionalThe locale of the search you are performing. The current supported locales are:'en-US''pt-BR''es-ES''ca-ES''de-DE''it-IT''fr-FR''sv-SE''id-ID''pl-PL''ja-JP''zh-TW''zh-CN''ko-KR''th-TH''nl-NL''hu-HU''vi-VN''cs-CZ''da-DK''fi-FI''uk-UA''el-GR''ro-RO''nb-NO''sk-SK''tr-TR''ru-RU'.

  • pageinteger | optionalThe page number you are requesting.Default: 1

  • per_pageinteger | optionalThe number of results you are requesting per page.Default: 15Max: 80

响应

  • videosarray ofVideoAn array ofVideoobjects.

  • urlstringThe Pexels URL for the current search query.

  • pageintegerThe current page number.

  • per_pageintegerThe number of results returned with each page.

  • total_resultsintegerThe total number of results for the request.

  • prev_pagestring | optionalURL for the previous page of results, if applicable.

  • next_pagestring | optionalURL for the next page of results, if applicable.

请求范例

curl -H "Authorization: <secret key>" \"https://api.pexels.com/videos/search?query=nature&per_page=1"

响应范例

{"page": 1,"per_page": 1,"total_results": 20475,"url": "https://www.pexels.com/videos/","videos": [{"id": 1448735,"width": 4096,"height": 2160,"url": "https://www.pexels.com/video/video-of-forest-1448735/","image": "https://images.pexels.com/videos/1448735/free-video-1448735.jpg?fit=crop&w=1200&h=630&auto=compress&cs=tinysrgb","duration": 32,"user": {"id": 574687,"name": "Ruvim Miksanskiy","url": "https://www.pexels.com/@digitech"},"video_files": [{"id": 58649,"quality": "sd","file_type": "video/mp4","width": 640,"height": 338,"link": "https://player.vimeo.com/external/291648067.sd.mp4?s=7f9ee1f8ec1e5376027e4a6d1d05d5738b2fbb29&profile_id=164&oauth2_token_id=57447761"},{"id": 58650,"quality": "hd","file_type": "video/mp4","width": 2048,"height": 1080,"link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=175&oauth2_token_id=57447761"},{"id": 58651,"quality": "hd","file_type": "video/mp4","width": 4096,"height": 2160,"link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=172&oauth2_token_id=57447761"},{"id": 58652,"quality": "hd","file_type": "video/mp4","width": 1366,"height": 720,"link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=174&oauth2_token_id=57447761"},{"id": 58653,"quality": "hd","file_type": "video/mp4","width": 2732,"height": 1440,"link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=170&oauth2_token_id=57447761"},{"id": 58654,"quality": "sd","file_type": "video/mp4","width": 960,"height": 506,"link": "https://player.vimeo.com/external/291648067.sd.mp4?s=7f9ee1f8ec1e5376027e4a6d1d05d5738b2fbb29&profile_id=165&oauth2_token_id=57447761"},{"id": 58655,"quality": "hls","file_type": "video/mp4","width": null,"height": null,"link": "https://player.vimeo.com/external/291648067.m3u8?s=1210fac9d80f9b74b4a334c4fca327cde08886b2&oauth2_token_id=57447761"}],"video_pictures": [{"id": 133236,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-0.jpg","nr": 0},{"id": 133237,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-1.jpg","nr": 1},{"id": 133238,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-2.jpg","nr": 2},{"id": 133239,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-3.jpg","nr": 3},{"id": 133240,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-4.jpg","nr": 4},{"id": 133241,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-5.jpg","nr": 5},{"id": 133242,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-6.jpg","nr": 6},{"id": 133243,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-7.jpg","nr": 7},{"id": 133244,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-8.jpg","nr": 8},{"id": 133245,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-9.jpg","nr": 9},{"id": 133246,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-10.jpg","nr": 10},{"id": 133247,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-11.jpg","nr": 11},{"id": 133248,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-12.jpg","nr": 12},{"id": 133249,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-13.jpg","nr": 13},{"id": 133250,"picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-14.jpg","nr": 14}]}

3.接口调用脚本

3.1.获取配乐

curl --location 'http://127.0.0.1:8080/api/v1/musics'

3.2.视频生成

curl --location 'http://127.0.0.1:8080/api/v1/videos' \
--header 'Content-Type: application/json' \
--data '{"video_subject": "千岛湖的落日","video_script": "","video_terms": "","video_aspect": "16:9","video_concat_mode": "random","video_clip_duration": 5,"video_count": 1,"video_language": "","voice_name": "zh-CN-XiaoyiNeural","voice_volume": 1,"bgm_type": "random","bgm_file": "","bgm_volume": 0.2,"subtitle_enabled": true,"subtitle_position": "bottom","font_name": "STHeitiMedium.ttc","text_fore_color": "#FFFFFF","text_background_color": "transparent","font_size": 60,"stroke_color": "#000000","stroke_width": 1.5,"n_threads": 2,"paragraph_number": 1
}'

3.3.任务状态查询

curl --location 'http://127.0.0.1:8080/api/v1/tasks/97087c51-d01a-43fb-96b9-9eefadb8f842'

3.4.视频脚本生成

curl --location 'http://127.0.0.1:8080/api/v1/scripts' \
--header 'Content-Type: application/json' \
--data '{"video_subject": "春天的花海","video_language": "","paragraph_number": 5
}'

3.5.视频检索关键词生成

curl --location 'http://127.0.0.1:8080/api/v1/terms' \
--header 'Content-Type: application/json' \
--data '{"video_subject": "春天的花海","video_script": "春天是一年中最美丽的季节之一。当冬天的寒冷逐渐结束,春天花海的美丽将会迎接我们。在春天的花海中,我们可以看到各种各样的花朵。粉色的樱花树下,人们纷纷拿出相机,纪录下这美好的瞬间。紫色的薰衣草田中,花朵的香气弥漫在空气中,让人们感到宁静和放松。还有,五颜六色的郁金香花海,吸引着许多游客前来欣赏。除了花朵的美丽,春天的花海还有许多活动可以参与。人们可以穿上轻便的衣服,漫步在花海中,感受春天的温暖。还可以举办野餐,在花海中享受美食和阳光。还可以举办婚礼或其他仪式,选择在花海中迎接新的开始。无论是花朵的美丽还是花海中的活动,春天的花海都是一个令人愉悦和放松的地方。在这里,我们可以忘记一切烦恼,沉浸在自然的美景中。春天的花海,让我们感受到生活的美好和希望。忘记繁忙的生活,放松身心,与家人和朋友一起享受这美丽的季节吧。希望你们喜欢这个视频,也希望在未来的春天里能够亲自到花海中感受这美好的景色。谢谢观看!","amount": 3
}'

3.6.上传背景音乐

curl --location 'http://127.0.0.1:8080/api/v1/musics' \
--form 'file=@"/Users/abc/Music/4.mp3"'

 

 


http://www.ppmy.cn/news/1424570.html

相关文章

CommunityToolkit.Mvvm笔记---AsyncRelayCommand

AsyncRelayCommand 是 CommunityToolkit.Mvvm 中的一个功能&#xff0c;专门设计用来处理异步操作。它是 RelayCommand 的一个变体&#xff0c;提供了对异步任务的支持&#xff0c;允许开发者在 MVVM&#xff08;Model-View-ViewModel&#xff09;模式中方便地实现异步命令。使…

华为OD-C卷-密码解密[100分]Python3+C语言-90%

题目描述 给定一段“密文”字符串 s,其中字符都是经过“密码本”映射的,现需要将“密文”解密并输出。 映射的规则(a ~ i)分别用(1 ~ 9)表示;(j ~ z)分别用("10*" ~ "26*")表示。 约束:映射始终唯一。 输入描述 “密文”字符串 输出描述 …

Hive进阶(4)----MapReduce的计算过程(赋图助君理解)

MapReduce的计算过程 MapReduce是一种编程模型和处理大规模数据集的方法。它通常用于分布式计算环境中&#xff0c;能够将数据处理任务分解成独立的部分&#xff0c;分配给多台计算机进行并行处理。这个模型由Google提出&#xff0c;并在开源领域中得到了广泛的应用和实现。Map…

uniapp 当前系统没有安装苹果根证书,是否打开证书目录(打开后依次安装证书

当你遇到这类问题时&#xff0c;说明你也极其的困惑&#xff01;这就是为啥大抵国内这些货色搞的东西总是不尽人意&#xff01;连开发者生态都搞不好&#xff0c;就急着吹嘘。 这是官方给的技术说明方案&#xff1a; 恭喜你&#xff0c;当你按照这个搞之后&#xff0c;你的问题…

Kolla-ansible部署OpenStack集群

0. OpenStack 部署 系统要求 单机部署最低配置&#xff1a; 2张网卡8G内存40G硬盘空间 主机系统&#xff1a; CentOS Stream 9Debian Bullseye (11)openEuler 22.03 LTSRocky Linux 9- Ubuntu Jammy (22.04) 官方不再支持CentOS 7作为主机系统&#xff0c;我这里使用的是R…

Linux_CentOS7/8系统 - 关闭图形界面新增用户机制手册

Linux_CentOS7/8系统 - 关闭图形界面新增用户机制手册 在系统完成图形界面安装后重新启动后第一次登入&#xff0c;在图形界面会有新增用户页面&#xff0c;那如果取消关闭可以按以下操作&#xff1a; CTRLALTF2 root账号登录 yum remove gnome-initial-setup -y init 3 init …

正则表达式中?=、?!、?<=、?<!、?:的理解与应用举例

正则表达式就是用事先定义好的一些特定字符、及这些特定字符的组合,组成一个规则字符串,这个规则字符串表达对字符串的一种过滤逻辑,这篇文章主要给大家介绍了关于正则表达式中?、?!、?&#xff1c;、?&#xff1c;!、?:的理解与应用举例的相关资料,需要的朋友可以参考下 …

深度 | 践行绿色健康可持续发展,这家企业提供了价值范本

文 | 螳螂观察 作者 | 余一 近段时间以来&#xff0c;小米SU7热度一直不减&#xff0c;在展露小米强大品牌号召力的同时&#xff0c;也侧面体现出了当前消费者对于新能源汽车的喜爱。 而消费者选择新能源汽车时&#xff0c;环保因素也起到了至关重要的作用。像前几日&#x…