一个文生视频MoneyPrinterTurbo项目解析

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

一句话提示词

大模型生成文案

百家号生成视频效果

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.git

cd MoneyPrinterTurbo

conda create -n MoneyPrinterTurbo python=3.10

conda activate MoneyPrinterTurbo

pip 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 MoneyPrinterTurbo

webui.bat

MacOS or Linux:

conda activate MoneyPrinterTurbo

sh 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: Female

Name: af-ZA-WillemNeural
Gender: Male

Name: am-ET-AmehaNeural
Gender: Male

Name: am-ET-MekdesNeural
Gender: Female

Name: ar-AE-FatimaNeural
Gender: Female

Name: ar-AE-HamdanNeural
Gender: Male

Name: ar-BH-AliNeural
Gender: Male

Name: ar-BH-LailaNeural
Gender: Female

Name: ar-DZ-AminaNeural
Gender: Female

Name: ar-DZ-IsmaelNeural
Gender: Male

Name: ar-EG-SalmaNeural
Gender: Female

Name: ar-EG-ShakirNeural
Gender: Male

Name: ar-IQ-BasselNeural
Gender: Male

Name: ar-IQ-RanaNeural
Gender: Female

Name: ar-JO-SanaNeural
Gender: Female

Name: ar-JO-TaimNeural
Gender: Male

Name: ar-KW-FahedNeural
Gender: Male

Name: ar-KW-NouraNeural
Gender: Female

Name: ar-LB-LaylaNeural
Gender: Female

Name: ar-LB-RamiNeural
Gender: Male

Name: ar-LY-ImanNeural
Gender: Female

Name: ar-LY-OmarNeural
Gender: Male

Name: ar-MA-JamalNeural
Gender: Male

Name: ar-MA-MounaNeural
Gender: Female

Name: ar-OM-AbdullahNeural
Gender: Male

Name: ar-OM-AyshaNeural
Gender: Female

Name: ar-QA-AmalNeural
Gender: Female

Name: ar-QA-MoazNeural
Gender: Male

Name: ar-SA-HamedNeural
Gender: Male

Name: ar-SA-ZariyahNeural
Gender: Female

Name: ar-SY-AmanyNeural
Gender: Female

Name: ar-SY-LaithNeural
Gender: Male

Name: ar-TN-HediNeural
Gender: Male

Name: ar-TN-ReemNeural
Gender: Female

Name: ar-YE-MaryamNeural
Gender: Female

Name: ar-YE-SalehNeural
Gender: Male

Name: az-AZ-BabekNeural
Gender: Male

Name: az-AZ-BanuNeural
Gender: Female

Name: bg-BG-BorislavNeural
Gender: Male

Name: bg-BG-KalinaNeural
Gender: Female

Name: bn-BD-NabanitaNeural
Gender: Female

Name: bn-BD-PradeepNeural
Gender: Male

Name: bn-IN-BashkarNeural
Gender: Male

Name: bn-IN-TanishaaNeural
Gender: Female

Name: bs-BA-GoranNeural
Gender: Male

Name: bs-BA-VesnaNeural
Gender: Female

Name: ca-ES-EnricNeural
Gender: Male

Name: ca-ES-JoanaNeural
Gender: Female

Name: cs-CZ-AntoninNeural
Gender: Male

Name: cs-CZ-VlastaNeural
Gender: Female

Name: cy-GB-AledNeural
Gender: Male

Name: cy-GB-NiaNeural
Gender: Female

Name: da-DK-ChristelNeural
Gender: Female

Name: da-DK-JeppeNeural
Gender: Male

Name: de-AT-IngridNeural
Gender: Female

Name: de-AT-JonasNeural
Gender: Male

Name: de-CH-JanNeural
Gender: Male

Name: de-CH-LeniNeural
Gender: Female

Name: de-DE-AmalaNeural
Gender: Female

Name: de-DE-ConradNeural
Gender: Male

