当前位置:   article > 正文

一个文生视频MoneyPrinterTurbo项目解析

一个文生视频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 虚拟环境

  1. git clone https://github.com/harry0703/MoneyPrinterTurbo.git
  2. cd MoneyPrinterTurbo
  3. conda create -n MoneyPrinterTurbo python=3.10
  4. conda activate MoneyPrinterTurbo
  5. pip install -r requirements.txt

② 安装好 ImageMagick

Windows:

MacOS:

brew install imagemagick

Ubuntu:

sudo apt-get install imagemagick

CentOS:

sudo yum install ImageMagick

③ 启动Web界面

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

Windows:

  1. conda activate MoneyPrinterTurbo
  2. webui.bat

MacOS or Linux:

  1. conda activate MoneyPrinterTurbo
  2. sh webui.sh

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

④ 启动API服务

python main.py

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

三.源码剖析

1.开发框架

2.参数解析

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

3.处理流程

70a4972c971349878f61eb9de17f5e4d.png

3.1.获取配音人信息

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

  1. # zh-CN-XiaoyiNeural-Female
  2. # zh-CN-YunxiNeural-Male

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

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

  1. # openai
  2. # moonshot (月之暗面)
  3. # oneapi
  4. # g4f
  5. # azure
  6. # qwen (通义千问)
  7. # gemini

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

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

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

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

3.3.音频合成

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

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库:

拼接方法:

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

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

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

3.7.视频生成

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

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

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

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

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

四.附录

