User:Manetta/scripts/python-translate-to-computer-phonemes

From XPUB & Lens-Based wiki
< User:Manetta
Revision as of 10:34, 24 March 2015 by Manetta (talk | contribs) (Created page with "= translating text into computer phonemes = using the CMU dictionary file from the software package [http://cmusphinx.sourceforge.net/ Sphinx] (cmu07a.dic)<br> for download h...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

translating text into computer phonemes

using the CMU dictionary file from the software package Sphinx (cmu07a.dic)
for download here: http://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/


Mb-echo-semantic-simulations-01-page005.png


import re
import os

with open('output.txt', 'w') as txt:

	x = open('input.txt', 'r')
	searchlines = x.readlines()
	x.close()
	print searchlines
	search = searchlines[0].split(" ")
	print search[0]

	for i, searchitem in enumerate(search):
		print searchitem
		dic = open('cmu07a.dic', 'r')
		for line in dic:
			if re.match(searchitem, line): 
				print line
				break		
				txt.write(selection), "\n"
		dic.close()


call	K AO L
me	M IY
echo	EH K OW
my	M AY
wife	W AY F
is	IH Z
echo	EH K OW
my	M AY
brother	B R AH DH ER
is	IH Z
echo	EH K OW
echo	EH K OW
is	IH Z
my	M AY
mom	M AA M
my	M AY
boss	B AA S
name	N EY M
is	IH Z
echo	EH K OW
my	M AY
dad	D AE D
is	IH Z
echo	EH K OW