Name: de-DE-FlorianMultilingualNeural
Gender: Male

Name: de-DE-KatjaNeural
Gender: Female

Name: de-DE-KillianNeural
Gender: Male

Name: de-DE-SeraphinaMultilingualNeural
Gender: Female

Name: el-GR-AthinaNeural
Gender: Female

Name: el-GR-NestorasNeural
Gender: Male

Name: en-AU-NatashaNeural
Gender: Female

Name: en-AU-WilliamNeural
Gender: Male

Name: en-CA-ClaraNeural
Gender: Female

Name: en-CA-LiamNeural
Gender: Male

Name: en-GB-LibbyNeural
Gender: Female

Name: en-GB-MaisieNeural
Gender: Female

Name: en-GB-RyanNeural
Gender: Male

Name: en-GB-SoniaNeural
Gender: Female

Name: en-GB-ThomasNeural
Gender: Male

Name: en-HK-SamNeural
Gender: Male

Name: en-HK-YanNeural
Gender: Female

Name: en-IE-ConnorNeural
Gender: Male

Name: en-IE-EmilyNeural
Gender: Female

Name: en-IN-NeerjaExpressiveNeural
Gender: Female

Name: en-IN-NeerjaNeural
Gender: Female

Name: en-IN-PrabhatNeural
Gender: Male

Name: en-KE-AsiliaNeural
Gender: Female

Name: en-KE-ChilembaNeural
Gender: Male

Name: en-NG-AbeoNeural
Gender: Male

Name: en-NG-EzinneNeural
Gender: Female

Name: en-NZ-MitchellNeural
Gender: Male

Name: en-NZ-MollyNeural
Gender: Female

Name: en-PH-JamesNeural
Gender: Male

Name: en-PH-RosaNeural
Gender: Female

Name: en-SG-LunaNeural
Gender: Female

Name: en-SG-WayneNeural
Gender: Male

Name: en-TZ-ElimuNeural
Gender: Male

Name: en-TZ-ImaniNeural
Gender: Female

Name: en-US-AnaNeural
Gender: Female

Name: en-US-AndrewNeural
Gender: Male

Name: en-US-AriaNeural
Gender: Female

Name: en-US-AvaNeural
Gender: Female

Name: en-US-BrianNeural
Gender: Male

Name: en-US-ChristopherNeural
Gender: Male

Name: en-US-EmmaNeural
Gender: Female

Name: en-US-EricNeural
Gender: Male

Name: en-US-GuyNeural
Gender: Male

Name: en-US-JennyNeural
Gender: Female

Name: en-US-MichelleNeural
Gender: Female

Name: en-US-RogerNeural
Gender: Male

Name: en-US-SteffanNeural
Gender: Male

Name: en-ZA-LeahNeural
Gender: Female

Name: en-ZA-LukeNeural
Gender: Male

Name: es-AR-ElenaNeural
Gender: Female

Name: es-AR-TomasNeural
Gender: Male

Name: es-BO-MarceloNeural
Gender: Male

Name: es-BO-SofiaNeural
Gender: Female

Name: es-CL-CatalinaNeural
Gender: Female

Name: es-CL-LorenzoNeural
Gender: Male

Name: es-CO-GonzaloNeural
Gender: Male

Name: es-CO-SalomeNeural
Gender: Female

Name: es-CR-JuanNeural
Gender: Male

Name: es-CR-MariaNeural
Gender: Female

Name: es-CU-BelkysNeural
Gender: Female

Name: es-CU-ManuelNeural
Gender: Male

Name: es-DO-EmilioNeural
Gender: Male

Name: es-DO-RamonaNeural
Gender: Female

Name: es-EC-AndreaNeural
Gender: Female

Name: es-EC-LuisNeural
Gender: Male

Name: es-ES-AlvaroNeural
Gender: Male

Name: es-ES-ElviraNeural
Gender: Female

Name: es-ES-XimenaNeural
Gender: Female