1.声音列表

  1. Name: af-ZA-AdriNeural
  2. Gender: Female
  3. Name: af-ZA-WillemNeural
  4. Gender: Male
  5. Name: am-ET-AmehaNeural
  6. Gender: Male
  7. Name: am-ET-MekdesNeural
  8. Gender: Female
  9. Name: ar-AE-FatimaNeural
  10. Gender: Female
  11. Name: ar-AE-HamdanNeural
  12. Gender: Male
  13. Name: ar-BH-AliNeural
  14. Gender: Male
  15. Name: ar-BH-LailaNeural
  16. Gender: Female
  17. Name: ar-DZ-AminaNeural
  18. Gender: Female
  19. Name: ar-DZ-IsmaelNeural
  20. Gender: Male
  21. Name: ar-EG-SalmaNeural
  22. Gender: Female
  23. Name: ar-EG-ShakirNeural
  24. Gender: Male
  25. Name: ar-IQ-BasselNeural
  26. Gender: Male
  27. Name: ar-IQ-RanaNeural
  28. Gender: Female
  29. Name: ar-JO-SanaNeural
  30. Gender: Female
  31. Name: ar-JO-TaimNeural
  32. Gender: Male
  33. Name: ar-KW-FahedNeural
  34. Gender: Male
  35. Name: ar-KW-NouraNeural
  36. Gender: Female
  37. Name: ar-LB-LaylaNeural
  38. Gender: Female
  39. Name: ar-LB-RamiNeural
  40. Gender: Male
  41. Name: ar-LY-ImanNeural
  42. Gender: Female
  43. Name: ar-LY-OmarNeural
  44. Gender: Male
  45. Name: ar-MA-JamalNeural
  46. Gender: Male
  47. Name: ar-MA-MounaNeural
  48. Gender: Female
  49. Name: ar-OM-AbdullahNeural
  50. Gender: Male
  51. Name: ar-OM-AyshaNeural
  52. Gender: Female
  53. Name: ar-QA-AmalNeural
  54. Gender: Female
  55. Name: ar-QA-MoazNeural
  56. Gender: Male
  57. Name: ar-SA-HamedNeural
  58. Gender: Male
  59. Name: ar-SA-ZariyahNeural
  60. Gender: Female
  61. Name: ar-SY-AmanyNeural
  62. Gender: Female
  63. Name: ar-SY-LaithNeural
  64. Gender: Male
  65. Name: ar-TN-HediNeural
  66. Gender: Male
  67. Name: ar-TN-ReemNeural
  68. Gender: Female
  69. Name: ar-YE-MaryamNeural
  70. Gender: Female
  71. Name: ar-YE-SalehNeural
  72. Gender: Male
  73. Name: az-AZ-BabekNeural
  74. Gender: Male
  75. Name: az-AZ-BanuNeural
  76. Gender: Female
  77. Name: bg-BG-BorislavNeural
  78. Gender: Male
  79. Name: bg-BG-KalinaNeural
  80. Gender: Female
  81. Name: bn-BD-NabanitaNeural
  82. Gender: Female
  83. Name: bn-BD-PradeepNeural
  84. Gender: Male
  85. Name: bn-IN-BashkarNeural
  86. Gender: Male
  87. Name: bn-IN-TanishaaNeural
  88. Gender: Female
  89. Name: bs-BA-GoranNeural
  90. Gender: Male
  91. Name: bs-BA-VesnaNeural
  92. Gender: Female
  93. Name: ca-ES-EnricNeural
  94. Gender: Male
  95. Name: ca-ES-JoanaNeural
  96. Gender: Female
  97. Name: cs-CZ-AntoninNeural
  98. Gender: Male
  99. Name: cs-CZ-VlastaNeural
  100. Gender: Female
  101. Name: cy-GB-AledNeural
  102. Gender: Male
  103. Name: cy-GB-NiaNeural
  104. Gender: Female
  105. Name: da-DK-ChristelNeural
  106. Gender: Female
  107. Name: da-DK-JeppeNeural
  108. Gender: Male
  109. Name: de-AT-IngridNeural
  110. Gender: Female
  111. Name: de-AT-JonasNeural
  112. Gender: Male
  113. Name: de-CH-JanNeural
  114. Gender: Male
  115. Name: de-CH-LeniNeural
  116. Gender: Female
  117. Name: de-DE-AmalaNeural
  118. Gender: Female
  119. Name: de-DE-ConradNeural
  120. Gender: Male
  121. Name: de-DE-FlorianMultilingualNeural
  122. Gender: Male
  123. Name: de-DE-KatjaNeural
  124. Gender: Female
  125. Name: de-DE-KillianNeural
  126. Gender: Male
  127. Name: de-DE-SeraphinaMultilingualNeural
  128. Gender: Female
  129. Name: el-GR-AthinaNeural
  130. Gender: Female
  131. Name: el-GR-NestorasNeural
  132. Gender: Male
  133. Name: en-AU-NatashaNeural
  134. Gender: Female
  135. Name: en-AU-WilliamNeural
  136. Gender: Male
  137. Name: en-CA-ClaraNeural
  138. Gender: Female
  139. Name: en-CA-LiamNeural
  140. Gender: Male
  141. Name: en-GB-LibbyNeural
  142. Gender: Female
  143. Name: en-GB-MaisieNeural
  144. Gender: Female
  145. Name: en-GB-RyanNeural
  146. Gender: Male
  147. Name: en-GB-SoniaNeural
  148. Gender: Female
  149. Name: en-GB-ThomasNeural
  150. Gender: Male
  151. Name: en-HK-SamNeural
  152. Gender: Male
  153. Name: en-HK-YanNeural
  154. Gender: Female
  155. Name: en-IE-ConnorNeural
  156. Gender: Male
  157. Name: en-IE-EmilyNeural
  158. Gender: Female
  159. Name: en-IN-NeerjaExpressiveNeural
  160. Gender: Female
  161. Name: en-IN-NeerjaNeural
  162. Gender: Female
  163. Name: en-IN-PrabhatNeural
  164. Gender: Male
  165. Name: en-KE-AsiliaNeural
  166. Gender: Female
  167. Name: en-KE-ChilembaNeural
  168. Gender: Male
  169. Name: en-NG-AbeoNeural
  170. Gender: Male
  171. Name: en-NG-EzinneNeural
  172. Gender: Female
  173. Name: en-NZ-MitchellNeural
  174. Gender: Male
  175. Name: en-NZ-MollyNeural
  176. Gender: Female
  177. Name: en-PH-JamesNeural
  178. Gender: Male
  179. Name: en-PH-RosaNeural
  180. Gender: Female
  181. Name: en-SG-LunaNeural
  182. Gender: Female
  183. Name: en-SG-WayneNeural
  184. Gender: Male
  185. Name: en-TZ-ElimuNeural
  186. Gender: Male
  187. Name: en-TZ-ImaniNeural
  188. Gender: Female
  189. Name: en-US-AnaNeural
  190. Gender: Female
  191. Name: en-US-AndrewNeural
  192. Gender: Male
  193. Name: en-US-AriaNeural
  194. Gender: Female
  195. Name: en-US-AvaNeural
  196. Gender: Female
  197. Name: en-US-BrianNeural
  198. Gender: Male
  199. Name: en-US-ChristopherNeural
  200. Gender: Male
  201. Name: en-US-EmmaNeural
  202. Gender: Female
  203. Name: en-US-EricNeural
  204. Gender: Male
  205. Name: en-US-GuyNeural
  206. Gender: Male
  207. Name: en-US-JennyNeural
  208. Gender: Female
  209. Name: en-US-MichelleNeural
  210. Gender: Female
  211. Name: en-US-RogerNeural
  212. Gender: Male
  213. Name: en-US-SteffanNeural
  214. Gender: Male
  215. Name: en-ZA-LeahNeural
  216. Gender: Female
  217. Name: en-ZA-LukeNeural
  218. Gender: Male
  219. Name: es-AR-ElenaNeural
  220. Gender: Female
  221. Name: es-AR-TomasNeural
  222. Gender: Male
  223. Name: es-BO-MarceloNeural
  224. Gender: Male
  225. Name: es-BO-SofiaNeural
  226. Gender: Female
  227. Name: es-CL-CatalinaNeural
  228. Gender: Female
  229. Name: es-CL-LorenzoNeural
  230. Gender: Male
  231. Name: es-CO-GonzaloNeural
  232. Gender: Male
  233. Name: es-CO-SalomeNeural
  234. Gender: Female
  235. Name: es-CR-JuanNeural
  236. Gender: Male
  237. Name: es-CR-MariaNeural
  238. Gender: Female
  239. Name: es-CU-BelkysNeural
  240. Gender: Female
  241. Name: es-CU-ManuelNeural
  242. Gender: Male
  243. Name: es-DO-EmilioNeural
  244. Gender: Male
  245. Name: es-DO-RamonaNeural
  246. Gender: Female
  247. Name: es-EC-AndreaNeural
  248. Gender: Female
  249. Name: es-EC-LuisNeural
  250. Gender: Male
  251. Name: es-ES-AlvaroNeural
  252. Gender: Male
  253. Name: es-ES-ElviraNeural
  254. Gender: Female
  255. Name: es-ES-XimenaNeural
  256. Gender: Female
  257. Name: es-GQ-JavierNeural
  258. Gender: Male
  259. Name: es-GQ-TeresaNeural
  260. Gender: Female
  261. Name: es-GT-AndresNeural
  262. Gender: Male
  263. Name: es-GT-MartaNeural
  264. Gender: Female
  265. Name: es-HN-CarlosNeural
  266. Gender: Male
  267. Name: es-HN-KarlaNeural
  268. Gender: Female
  269. Name: es-MX-DaliaNeural
  270. Gender: Female
  271. Name: es-MX-JorgeNeural
  272. Gender: Male
  273. Name: es-NI-FedericoNeural
  274. Gender: Male
  275. Name: es-NI-YolandaNeural
  276. Gender: Female
  277. Name: es-PA-MargaritaNeural
  278. Gender: Female
  279. Name: es-PA-RobertoNeural
  280. Gender: Male
  281. Name: es-PE-AlexNeural
  282. Gender: Male
  283. Name: es-PE-CamilaNeural
  284. Gender: Female
  285. Name: es-PR-KarinaNeural
  286. Gender: Female
  287. Name: es-PR-VictorNeural
  288. Gender: Male
  289. Name: es-PY-MarioNeural
  290. Gender: Male
  291. Name: es-PY-TaniaNeural
  292. Gender: Female
  293. Name: es-SV-LorenaNeural
  294. Gender: Female
  295. Name: es-SV-RodrigoNeural
  296. Gender: Male
  297. Name: es-US-AlonsoNeural
  298. Gender: Male
  299. Name: es-US-PalomaNeural
  300. Gender: Female
  301. Name: es-UY-MateoNeural
  302. Gender: Male
  303. Name: es-UY-ValentinaNeural
  304. Gender: Female
  305. Name: es-VE-PaolaNeural
  306. Gender: Female
  307. Name: es-VE-SebastianNeural
  308. Gender: Male
  309. Name: et-EE-AnuNeural
  310. Gender: Female
  311. Name: et-EE-KertNeural
  312. Gender: Male
  313. Name: fa-IR-DilaraNeural
  314. Gender: Female
  315. Name: fa-IR-FaridNeural
  316. Gender: Male
  317. Name: fi-FI-HarriNeural
  318. Gender: Male
  319. Name: fi-FI-NooraNeural
  320. Gender: Female
  321. Name: fil-PH-AngeloNeural
  322. Gender: Male
  323. Name: fil-PH-BlessicaNeural
  324. Gender: Female
  325. Name: fr-BE-CharlineNeural
  326. Gender: Female
  327. Name: fr-BE-GerardNeural
  328. Gender: Male
  329. Name: fr-CA-AntoineNeural
  330. Gender: Male
  331. Name: fr-CA-JeanNeural
  332. Gender: Male
  333. Name: fr-CA-SylvieNeural
  334. Gender: Female
  335. Name: fr-CA-ThierryNeural
  336. Gender: Male
  337. Name: fr-CH-ArianeNeural
  338. Gender: Female
  339. Name: fr-CH-FabriceNeural
  340. Gender: Male
  341. Name: fr-FR-DeniseNeural
  342. Gender: Female
  343. Name: fr-FR-EloiseNeural
  344. Gender: Female
  345. Name: fr-FR-HenriNeural
  346. Gender: Male
  347. Name: fr-FR-RemyMultilingualNeural
  348. Gender: Male
  349. Name: fr-FR-VivienneMultilingualNeural
  350. Gender: Female
  351. Name: ga-IE-ColmNeural
  352. Gender: Male
  353. Name: ga-IE-OrlaNeural
  354. Gender: Female
  355. Name: gl-ES-RoiNeural
  356. Gender: Male
  357. Name: gl-ES-SabelaNeural
  358. Gender: Female
  359. Name: gu-IN-DhwaniNeural
  360. Gender: Female
  361. Name: gu-IN-NiranjanNeural
  362. Gender: Male
  363. Name: he-IL-AvriNeural
  364. Gender: Male
  365. Name: he-IL-HilaNeural
  366. Gender: Female
  367. Name: hi-IN-MadhurNeural
  368. Gender: Male
  369. Name: hi-IN-SwaraNeural
  370. Gender: Female
  371. Name: hr-HR-GabrijelaNeural
  372. Gender: Female
  373. Name: hr-HR-SreckoNeural
  374. Gender: Male
  375. Name: hu-HU-NoemiNeural
  376. Gender: Female
  377. Name: hu-HU-TamasNeural
  378. Gender: Male
  379. Name: id-ID-ArdiNeural
  380. Gender: Male
  381. Name: id-ID-GadisNeural
  382. Gender: Female
  383. Name: is-IS-GudrunNeural
  384. Gender: Female
  385. Name: is-IS-GunnarNeural
  386. Gender: Male
  387. Name: it-IT-DiegoNeural
  388. Gender: Male
  389. Name: it-IT-ElsaNeural
  390. Gender: Female
  391. Name: it-IT-GiuseppeNeural
  392. Gender: Male
  393. Name: it-IT-IsabellaNeural
  394. Gender: Female
  395. Name: ja-JP-KeitaNeural
  396. Gender: Male
  397. Name: ja-JP-NanamiNeural
  398. Gender: Female
  399. Name: jv-ID-DimasNeural
  400. Gender: Male
  401. Name: jv-ID-SitiNeural
  402. Gender: Female
  403. Name: ka-GE-EkaNeural
  404. Gender: Female
  405. Name: ka-GE-GiorgiNeural
  406. Gender: Male
  407. Name: kk-KZ-AigulNeural
  408. Gender: Female
  409. Name: kk-KZ-DauletNeural
  410. Gender: Male
  411. Name: km-KH-PisethNeural
  412. Gender: Male
  413. Name: km-KH-SreymomNeural
  414. Gender: Female
  415. Name: kn-IN-GaganNeural
  416. Gender: Male
  417. Name: kn-IN-SapnaNeural
  418. Gender: Female
  419. Name: ko-KR-HyunsuNeural
  420. Gender: Male
  421. Name: ko-KR-InJoonNeural
  422. Gender: Male
  423. Name: ko-KR-SunHiNeural
  424. Gender: Female
  425. Name: lo-LA-ChanthavongNeural
  426. Gender: Male
  427. Name: lo-LA-KeomanyNeural
  428. Gender: Female
  429. Name: lt-LT-LeonasNeural
  430. Gender: Male
  431. Name: lt-LT-OnaNeural
  432. Gender: Female
  433. Name: lv-LV-EveritaNeural
  434. Gender: Female
  435. Name: lv-LV-NilsNeural
  436. Gender: Male
  437. Name: mk-MK-AleksandarNeural
  438. Gender: Male
  439. Name: mk-MK-MarijaNeural
  440. Gender: Female
  441. Name: ml-IN-MidhunNeural
  442. Gender: Male
  443. Name: ml-IN-SobhanaNeural
  444. Gender: Female
  445. Name: mn-MN-BataaNeural
  446. Gender: Male
  447. Name: mn-MN-YesuiNeural
  448. Gender: Female
  449. Name: mr-IN-AarohiNeural
  450. Gender: Female
  451. Name: mr-IN-ManoharNeural
  452. Gender: Male
  453. Name: ms-MY-OsmanNeural
  454. Gender: Male
  455. Name: ms-MY-YasminNeural
  456. Gender: Female
  457. Name: mt-MT-GraceNeural
  458. Gender: Female
  459. Name: mt-MT-JosephNeural
  460. Gender: Male
  461. Name: my-MM-NilarNeural
  462. Gender: Female
  463. Name: my-MM-ThihaNeural
  464. Gender: Male
  465. Name: nb-NO-FinnNeural
  466. Gender: Male
  467. Name: nb-NO-PernilleNeural
  468. Gender: Female
  469. Name: ne-NP-HemkalaNeural
  470. Gender: Female
  471. Name: ne-NP-SagarNeural
  472. Gender: Male
  473. Name: nl-BE-ArnaudNeural
  474. Gender: Male
  475. Name: nl-BE-DenaNeural
  476. Gender: Female
  477. Name: nl-NL-ColetteNeural
  478. Gender: Female
  479. Name: nl-NL-FennaNeural
  480. Gender: Female
  481. Name: nl-NL-MaartenNeural
  482. Gender: Male
  483. Name: pl-PL-MarekNeural
  484. Gender: Male
  485. Name: pl-PL-ZofiaNeural
  486. Gender: Female
  487. Name: ps-AF-GulNawazNeural
  488. Gender: Male
  489. Name: ps-AF-LatifaNeural
  490. Gender: Female
  491. Name: pt-BR-AntonioNeural
  492. Gender: Male
  493. Name: pt-BR-FranciscaNeural
  494. Gender: Female
  495. Name: pt-BR-ThalitaNeural
  496. Gender: Female
  497. Name: pt-PT-DuarteNeural
  498. Gender: Male
  499. Name: pt-PT-RaquelNeural
  500. Gender: Female
  501. Name: ro-RO-AlinaNeural
  502. Gender: Female
  503. Name: ro-RO-EmilNeural
  504. Gender: Male
  505. Name: ru-RU-DmitryNeural
  506. Gender: Male
  507. Name: ru-RU-SvetlanaNeural
  508. Gender: Female
  509. Name: si-LK-SameeraNeural
  510. Gender: Male
  511. Name: si-LK-ThiliniNeural
  512. Gender: Female
  513. Name: sk-SK-LukasNeural
  514. Gender: Male
  515. Name: sk-SK-ViktoriaNeural
  516. Gender: Female
  517. Name: sl-SI-PetraNeural
  518. Gender: Female
  519. Name: sl-SI-RokNeural
  520. Gender: Male
  521. Name: so-SO-MuuseNeural
  522. Gender: Male
  523. Name: so-SO-UbaxNeural
  524. Gender: Female
  525. Name: sq-AL-AnilaNeural
  526. Gender: Female
  527. Name: sq-AL-IlirNeural
  528. Gender: Male
  529. Name: sr-RS-NicholasNeural
  530. Gender: Male
  531. Name: sr-RS-SophieNeural
  532. Gender: Female
  533. Name: su-ID-JajangNeural
  534. Gender: Male
  535. Name: su-ID-TutiNeural
  536. Gender: Female
  537. Name: sv-SE-MattiasNeural
  538. Gender: Male
  539. Name: sv-SE-SofieNeural
  540. Gender: Female
  541. Name: sw-KE-RafikiNeural
  542. Gender: Male
  543. Name: sw-KE-ZuriNeural
  544. Gender: Female
  545. Name: sw-TZ-DaudiNeural
  546. Gender: Male
  547. Name: sw-TZ-RehemaNeural
  548. Gender: Female
  549. Name: ta-IN-PallaviNeural
  550. Gender: Female
  551. Name: ta-IN-ValluvarNeural
  552. Gender: Male
  553. Name: ta-LK-KumarNeural
  554. Gender: Male
  555. Name: ta-LK-SaranyaNeural
  556. Gender: Female
  557. Name: ta-MY-KaniNeural
  558. Gender: Female
  559. Name: ta-MY-SuryaNeural
  560. Gender: Male
  561. Name: ta-SG-AnbuNeural
  562. Gender: Male
  563. Name: ta-SG-VenbaNeural
  564. Gender: Female
  565. Name: te-IN-MohanNeural
  566. Gender: Male
  567. Name: te-IN-ShrutiNeural
  568. Gender: Female
  569. Name: th-TH-NiwatNeural
  570. Gender: Male
  571. Name: th-TH-PremwadeeNeural
  572. Gender: Female
  573. Name: tr-TR-AhmetNeural
  574. Gender: Male
  575. Name: tr-TR-EmelNeural
  576. Gender: Female
  577. Name: uk-UA-OstapNeural
  578. Gender: Male
  579. Name: uk-UA-PolinaNeural
  580. Gender: Female
  581. Name: ur-IN-GulNeural
  582. Gender: Female
  583. Name: ur-IN-SalmanNeural
  584. Gender: Male
  585. Name: ur-PK-AsadNeural
  586. Gender: Male
  587. Name: ur-PK-UzmaNeural
  588. Gender: Female
  589. Name: uz-UZ-MadinaNeural
  590. Gender: Female
  591. Name: uz-UZ-SardorNeural
  592. Gender: Male
  593. Name: vi-VN-HoaiMyNeural
  594. Gender: Female
  595. Name: vi-VN-NamMinhNeural
  596. Gender: Male
  597. Name: zh-CN-XiaoxiaoNeural
  598. Gender: Female
  599. Name: zh-CN-XiaoyiNeural
  600. Gender: Female
  601. Name: zh-CN-YunjianNeural
  602. Gender: Male
  603. Name: zh-CN-YunxiNeural
  604. Gender: Male
  605. Name: zh-CN-YunxiaNeural
  606. Gender: Male
  607. Name: zh-CN-YunyangNeural
  608. Gender: Male
  609. Name: zh-CN-liaoning-XiaobeiNeural
  610. Gender: Female
  611. Name: zh-CN-shaanxi-XiaoniNeural
  612. Gender: Female
  613. Name: zh-HK-HiuGaaiNeural
  614. Gender: Female
  615. Name: zh-HK-HiuMaanNeural
  616. Gender: Female
  617. Name: zh-HK-WanLungNeural
  618. Gender: Male
  619. Name: zh-TW-HsiaoChenNeural
  620. Gender: Female
  621. Name: zh-TW-HsiaoYuNeural
  622. Gender: Female
  623. Name: zh-TW-YunJheNeural
  624. Gender: Male
  625. Name: zu-ZA-ThandoNeural
  626. Gender: Female
  627. Name: zu-ZA-ThembaNeural
  628. 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

