Par*_*gue 13 python algorithm nlp linguistics cpu-word
我非常喜欢发现可以很快敲击的句子.例如,"必须读一点维基百科"或"不想用一瓶麦芽在阴沟里结束".(乔治·沃茨基)
我想用Python编写一个程序,使我能够找到可以清晰表达的单词(或单词组合),使其在说话时听起来非常快.
我最初认为具有高音节比率的单词将是最好的,但是在编写Python程序来找到这些单词时,我只检索了非常简单的单词,这些单词听起来并不快(例如"iowa").
所以我对实际上听起来很快的话语感到茫然.这是语素与字母的比率吗?它是交替的元音 - 辅音对的数量吗?
你们将如何设计一个python程序来解决这个问题?
这只是黑暗中的一个因为我不是语言学家(尽管我已经写过一个语音合成器),这里有用的指标是构成每个单词的音素数,因为音素本身就是无论使用何时,都是相同的大致持续时间 有一个英语方言的国际音标字母表,以及一个很好的英语语音.
一个好的开源语音字典可以从cmudict项目获得,它有大约130k字
这是一个非常快速的查找程序:
#!/usr/bin/python
import re
words={}
for line in open("cmudict.0.7a",'ro').readlines():
split_idx = line.find(' ')
words[line[0:split_idx]] = line[split_idx+1:-1]
user_input = raw_input("Words: ")
print
for word in user_input.split(' '):
try:
print "%25s %s" % (word, words[word.upper()])
except:
print "%25s %s" % (word, 'unable to find phonems for word')
Run Code Online (Sandbox Code Playgroud)
当运行..
Words: I support hip hop from the underground up
I AY1
support S AH0 P AO1 R T
hip HH IH1 P
hop HH AA1 P
from F R AH1 M
the DH AH0
underground AH1 N D ER0 G R AW2 N D
up AH1 P
Run Code Online (Sandbox Code Playgroud)
如果你想得到超级花哨的裤子,总会有Python自然语言工具包,可能会有一些有用的花絮.
此外,一些现实世界使用 ..虽然公平,我把'stylin'修改为'造型'..但留下'tellin'来揭示未知单词的缺陷..你可能会尝试查找in'以subbing 结尾的单词撇号中的g,然后NG从查找中删除音素.
Yes Y EH1 S
the DH AH0
rhythm R IH1 DH AH0 M
the DH AH0
rebel R EH1 B AH0 L
Without W IH0 TH AW1 T
a AH0
pause P AO1 Z
I'm AY1 M
lowering L OW1 ER0 IH0 NG
my M AY1
level L EH1 V AH0 L
The DH AH0
hard HH AA1 R D
rhymer R AY1 M ER0
where W EH1 R
you Y UW1
never N EH1 V ER0
been B IH1 N
I'm AY1 M
in IH0 N
You Y UW1
want W AA1 N T
styling S T AY1 L IH0 NG
you Y UW1
know N OW1
it's IH1 T S
time T AY1 M
again AH0 G EH1 N
D D IY1
the DH AH0
enemy EH1 N AH0 M IY0
tellin unable to find phonems for word
you Y UW1
to T UW1
hear HH IY1 R
it IH1 T
They DH EY1
praised P R EY1 Z D
etc...
Run Code Online (Sandbox Code Playgroud)
如果这是你计划花一些时间的东西,我会有兴趣帮助.我认为在我的简历中加入'Worlds first rapping IDE'会很有趣.如果已经存在,那么世界上第一个基于Python的rapping IDE.:p
| 归档时间: |
|
| 查看次数: |
1140 次 |
| 最近记录: |