Name: es-GQ-JavierNeural
Gender: Male

Name: es-GQ-TeresaNeural
Gender: Female

Name: es-GT-AndresNeural
Gender: Male

Name: es-GT-MartaNeural
Gender: Female

Name: es-HN-CarlosNeural
Gender: Male

Name: es-HN-KarlaNeural
Gender: Female

Name: es-MX-DaliaNeural
Gender: Female

Name: es-MX-JorgeNeural
Gender: Male

Name: es-NI-FedericoNeural
Gender: Male

Name: es-NI-YolandaNeural
Gender: Female

Name: es-PA-MargaritaNeural
Gender: Female

Name: es-PA-RobertoNeural
Gender: Male

Name: es-PE-AlexNeural
Gender: Male

Name: es-PE-CamilaNeural
Gender: Female

Name: es-PR-KarinaNeural
Gender: Female

Name: es-PR-VictorNeural
Gender: Male

Name: es-PY-MarioNeural
Gender: Male

Name: es-PY-TaniaNeural
Gender: Female

Name: es-SV-LorenaNeural
Gender: Female

Name: es-SV-RodrigoNeural
Gender: Male

Name: es-US-AlonsoNeural
Gender: Male

Name: es-US-PalomaNeural
Gender: Female

Name: es-UY-MateoNeural
Gender: Male

Name: es-UY-ValentinaNeural
Gender: Female

Name: es-VE-PaolaNeural
Gender: Female

Name: es-VE-SebastianNeural
Gender: Male

Name: et-EE-AnuNeural
Gender: Female

Name: et-EE-KertNeural
Gender: Male

Name: fa-IR-DilaraNeural
Gender: Female

Name: fa-IR-FaridNeural
Gender: Male

Name: fi-FI-HarriNeural
Gender: Male

Name: fi-FI-NooraNeural
Gender: Female

Name: fil-PH-AngeloNeural
Gender: Male

Name: fil-PH-BlessicaNeural
Gender: Female

Name: fr-BE-CharlineNeural
Gender: Female

Name: fr-BE-GerardNeural
Gender: Male

Name: fr-CA-AntoineNeural
Gender: Male

Name: fr-CA-JeanNeural
Gender: Male

Name: fr-CA-SylvieNeural
Gender: Female

Name: fr-CA-ThierryNeural
Gender: Male

Name: fr-CH-ArianeNeural
Gender: Female

Name: fr-CH-FabriceNeural
Gender: Male

Name: fr-FR-DeniseNeural
Gender: Female

Name: fr-FR-EloiseNeural
Gender: Female

Name: fr-FR-HenriNeural
Gender: Male

Name: fr-FR-RemyMultilingualNeural
Gender: Male

Name: fr-FR-VivienneMultilingualNeural
Gender: Female

Name: ga-IE-ColmNeural
Gender: Male

Name: ga-IE-OrlaNeural
Gender: Female

Name: gl-ES-RoiNeural
Gender: Male

Name: gl-ES-SabelaNeural
Gender: Female

Name: gu-IN-DhwaniNeural
Gender: Female

Name: gu-IN-NiranjanNeural
Gender: Male

Name: he-IL-AvriNeural
Gender: Male

Name: he-IL-HilaNeural
Gender: Female

Name: hi-IN-MadhurNeural
Gender: Male

Name: hi-IN-SwaraNeural
Gender: Female

Name: hr-HR-GabrijelaNeural
Gender: Female

Name: hr-HR-SreckoNeural
Gender: Male

Name: hu-HU-NoemiNeural
Gender: Female

Name: hu-HU-TamasNeural
Gender: Male

Name: id-ID-ArdiNeural
Gender: Male

Name: id-ID-GadisNeural
Gender: Female

Name: is-IS-GudrunNeural
Gender: Female

Name: is-IS-GunnarNeural
Gender: Male

Name: it-IT-DiegoNeural
Gender: Male