响应

请求范例

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

响应范例

  1. {
  2. "page": 1,
  3. "per_page": 1,
  4. "total_results": 20475,
  5. "url": "https://www.pexels.com/videos/",
  6. "videos": [
  7. {
  8. "id": 1448735,
  9. "width": 4096,
  10. "height": 2160,
  11. "url": "https://www.pexels.com/video/video-of-forest-1448735/",
  12. "image": "https://images.pexels.com/videos/1448735/free-video-1448735.jpg?fit=crop&w=1200&h=630&auto=compress&cs=tinysrgb",
  13. "duration": 32,
  14. "user": {
  15. "id": 574687,
  16. "name": "Ruvim Miksanskiy",
  17. "url": "https://www.pexels.com/@digitech"
  18. },
  19. "video_files": [
  20. {
  21. "id": 58649,
  22. "quality": "sd",
  23. "file_type": "video/mp4",
  24. "width": 640,
  25. "height": 338,
  26. "link": "https://player.vimeo.com/external/291648067.sd.mp4?s=7f9ee1f8ec1e5376027e4a6d1d05d5738b2fbb29&profile_id=164&oauth2_token_id=57447761"
  27. },
  28. {
  29. "id": 58650,
  30. "quality": "hd",
  31. "file_type": "video/mp4",
  32. "width": 2048,
  33. "height": 1080,
  34. "link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=175&oauth2_token_id=57447761"
  35. },
  36. {
  37. "id": 58651,
  38. "quality": "hd",
  39. "file_type": "video/mp4",
  40. "width": 4096,
  41. "height": 2160,
  42. "link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=172&oauth2_token_id=57447761"
  43. },
  44. {
  45. "id": 58652,
  46. "quality": "hd",
  47. "file_type": "video/mp4",
  48. "width": 1366,
  49. "height": 720,
  50. "link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=174&oauth2_token_id=57447761"
  51. },
  52. {
  53. "id": 58653,
  54. "quality": "hd",
  55. "file_type": "video/mp4",
  56. "width": 2732,
  57. "height": 1440,
  58. "link": "https://player.vimeo.com/external/291648067.hd.mp4?s=94998971682c6a3267e4cbd19d16a7b6c720f345&profile_id=170&oauth2_token_id=57447761"
  59. },
  60. {
  61. "id": 58654,
  62. "quality": "sd",
  63. "file_type": "video/mp4",
  64. "width": 960,
  65. "height": 506,
  66. "link": "https://player.vimeo.com/external/291648067.sd.mp4?s=7f9ee1f8ec1e5376027e4a6d1d05d5738b2fbb29&profile_id=165&oauth2_token_id=57447761"
  67. },
  68. {
  69. "id": 58655,
  70. "quality": "hls",
  71. "file_type": "video/mp4",
  72. "width": null,
  73. "height": null,
  74. "link": "https://player.vimeo.com/external/291648067.m3u8?s=1210fac9d80f9b74b4a334c4fca327cde08886b2&oauth2_token_id=57447761"
  75. }
  76. ],
  77. "video_pictures": [
  78. {
  79. "id": 133236,
  80. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-0.jpg",
  81. "nr": 0
  82. },
  83. {
  84. "id": 133237,
  85. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-1.jpg",
  86. "nr": 1
  87. },
  88. {
  89. "id": 133238,
  90. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-2.jpg",
  91. "nr": 2
  92. },
  93. {
  94. "id": 133239,
  95. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-3.jpg",
  96. "nr": 3
  97. },
  98. {
  99. "id": 133240,
  100. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-4.jpg",
  101. "nr": 4
  102. },
  103. {
  104. "id": 133241,
  105. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-5.jpg",
  106. "nr": 5
  107. },
  108. {
  109. "id": 133242,
  110. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-6.jpg",
  111. "nr": 6
  112. },
  113. {
  114. "id": 133243,
  115. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-7.jpg",
  116. "nr": 7
  117. },
  118. {
  119. "id": 133244,
  120. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-8.jpg",
  121. "nr": 8
  122. },
  123. {
  124. "id": 133245,
  125. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-9.jpg",
  126. "nr": 9
  127. },
  128. {
  129. "id": 133246,
  130. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-10.jpg",
  131. "nr": 10
  132. },
  133. {
  134. "id": 133247,
  135. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-11.jpg",
  136. "nr": 11
  137. },
  138. {
  139. "id": 133248,
  140. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-12.jpg",
  141. "nr": 12
  142. },
  143. {
  144. "id": 133249,
  145. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-13.jpg",
  146. "nr": 13
  147. },
  148. {
  149. "id": 133250,
  150. "picture": "https://static-videos.pexels.com/videos/1448735/pictures/preview-14.jpg",
  151. "nr": 14
  152. }
  153. ]
  154. }

3.接口调用脚本

3.1.获取配乐

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

3.2.视频生成

  1. curl --location 'http://127.0.0.1:8080/api/v1/videos' \
  2. --header 'Content-Type: application/json' \
  3. --data '{
  4. "video_subject": "千岛湖的落日",
  5. "video_script": "",
  6. "video_terms": "",
  7. "video_aspect": "16:9",
  8. "video_concat_mode": "random",
  9. "video_clip_duration": 5,
  10. "video_count": 1,
  11. "video_language": "",
  12. "voice_name": "zh-CN-XiaoyiNeural",
  13. "voice_volume": 1,
  14. "bgm_type": "random",
  15. "bgm_file": "",
  16. "bgm_volume": 0.2,
  17. "subtitle_enabled": true,
  18. "subtitle_position": "bottom",
  19. "font_name": "STHeitiMedium.ttc",
  20. "text_fore_color": "#FFFFFF",
  21. "text_background_color": "transparent",
  22. "font_size": 60,
  23. "stroke_color": "#000000",
  24. "stroke_width": 1.5,
  25. "n_threads": 2,
  26. "paragraph_number": 1
  27. }'

3.3.任务状态查询

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

3.4.视频脚本生成

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

3.5.视频检索关键词生成

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

3.6.上传背景音乐

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

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/453609
推荐阅读
相关标签
  

闽ICP备14008679号