在一些帮助下,我已经设法发现口语。 现在我正在寻找让选定的人说出的文字。 这样我就可以输入 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 + " "