Name: it-IT-ElsaNeural
Gender: Female

Name: it-IT-GiuseppeNeural
Gender: Male

Name: it-IT-IsabellaNeural
Gender: Female

Name: ja-JP-KeitaNeural
Gender: Male

Name: ja-JP-NanamiNeural
Gender: Female

Name: jv-ID-DimasNeural
Gender: Male

Name: jv-ID-SitiNeural
Gender: Female

Name: ka-GE-EkaNeural
Gender: Female

Name: ka-GE-GiorgiNeural
Gender: Male

Name: kk-KZ-AigulNeural
Gender: Female

Name: kk-KZ-DauletNeural
Gender: Male

Name: km-KH-PisethNeural
Gender: Male

Name: km-KH-SreymomNeural
Gender: Female

Name: kn-IN-GaganNeural
Gender: Male

Name: kn-IN-SapnaNeural
Gender: Female

Name: ko-KR-HyunsuNeural
Gender: Male

Name: ko-KR-InJoonNeural
Gender: Male

Name: ko-KR-SunHiNeural
Gender: Female

Name: lo-LA-ChanthavongNeural
Gender: Male

Name: lo-LA-KeomanyNeural
Gender: Female

Name: lt-LT-LeonasNeural
Gender: Male

Name: lt-LT-OnaNeural
Gender: Female

Name: lv-LV-EveritaNeural
Gender: Female

Name: lv-LV-NilsNeural
Gender: Male

Name: mk-MK-AleksandarNeural
Gender: Male

Name: mk-MK-MarijaNeural
Gender: Female

Name: ml-IN-MidhunNeural
Gender: Male

Name: ml-IN-SobhanaNeural
Gender: Female

Name: mn-MN-BataaNeural
Gender: Male

Name: mn-MN-YesuiNeural
Gender: Female

Name: mr-IN-AarohiNeural
Gender: Female

Name: mr-IN-ManoharNeural
Gender: Male

Name: ms-MY-OsmanNeural
Gender: Male

Name: ms-MY-YasminNeural
Gender: Female

Name: mt-MT-GraceNeural
Gender: Female

Name: mt-MT-JosephNeural
Gender: Male

Name: my-MM-NilarNeural
Gender: Female

Name: my-MM-ThihaNeural
Gender: Male

Name: nb-NO-FinnNeural
Gender: Male

Name: nb-NO-PernilleNeural
Gender: Female

Name: ne-NP-HemkalaNeural
Gender: Female

Name: ne-NP-SagarNeural
Gender: Male

Name: nl-BE-ArnaudNeural
Gender: Male

Name: nl-BE-DenaNeural
Gender: Female

Name: nl-NL-ColetteNeural
Gender: Female

Name: nl-NL-FennaNeural
Gender: Female

Name: nl-NL-MaartenNeural
Gender: Male

Name: pl-PL-MarekNeural
Gender: Male

Name: pl-PL-ZofiaNeural
Gender: Female

Name: ps-AF-GulNawazNeural
Gender: Male

Name: ps-AF-LatifaNeural
Gender: Female

Name: pt-BR-AntonioNeural
Gender: Male

Name: pt-BR-FranciscaNeural
Gender: Female

Name: pt-BR-ThalitaNeural
Gender: Female

Name: pt-PT-DuarteNeural
Gender: Male

Name: pt-PT-RaquelNeural
Gender: Female

Name: ro-RO-AlinaNeural
Gender: Female

Name: ro-RO-EmilNeural
Gender: Male

Name: ru-RU-DmitryNeural
Gender: Male

Name: ru-RU-SvetlanaNeural
Gender: Female

Name: si-LK-SameeraNeural
Gender: Male

Name: si-LK-ThiliniNeural
Gender: Female

Name: sk-SK-LukasNeural
Gender: Male

Name: sk-SK-ViktoriaNeural
Gender: Female

Name: sl-SI-PetraNeural
Gender: Female

