文字转视频 python_在python中将文本转换为叙述视频(Turning text into narrated video in python)...

在python中将文本转换为叙述视频(Turning text into narrated video in python)

我有很多文本,我想将它转换为音频,使用一些文本到语音库,然后我想将该音频转换为视频文件,如果屏幕只是黑色,或者如果文字是视觉的?

无论如何,我真的不知道从哪里开始。 有很多,我需要做很多次,我对python非常熟悉,但我不知道应该怎么做。 是否有用于将文本转换为python语音的标准库? 还是mp4中的音频?

I have a lot of text, and I would like to convert it into audio, using some text-to-speech library, and then I would like to turn that audio into a video file, it doesn't matter if the screen is just black, or maybe if the text was the visual?

Anyway, I don't really know where to get started. There is a lot of it, and I need it done a lot of times, and I'm pretty familiar with python but I don't know how I should go about this. Are there standard libraries for turning text into speech for python? Or audio in mp4?

原文:https://stackoverflow.com/questions/16125207

更新时间:2019-12-15 15:52

最满意答案

没有用python编写的纯文本到语音引擎,但是有很多其他引擎的包装器。 这是一些快速的谷歌搜索带来的:

如果你在Windows上, PySpeech与windows文本到语音引擎接口。 它不再受支持,但可能适合您。

龙也有一个自然界面的界面,叫做Dragonfly 。 此库也适用于内置的Windows系统,并且仍然受到积极支持。

最后,如果你在linux上,那就是pyFestival ,它为开源Festival引擎提供绑定。

There's no pure text-to-speech engine written in python, but there are plenty of wrappers for other engines. Here's what some quick googling brought up:

If you're on windows, PySpeech interfaces with the windows text-to-speech engine. It's no longer supported, but may work for you.

There's also an interface for dragon naturally speaking, called Dragonfly. This library also works on the built in Windows system, and is still actively supported.

Finally, if you're on linux, there's pyFestival, which offers bindings for the open source Festival engine.

2013-04-21

相关问答

如果我理解正确,你已经认识到了手(感兴趣区域又称投资回报率)并且想知道如何知道它是向左还是向右移动。 为了识别这一点,您应该保留其位置的历史记录。 只记得那只手的几帧。 import numpy as np

from collections import deque

cx_hist = deque(maxlen=10) # how many frames history

while True:

...

M = cv2.moments(contour) # the moment o

...

没有用python编写的纯文本到语音引擎,但是有很多其他引擎的包装器。 这是一些快速的谷歌搜索带来的: 如果你在Windows上, PySpeech与windows文本到语音引擎接口。 它不再受支持,但可能适合您。 龙也有一个自然界面的界面,叫做Dragonfly 。 此库也适用于内置的Windows系统,并且仍然受到积极支持。 最后,如果你在linux上,那就是pyFestival ,它为开源Festival引擎提供绑定。 There's no pure text-to-speech engin

...

从nltk.org的主页看来,这不仅仅是一种解决方法: >>> import nltk

>>> sentence = """At eight o'clock on Thursday morning

... Arthur didn't feel very good."""

>>> tokens = nltk.word_tokenize(sentence)

>>> tokens

['At', 'eight', "o'clock", 'on', 'Thursday', 'morning',

'Art

...

使用阅读视频文件 cap = cv2.VideoCapture(fileName)

浏览每一帧: while(cap.isOpened()):

# Read frame

ret, frame = cap.read()

如果您愿意,您可以将每个帧插入到3D矩阵中,以获得您想要的时空矩阵 Read the video file using cap = cv2.VideoCapture(fileName)

Go over each frame: while(cap.isOpene

...

这个问题就是解决方案。 也适用于Python 2.7 与NLTK无关。 简单的解决方案是使用'unicode_escape' 解码输出文本 print(str(tree).decode('unicode_escape'))

和 print(rule.unicode_repr().decode('unicode_escape'))

对于NTLK类型的解决方案,打印nltk.tree.Tree类型的树作为括号文本,使用以下 print(tree.pformat())

Solutions are

...

使用selenium API时,您应该执行一些任务,例如单击按钮或滚动到底部。 当您需要从HTML中提取信息时,您应该使用BeautifulSoup,它非常简单: from selenium import webdriver

import os

import re

from bs4 import BeautifulSoup

driver = webdriver.PhantomJS()

driver.implicitly_wait(30)

driver.set_window_size(1120, 5

...

尝试使用OpenCV的Python包装器,例如ctypes-opencv 。 C API引用在这里 ,包装器非常接近(有关任何更改,请参阅docstrings)。 我用它来绘制视频而没有任何闪烁,所以你应该没有问题。 您需要的大致电话大纲: 使用cvCreateFileCapture加载视频,使用cvFont加载字体。 使用cvQueryFrame抓取框架,增加框架计数器。 使用cvPutText,cvEllipse等在框架上绘图等。 使用cvShowImage显示给用户。 Try a Pytho

...

根据w3 : Comments consist of the following parts, in exactly the following order:

- the comment start delimiter ""

The text part of comments has the following restrictions:

1. must not start with a ">" cha

...

在为drawtext指定参数时,冒号“:”和反斜杠“\”具有特殊含义。 所以你可以做的是通过将“:”转换为“\:”并将“\”转换为“\\”来逃避它们。 此外,您可以用单引号括住字体文件的路径,因为路径中包含空格。 所以你会有 ffmpeg -i C:\Test\rec\vid_1321909320.avi -vf drawtext=fontfile='C\:\\Windows\\Fonts\\arial.ttf':text=test vid_1321909320.flv

A colon ":"

...

我有同样的问题,我正在寻找解决方案。 我找到了这个 这似乎工作得很好,虽然我还没有尝试。 希望这可以帮助。 I have the same problem and am searching the solution. I found this This seems work well though I didn't try yet. Hope this helps.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值