gpt4 book ai didi

python - 计算一个角色在电影剧本中说的话

转载 作者:太空宇宙 更新时间:2023-11-04 07:55:13 29 4
gpt4 key购买 nike

在一些帮助下,我已经设法发现口语。现在我正在寻找让选定的人说出的文字。这样我就可以输入 MIA 并获取她在电影中所说的每一个字像这样:

name = input("Enter name:")
wordsspoken(script, name)
name1 = input("Enter another name:")
wordsspoken(script, name1)

这样我就可以数出之后的字数了。

电影剧本是这样的

An awkward beat. They pass a wooden SALOON -- where a WESTERN
is being shot. Extras in COWBOY costumes drink coffee on the
steps.
Revision 25.


MIA (CONT'D)
I love this stuff. Makes coming to work
easier.

SEBASTIAN
I know what you mean. I get breakfast
five miles out of the way just to sit
outside a jazz club.

MIA
Oh yeah?

SEBASTIAN
It was called Van Beek. The swing bands
played there. Count Basie. Chick Webb.
(then,)
It's a samba-tapas place now.

MIA
A what?

SEBASTIAN
Samba-tapas. It's... Exactly. The joke's on
history.

最佳答案

我会先询问用户脚本中的所有名称。然后询问他们想要哪个名字的单词。我会逐字搜索文本,直到找到想要的名字,然后将以下单词复制到变量中,直到找到与脚本中其他人匹配的名字。现在人们可以说出另一个角色的名字,但如果您假设说话的人的标题全部大写,或者在一行中,文本应该很容易过滤。

for word in script:
if word == speaker and word.isupper(): # you may want to check that this is on its own line as well.
recording = True
elif word in character_names and word.isupper(): # you may want to check that this is on its own line as well.
recording = False

if recording:
spoken_text += word + " "

关于python - 计算一个角色在电影剧本中说的话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49881391/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com