Name: sl-SI-RokNeural
Gender: Male

Name: so-SO-MuuseNeural
Gender: Male

Name: so-SO-UbaxNeural
Gender: Female

Name: sq-AL-AnilaNeural
Gender: Female

Name: sq-AL-IlirNeural
Gender: Male

Name: sr-RS-NicholasNeural
Gender: Male

Name: sr-RS-SophieNeural
Gender: Female

Name: su-ID-JajangNeural
Gender: Male

Name: su-ID-TutiNeural
Gender: Female

Name: sv-SE-MattiasNeural
Gender: Male

Name: sv-SE-SofieNeural
Gender: Female

Name: sw-KE-RafikiNeural
Gender: Male

Name: sw-KE-ZuriNeural
Gender: Female

Name: sw-TZ-DaudiNeural
Gender: Male

Name: sw-TZ-RehemaNeural
Gender: Female

Name: ta-IN-PallaviNeural
Gender: Female

Name: ta-IN-ValluvarNeural
Gender: Male

Name: ta-LK-KumarNeural
Gender: Male

Name: ta-LK-SaranyaNeural
Gender: Female

Name: ta-MY-KaniNeural
Gender: Female

Name: ta-MY-SuryaNeural
Gender: Male

Name: ta-SG-AnbuNeural
Gender: Male

Name: ta-SG-VenbaNeural
Gender: Female

Name: te-IN-MohanNeural
Gender: Male

Name: te-IN-ShrutiNeural
Gender: Female

Name: th-TH-NiwatNeural
Gender: Male

Name: th-TH-PremwadeeNeural
Gender: Female

Name: tr-TR-AhmetNeural
Gender: Male

Name: tr-TR-EmelNeural
Gender: Female

Name: uk-UA-OstapNeural
Gender: Male

Name: uk-UA-PolinaNeural
Gender: Female

Name: ur-IN-GulNeural
Gender: Female

Name: ur-IN-SalmanNeural
Gender: Male

Name: ur-PK-AsadNeural
Gender: Male

Name: ur-PK-UzmaNeural
Gender: Female

Name: uz-UZ-MadinaNeural
Gender: Female

Name: uz-UZ-SardorNeural
Gender: Male

Name: vi-VN-HoaiMyNeural
Gender: Female

Name: vi-VN-NamMinhNeural
Gender: Male

Name: zh-CN-XiaoxiaoNeural
Gender: Female

Name: zh-CN-XiaoyiNeural
Gender: Female

Name: zh-CN-YunjianNeural
Gender: Male

Name: zh-CN-YunxiNeural
Gender: Male

Name: zh-CN-YunxiaNeural
Gender: Male

Name: zh-CN-YunyangNeural
Gender: Male

Name: zh-CN-liaoning-XiaobeiNeural
Gender: Female

Name: zh-CN-shaanxi-XiaoniNeural
Gender: Female

Name: zh-HK-HiuGaaiNeural
Gender: Female

Name: zh-HK-HiuMaanNeural
Gender: Female

Name: zh-HK-WanLungNeural
Gender: Male

Name: zh-TW-HsiaoChenNeural
Gender: Female

Name: zh-TW-HsiaoYuNeural
Gender: Female

Name: zh-TW-YunJheNeural
Gender: Male

Name: zu-ZA-ThandoNeural
Gender: Female

Name: 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.mfbz.cn/a/557615.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

上位机图像处理和嵌入式模块部署(智能硬件的介绍)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 目前&#xff0c;用上位机软件虽然可以部署项目&#xff0c;但是它本身有自己的缺点&#xff0c;那就是稳定性差、价格贵。稳定性这部分&#xff0…

深度剖析扫雷游戏的各个知识点(2)

小伙伴们&#xff0c;大家好。这次继续上次的剖析扫雷游戏的知识点。 那么本次咱们主要是讲扫雷中的宏定义&#xff0c;也就是#define这些 首先#define是用来定义一个宏&#xff0c;后面就是类似于和变量一样的常量名&#xff0c;以及最后的数字就是它的值。 定义规则 #def…

