这只是在黑暗中的一次尝试,因为我不是语言学家(尽管我已经写了一个语音合成器),这里有用的指标是组成每个单词的音素数量,因为音素本身会无论使用如何,都是相同的大致持续时间。有一个英语方言的国际音标图表,以及一个很好的英语音韵。
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')
跑的时候..
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
如果你想获得关于这个的超级花哨的裤子,总有Python Natural Language Toolkit可能对你有一些有用的花絮。
此外,一些现实世界使用.. 虽然公平地说,我将 'stylin' 固定为 'styling'.. 但留下 '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...
如果这是您打算花一些时间做的事情,我很乐意提供帮助。我认为将“世界上第一个说唱 IDE”放在我的简历上会很有趣。如果已经存在的话,世界上第一个基于 Python 的说唱 IDE。:p