数据结构——树和二叉树

目录 前言 一、树概念及结构 1.1树的概念 1.2 树的相关概念 ​编辑 1.3 树的表示 1.4 树的应用 2.二叉树概念及结构 2.1 二叉树概念 2.2 现实中的二叉树 2.3 特殊的二叉树 2.4 二叉树的性质 2.5 二叉树的存储结构 总结 前言 之前我们学习到的数据结构都是线性的…

Linux Makefile

1.开发背景 linux 下编译程序需要用到对应的 Makefile&#xff0c;用于编译应用程序。 2.开发需求 编写 Makefile 编译应用程序 1&#xff09;支持多个源文件 2&#xff09;支持多个头文件 3&#xff09;支持只编译修改的文件&#xff0c;包括源文件和头文件 4&#xff09;支持…

【Android Studio报错】:* What went wrong:Out of memory. Java heap space

项目场景&#xff1a; 今天&#xff0c;刚打开自己的安卓项目发现报错&#xff1a; 报错&#xff1a; * What went wrong: Out of memory. Java heap space Possible solution: - Check the JVM memory arguments defined for the gradle process in: gradle.properties in…

STM32G030F6P6TR ST意法

STM32G030F6P6TR是ST(意法半导体)一款基于高性能ArmCortex-M032位RISC内核&#xff0c;工作频率高达64MHz的32位MCU微控制器。代理销售ST(意法半导体)全系列IC电子元器件-中芯巨能为您提供STM32G030F6P6TR(ST 32位MCU)引脚图及中文参数介绍等内容。 STM32G030F6P6TR的中文参数 …

Python多态

1.多态 多态定义&#xff1a;多态&#xff08;polymorphism&#xff09;是指同一个方法调用由于对象不同可能会产生不同的行为 注意以下2点&#xff1a; 1.多态是方法的多态&#xff0c;属性没有多态。 2.多态的存在有2个必要条件&#xff1a;继承、方法重写 class Animal:de…

RabbitMQ入门实战

文章目录 RabbitMQ入门实战基本概念安装快速入门单向发送多消费者 RabbitMQ入门实战 官方&#xff1a;https://www.rabbitmq.com 基本概念 AMQP协议&#xff1a;https://www.rabbitmq.com/tutorials/amqp-concepts.html 定义&#xff1a;高级信息队列协议&#xff08;Advanc…

ORA-600 ktsiseginfo1故障---惜分飞

oracle 9i的库在运行途中突然报ORA-600 kcbnew_3错误 Sun Mar 31 14:25:11 2024 Undo Segment 69 Onlined Sun Mar 31 14:25:11 2024 Created Undo Segment _SYSSMU69$ Sun Mar 31 14:25:11 2024 Created Undo Segment _SYSSMU70$ Undo Segment 70 Onlined Sun Mar 31 14:28:41…

开启Three.js之旅(会持续完善)

文章目录 Three.js必备构建项目场景Scene相机CameraPerspectiveCamera 渲染器WebGLRendererCSS3DRenderer 灯光LightAmbientLightDirectionalLight 平行光PointLight 加载器CacheFileLoaderLoaderGLTFLoaderRGBELoaderTextureLoader 材质MetarialMeshBasicMaterialMeshLambertM…

【C++程序员的自我修炼】拷贝构造函数

心存希冀 追光而遇目有繁星 沐光而行 目录 拷贝构造函数概念 拷贝构造的特征 无穷递归的解释 浅拷贝 总结&#xff1a; 深拷贝 拷贝构造函数典型调用场景 总结 契子✨ 在生活中总有很多琐事&#xff0c;不做不行做了又怕麻烦&#xff0c;有时候想要是有个和自己一模一样的人就…

机器学习和深度学习-- 李宏毅(笔记于个人理解)Day 21

Day 21 Self- Attention 选修部分 ​ 学完自适应 再回来看看 Sequence Labling 假如我们现在有一个需要读完全部句子才能解的问题&#xff0c; 那么red window 就需要变得是最大的&#xff08;最长的句子&#xff09;&#xff1b; 其实这里大家有没有想过&#xff0c;这个玩意…

【机器学习】数据变换---小波变换特征提取及应用案列介绍

引言 在机器学习领域&#xff0c;数据变换是一种常见且重要的预处理步骤。通过对原始数据进行变换&#xff0c;我们可以提取出更有意义的特征&#xff0c;提高模型的性能。在众多数据变换方法中&#xff0c;小波变换是一种非常有效的方法&#xff0c;尤其适用于处理非平稳信号和…

maridb双数据源联查解决方案:联合存储引擎(Federated Storage Engine)

本地MySQL数据库要访问远程MySQL数据库的表中的数据, 必须通过FEDERATED存储引擎来实现. 有点类似Oracle中的数据库链接(DBLINK)。使用FEDERATED存储引擎的表,本地只存储表的结构信息,数据都存放在远程数据库上,查询时通过建表时指定的连接符去获取远程库的数据返回到本地。操作…

爬虫机试题-爬取新闻网站

之前投简历时遇到了这样的一个笔试。本以为会是数据结构算法之类的没想到直接发了一个word直接提需求&#xff0c;感觉挺有意思就写了这篇文章&#xff0c;感兴趣的朋友可以看看。 拿到urllist 通过分析页面结构我们得以知道&#xff0c;这个页面本身没有新闻信息&#xff0c;是…

计算机软考流程介绍

笔者来介绍一下软考流程 1、考试简介 计算机技术与软件专业技术资格&#xff08;水平&#xff09;考试&#xff1a;简称 计算机软考 认证&#xff1a; 国家人力资源和社会保障部 国家工业和信息化部 目的&#xff1a; 科学、公正地对全国计算机与软件专业技术人员进行职业资格…

Hotcoin 热门资产上新速报:以太坊互操作性基础设施Omni Network(OMNI)

Hotcoin持续为全球600万用户发掘优质潜力资产&#xff0c;热门币种交易上热币。一文快速了解今日上新资产:Omni Network&#xff08;OMNI&#xff09; 推荐指数 8.4 交易对 OMNI/USDT 交易时间 4月17日 GMT8 20&#xff1a;30 资产赛道 Layer1 项目简介 Omni 是以太坊…

安防视频监控/视频集中存储/云存储/磁盘阵列EasyCVR平台级联时,下级平台未发流是什么原因?

安防视频监控/视频集中存储/云存储/磁盘阵列EasyCVR平台可拓展性强、视频能力灵活、部署轻快&#xff0c;可支持的主流标准协议有国标GB28181、RTSP/Onvif、RTMP等&#xff0c;以及支持厂家私有协议与SDK接入&#xff0c;包括海康Ehome、海大宇等设备的SDK等。平台既具备传统安…

黑洞路由、 DDoS 攻击 、 环路

黑洞路由 DDoS 攻击 DDoS 攻击是一种针对服务器、服务或网络的恶意行为。DDoS 攻击通过向目标发送大量流量&#xff0c;使其不堪重负&#xff0c;导致资源和带宽被耗尽。因此&#xff0c;目标可能会变慢或崩溃&#xff0c;无法正常处理合法的流量。DDoS 攻击通常是由僵尸网络…

Jmeter 性能-内存溢出问题定位分析

1、堆内存溢出 ①稳定性压测一段时间后&#xff0c;Jmeter报错&#xff0c;日志报&#xff1a; java.lang.OutOfMemoryError.Java heap space ②用jmap -histo pid命令dump堆内存使用情况&#xff0c;查看堆内存排名前20个对象。 看是否有自己应用程序的方法&#xff0c;从…
最新文章